pharmokan

Licia todo prototypes extension

Apr 17th, 2020
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. //todo
  2. //Array.prototype.askeyscombineintoobjwithvaluesfrom = function (arr) {} <--licia combine
  3. //findlastoccurrence findlastidx
  4. //extendDeep -- merge parts of an object deeply into main obj -- mergewithobj
  5. //!compact -- [0, 1, false, 2, '', 3] // -> [1, 2, 3] --removegarbage
  6. //defaults -- fill in default key/value information when instantiating objects that you dont provide initially.
  7. //find -- find first occ where whole object where key.value = [input] -- findfirstwherekeyvalueis -- useful for json return entire list of skus that match
  8. //findKey -- find the key where value = [input] -- findkeynamewhereavalueis
  9. //!invert -- useful keys become values and vice versa object { a: 'b', c: 'd', e: 'f' } // -> {b: 'a', d: 'c', f: 'e'}
  10. //!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]
  11. //isMatch -- matches object notation needle in a big haystack obj { a: 1, b: 2 }, { a: 1 } // -> true
  12. //has -- boolean return if an obj has key set for needle input { one: 1 }, 'one' // -> true has key entry -- haskeyset
  13. //keys -- get keys as array from an obj { a: 1, b: 2 } // -> ['a','b'] -- getkeys
  14. //!!!values -- like keys, but returns in array all values of all keys encountered. -- getvalues
  15. //format -- '%s_%s', 'foo', 'bar' // -> 'foo_bar'
  16. //!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
  17. //!mapObj -- map like array but for object values -- useful for hashmap
  18. //omit -- return an object (non-mutated) without certain keys that are specified -- without
  19. //pairs -- { a: 1, b: 2 } // -> [['a', 1], ['b', 2]]
  20. //pick -- like omit but you specify only the ones you want to display as opposed to ones you want to omit -- filterouteverythingexcept
  21. //pluck -- like pick, but in entire json object and output as array based on key entry provided. -- filterouteverythingexcept
  22. //!remove -- mutates array similar to like filter, but mutating
  23. //!safeGet -- if not set, will not through error, just undefined. useful for mistakes in ramda arthur scripts getval
  24. //!safeSet -- very useful, deep creation without error thrown if parent branch of obj not exist -- setval
  25. //!safeDel -- can pass array, nested dot notation a.aa.aaa and it will deep delete -- delval
  26. //swap -- mutating array, little mix of splice and slice, swap values in index
  27. //!!!union -- combines arrays up to arrN, discards duplicate occurences in each array -- combinewithandremovedupes
  28. //?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]]...]
  29.  
  30. //todo
  31. // Object mergewithobj //extendDeep -- merge parts of an object deeply into main obj -- mergewithobj
  32. // Array removegarbage //!compact -- [0, 1, false, 2, '', 3] // -> [1, 2, 3] --removegarbage
  33. // 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
  34. // Object findkeynamewhereval //findKey -- find the key where value = [input] -- findkeynamewhereavalueis
  35. // 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'}
  36. // 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]
  37. // Object deepsearchforpropwhere //isMatch -- matches object notation needle in a big haystack obj { a: 1, b: 2 }, { a: 1 } // -> true
  38. // Object haskeyset //has -- boolean return if an obj has key set for needle input { one: 1 }, 'one' // -> true has key entry -- haskeyset
  39. // Object getkeysasarray //keys -- get keys as array from an obj { a: 1, b: 2 } // -> ['a','b'] -- getkeys
  40. // Object getvalsasarray //!!!values -- like keys, but returns in array all values of all keys encountered. -- getvalues
  41. // 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
  42. // Object without //omit -- return an object (non-mutated) without certain keys that are specified -- without
  43. // Object filtereverythingexcept //pick -- like omit but you specify only the ones you want to display as opposed to ones you want to omit -- filterouteverythingexcept
  44. // Json Object filtereverythingexcept //pluck -- like pick, but in entire json object and output as array based on key entry provided. -- filterouteverythingexcept
  45. // Array removewhere //!remove -- mutates array similar to like filter, but mutating
  46. // Object getprop //!safeGet -- if not set, will not through error, just undefined. useful for mistakes in ramda arthur scripts getval
  47. // Object setprop //!safeSet -- very useful, deep creation without error thrown if parent branch of obj not exist -- setval
  48. // Object deleteprop //!safeDel -- can pass array, nested dot notation a.aa.aaa and it will deep delete -- delval
  49. // Array combinewithandremovedupes -- union //!!!union -- combines arrays up to arrN, discards duplicate occurences in each array -- combinewithandremovedupes
Add Comment
Please, Sign In to add comment