rush icon indicating copy to clipboard operation
rush copied to clipboard

Port some of the LoDash functions

Open Xion opened this issue 9 years ago • 0 comments

LoDash/Underscore is a widely used Javascript library with some helper functions. Many of them could be translated directly to rush.

  • [ ] chunk (for arrays and strings)
  • [x] compact (equivalent of filter(bool & (!)) if that was a valid syntax)
  • [ ] concat (accepting variable number of array arguments)
  • [ ] deburr (as Unicode NFD conversion)
  • [ ] flip
  • [ ] flatten (like concat but accepts array of arrays)
  • [ ] head (both arrays and strings)
  • [x] identity (as id)
  • [ ] initial (as init)
  • [x] invert (as an overload for rev for object arguments)
  • [x] keys (for objects, arrays, and strings (return array of indices for the latter two))
  • [ ] last (both arrays and strings)
  • [ ] now (possibly as time; may make sense to create a datetime/instant type)
  • [x] omit (for objects, arrays, and strings; keys as array)
  • [ ] pad (for both strings and arrays)
  • [ ] padEnd (as padright, for both strings and arrays)
  • [ ] padStart (as padleft, for both strings and arrays)
  • [x] pick (for objects, arrays, and strings; keys as array)
  • [x] reject (opposite of filter)
  • [x] sample(Size) (as sample, for arrays, strings, and objects (return random value for objects); sample size as first arg)
  • [x] shuffle (for arrays and strings)
  • [ ] tail (both arrays and strings)
  • [ ] uniq (both arrays and objects (objects uniq'd by values))
  • [ ] uniqBy (both arrays and objects (objects uniq'd by values))
  • [x] values
  • [x] words
  • [ ] zipObject (as object; it should accept either two same-sized arrays (keys and values), or a single array (alternating keys and values))

Xion avatar May 14 '16 04:05 Xion