Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //todo
- //Array.prototype.askeyscombineintoobjwithvaluesfrom = function (arr) {} <--licia combine
- //findlastoccurrence findlastidx
- //extendDeep -- merge parts of an object deeply into main obj -- mergewithobj
- //!compact -- [0, 1, false, 2, '', 3] // -> [1, 2, 3] --removegarbage
- //defaults -- fill in default key/value information when instantiating objects that you dont provide initially.
- //find -- find first occ where whole object where key.value = [input] -- findfirstwherekeyvalueis -- useful for json return entire list of skus that match
- //findKey -- find the key where value = [input] -- findkeynamewhereavalueis
- //!invert -- useful keys become values and vice versa object { a: 'b', c: 'd', e: 'f' } // -> {b: 'a', d: 'c', f: 'e'}
- //!intersect -- self explanatory, [arr1 not in arr2 and arr2 not in arr1, can be up to arrN] [1, 2, 3, 4], [2, 1, 10] // -> [1, 2]
- //isMatch -- matches object notation needle in a big haystack obj { a: 1, b: 2 }, { a: 1 } // -> true
- //has -- boolean return if an obj has key set for needle input { one: 1 }, 'one' // -> true has key entry -- haskeyset
- //keys -- get keys as array from an obj { a: 1, b: 2 } // -> ['a','b'] -- getkeys
- //!!!values -- like keys, but returns in array all values of all keys encountered. -- getvalues
- //format -- '%s_%s', 'foo', 'bar' // -> 'foo_bar'
- //!matcher -- [FIND WHERE SKU = FOO AND COLOR = BAR] finds within json obj things that match multiple key conditions filter(objects, matcher({ a: 4, c: 6 })); // -> [{a: 4, b: 5, c: 6}] -- getallvalueswhere -- getallrecords -- findallthatmatch
- //!mapObj -- map like array but for object values -- useful for hashmap
- //omit -- return an object (non-mutated) without certain keys that are specified -- without
- //pairs -- { a: 1, b: 2 } // -> [['a', 1], ['b', 2]]
- //pick -- like omit but you specify only the ones you want to display as opposed to ones you want to omit -- filterouteverythingexcept
- //pluck -- like pick, but in entire json object and output as array based on key entry provided. -- filterouteverythingexcept
- //!remove -- mutates array similar to like filter, but mutating
- //!safeGet -- if not set, will not through error, just undefined. useful for mistakes in ramda arthur scripts getval
- //!safeSet -- very useful, deep creation without error thrown if parent branch of obj not exist -- setval
- //!safeDel -- can pass array, nested dot notation a.aa.aaa and it will deep delete -- delval
- //swap -- mutating array, little mix of splice and slice, swap values in index
- //!!!union -- combines arrays up to arrN, discards duplicate occurences in each array -- combinewithandremovedupes
- //?unzip -- weird but has ability to turn rows into columns of array arr0[arr1[i][j],arr2[j][j]] = arr0[arr3[arr1[i],arr2[j]]...]
- //todo
- // Object mergewithobj //extendDeep -- merge parts of an object deeply into main obj -- mergewithobj
- // Array removegarbage //!compact -- [0, 1, false, 2, '', 3] // -> [1, 2, 3] --removegarbage
- // Json Object findwherekeyvalueis //find -- find first occ where whole object where key.value = [input] -- findfirstwherekeyvalueis -- useful for json return entire list of skus that match
- // Object findkeynamewhereval //findKey -- find the key where value = [input] -- findkeynamewhereavalueis
- // Object invert -- convertkeysintovaluesandviceversa -- viceversa -- flip //!invert -- useful keys become values and vice versa object { a: 'b', c: 'd', e: 'f' } // -> {b: 'a', d: 'c', f: 'e'}
- // Array intersectwith -- combineandfilteroutdupes //!intersect -- self explanatory, [arr1 not in arr2 and arr2 not in arr1, can be up to arrN] [1, 2, 3, 4], [2, 1, 10] // -> [1, 2]
- // Object deepsearchforpropwhere //isMatch -- matches object notation needle in a big haystack obj { a: 1, b: 2 }, { a: 1 } // -> true
- // Object haskeyset //has -- boolean return if an obj has key set for needle input { one: 1 }, 'one' // -> true has key entry -- haskeyset
- // Object getkeysasarray //keys -- get keys as array from an obj { a: 1, b: 2 } // -> ['a','b'] -- getkeys
- // Object getvalsasarray //!!!values -- like keys, but returns in array all values of all keys encountered. -- getvalues
- // Json Object getallvalueswhere -- getallrecords -- findallthatmatch //!matcher -- [FIND WHERE SKU = FOO AND COLOR = BAR] finds within json obj things that match multiple key conditions filter(objects, matcher({ a: 4, c: 6 })); // -> [{a: 4, b: 5, c: 6}] -- getallvalueswhere -- getallrecords -- findallthatmatch
- // Object without //omit -- return an object (non-mutated) without certain keys that are specified -- without
- // Object filtereverythingexcept //pick -- like omit but you specify only the ones you want to display as opposed to ones you want to omit -- filterouteverythingexcept
- // Json Object filtereverythingexcept //pluck -- like pick, but in entire json object and output as array based on key entry provided. -- filterouteverythingexcept
- // Array removewhere //!remove -- mutates array similar to like filter, but mutating
- // Object getprop //!safeGet -- if not set, will not through error, just undefined. useful for mistakes in ramda arthur scripts getval
- // Object setprop //!safeSet -- very useful, deep creation without error thrown if parent branch of obj not exist -- setval
- // Object deleteprop //!safeDel -- can pass array, nested dot notation a.aa.aaa and it will deep delete -- delval
- // Array combinewithandremovedupes -- union //!!!union -- combines arrays up to arrN, discards duplicate occurences in each array -- combinewithandremovedupes
Add Comment
Please, Sign In to add comment