Skip to content

maicol07/ts-collections

Repository files navigation

TS Collections

Collections for array and objects data. Heavily faithful to Laravel implementation.

Why?

I love Laravel Collections and I wanted to use them in my TS projects. I tried to find a library that implements them with a good support for JS objects, but I couldn't find any that satisfied my needs, so I decided to create my own.

Differences between Laravel Collections and TS Collections

There are some little differences between Laravel Collections and TS Collections due to how JS/TS works:

  • All names are camelCase (following JS coding standards)

Differences between ts-collections and Laravel Collections

  • There are some new methods:
    • entries
    • toObject
    • toMap
    • isArray (protected)
  • Currently, lazy collections aren't implemented.
  • Currently, macros aren't implemented.
  • Currently, higher order messages aren't implemented.
  • Due to the difference above, you can't use the following Laravel methods on your Collection:
    • chunkWhile
    • countBy

Development Status

Planned releases here: https://github.com/users/maicol07/projects/4/views/1

  • all
  • average
  • avg
  • chunk
  • chunkWhile
  • collapse
  • collect
  • combine
  • concat
  • contains
  • containsOneItem
  • containsStrict
  • count
  • countBy
  • crossJoin
  • dd
  • diff
  • diffAssoc
  • diffAssocUsing
  • diffKeys
  • doesntContain
  • dot
  • dump
  • duplicates
  • duplicatesStrict
  • each
  • eachSpread
  • ensure
  • every
  • except
  • filter
  • first
  • firstOrFail
  • firstWhere
  • flatMap
  • flatten
  • flip
  • forget
  • forPage
  • get
  • groupBy
  • has
  • hasAny
  • implode
  • intersect
  • intersectAssoc
  • intersectByKeys
  • isEmpty
  • isNotEmpty
  • join
  • keyBy
  • keys
  • last
  • lazy
  • macro
  • make
  • map
  • mapInto
  • mapSpread
  • mapToGroups
  • mapWithKeys
  • max
  • median
  • merge
  • mergeRecursive
  • min
  • mode
  • nth
  • only
  • pad
  • partition
  • percentage
  • pipe
  • pipeInto
  • pipeThrough
  • pluck
  • pop
  • prepend
  • pull
  • push
  • put
  • random
  • range
  • reduce
  • reduceSpread
  • reject
  • replace
  • replaceRecursive
  • reverse
  • search
  • shift
  • shuffle
  • skip
  • skipUntil
  • skipWhile
  • slice
  • sliding
  • sole
  • some
  • sort
  • sortBy
  • sortByDesc
  • sortDesc
  • sortKeys
  • sortKeysDesc
  • sortKeysUsing
  • splice
  • split
  • splitIn
  • sum
  • take
  • takeUntil
  • takeWhile
  • tap
  • times
  • toArray
  • toJson
  • transform
  • undot
  • union
  • unique
  • uniqueStrict
  • unless
  • unlessEmpty
  • unlessNotEmpty
  • unwrap
  • value
  • values
  • when
  • whenEmpty
  • whenNotEmpty
  • where
  • whereStrict
  • whereBetween
  • whereIn
  • whereInStrict
  • whereInstanceOf
  • whereNotBetween
  • whereNotIn
  • whereNotInStrict
  • whereNotNull
  • whereNull
  • wrap
  • zip

Credits