Skip to content

Releases: DusanKasan/Knapsack

Filter without an argument

20 May 18:49
Compare
Choose a tag to compare
  • Filter without an argument (defaults to null) will remove falsy values

Intersect added, getNth removed, difference renamed to diff.

04 May 16:58
Compare
Choose a tag to compare
  • Intersect function added
  • Average utility function added
  • Concatenate utility function added
  • Reduce/reduceRight/second now have the returnAsCollection flag
  • Breaking change: getNth removed (to solve ambiguity with takeNth, use values()->get(n))
  • Breaking change: difference renamed to diff

Zip and transform added, extract replacing pluck

02 May 18:41
Compare
Choose a tag to compare
  • Zip function added // zips together items from multiple collections
  • Extract function added // extracts data from sub-collections using dot separated key path
  • Transform function added // transforms a collection using callable
  • Breaking change: combine now stops when it runs out of keys or values
  • Breaking change: pluck removed (replaced by extract)

More collection functions, CollectionTrait and bugfixes

27 Apr 20:56
Compare
Choose a tag to compare

There are some new functions, specifically:

  • second() // seems useless but really usefull :)
  • combine($values) // uses current collection as keys, $values as values
  • except($keys) // rejects every item with key found in $keys
  • only($keys) // filters only items with key found in $keys
  • difference(...$collections) // filters items that are in the original collection but not in any of $collections
  • flip() // flips keys with values
  • has($key) // checks for the existence of item with $key key

CollectionTrait has been introduced and its usage documented in readme.

A handful of bugfixes also:

  • Collection constructor might have experienced conflicts between callable (in array form) and array arguments
  • Pluck might have failed on heterogenous collections. Now ignores non-collection items.

Further normalization of return values

21 Apr 11:23
Compare
Choose a tag to compare

Automatic conversion of return values to Collections is no longer happening if you do not explicitly require it. Details in documentation.

New namespace, realize() and more variadics

11 Apr 20:03
Compare
Choose a tag to compare

Project moved to new global namespace DusanKasan (whole namespace is DusanKasan\Knapsack) to avoid conflicts. Collection::realize was introduced to force materialization of the collection (turning lazy collection into non-lazy). Collection::concat and Collection::interleave are now variadic.

Breaking change: toArray and Collection::toArray now behave more logicaly and do not convert items recursively.

Documentation/Readme reflects all these changes.

Version 1.0.0

07 Apr 07:02
Compare
Choose a tag to compare

The project is ready for production use. No known bugs exist.

Total overhaul and move to more functional design

19 Nov 07:54
Compare
Choose a tag to compare

Collection class now uses Generator functions under the hood. The functions are also accessible allowing for functional programming. Performance improved 2x.