MCPcopy Create free account
hub / github.com/codrops/RainEffect / createDictMethod

Function createDictMethod

demo/js/index3.js:1463–1488  ·  view source on GitHub ↗
(TYPE)

Source from the content-addressed store, hash-verified

1461// 6 -> Dict.findKey
1462// 7 -> Dict.mapPairs
1463var createDictMethod = function(TYPE){
1464 var IS_MAP = TYPE == 1
1465 , IS_EVERY = TYPE == 4;
1466 return function(object, callbackfn, that /* = undefined */){
1467 var f = ctx(callbackfn, that, 3)
1468 , O = toIObject(object)
1469 , result = IS_MAP || TYPE == 7 || TYPE == 2
1470 ? new (typeof this == 'function' ? this : Dict) : undefined
1471 , key, val, res;
1472 for(key in O)if(has(O, key)){
1473 val = O[key];
1474 res = f(val, key, object);
1475 if(TYPE){
1476 if(IS_MAP)result[key] = res; // map
1477 else if(res)switch(TYPE){
1478 case 2: result[key] = val; break; // filter
1479 case 3: return true; // some
1480 case 5: return val; // find
1481 case 6: return key; // findKey
1482 case 7: result[res[0]] = res[1]; // mapPairs
1483 } else if(IS_EVERY)return false; // every
1484 }
1485 }
1486 return TYPE == 3 || IS_EVERY ? IS_EVERY : result;
1487 };
1488};
1489var findKey = createDictMethod(6);
1490
1491var createDictIter = function(kind){

Callers 1

index3.jsFile · 0.70

Calls 2

ctxFunction · 0.70
fFunction · 0.70

Tested by

no test coverage detected