Socket
Socket
Sign inDemoInstall

immutable

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0

2

package.json
{
"name": "immutable",
"version": "4.1.0",
"version": "4.2.0",
"description": "Immutable Data Collections",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -640,2 +640,42 @@ # Immutable collections for JavaScript

## Comparison of filter(), groupBy(), and partition()
The `filter()`, `groupBy()`, and `partition()` methods are similar in that they
all divide a collection into parts based on applying a function to each element.
All three call the predicate or grouping function once for each item in the
input collection. All three return zero or more collections of the same type as
their input. The returned collections are always distinct from the input
(according to `===`), even if the contents are identical.
Of these methods, `filter()` is the only one that is lazy and the only one which
discards items from the input collection. It is the simplest to use, and the
fact that it returns exactly one collection makes it easy to combine with other
methods to form a pipeline of operations.
The `partition()` method is similar to an eager version of `filter()`, but it
returns two collections; the first contains the items that would have been
discarded by `filter()`, and the second contains the items that would have been
kept. It always returns an array of exactly two collections, which can make it
easier to use than `groupBy()`. Compared to making two separate calls to
`filter()`, `partition()` makes half as many calls it the predicate passed to
it.
The `groupBy()` method is a more generalized version of `partition()` that can
group by an arbitrary function rather than just a predicate. It returns a map
with zero or more entries, where the keys are the values returned by the
grouping function, and the values are nonempty collections of the corresponding
arguments. Although `groupBy()` is more powerful than `partition()`, it can be
harder to use because it is not always possible predict in advance how many
entries the returned map will have and what their keys will be.
| Summary | `filter` | `partition` | `groupBy` |
|:------------------------------|:---------|:------------|:---------------|
| ease of use | easiest | moderate | hardest |
| generality | least | moderate | most |
| laziness | lazy | eager | eager |
| # of returned sub-collections | 1 | 2 | 0 or more |
| sub-collections may be empty | yes | yes | no |
| can discard items | yes | no | no |
| wrapping container | none | array | Map/OrderedMap |
## Additional Tools and Resources

@@ -642,0 +682,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc