Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@supercharge/collections

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@supercharge/collections - npm Package Versions

1345

3.1.4

Diff

Changelog

Source

3.1.4 - 2021-02-05

Fixed

  • fixed types for first and shift
marcuspoehls
published 3.1.3 •

Changelog

Source

3.1.3 - 2021-01-28

Fixed

  • fixed another typing issue for flatMap
marcuspoehls
published 3.1.2 •

Changelog

Source

3.1.2 - 2021-01-07

Fixed

  • fixed typings for map and flatMap
marcuspoehls
published 3.1.1 •

Changelog

Source

3.1.1 - 2021-01-03

Fixed

  • fixed types: make predicate parameter optional for Collection#first
marcuspoehls
published 3.1.0 •

Changelog

Source

3.1.0 - 2020-12-02

Updated

  • bump dependencies
  • change typings to allow single values and arrays (T | T[]) when creating collections
marcuspoehls
published 3.0.0 •

Changelog

Source

3.0.0 - 2020-09-03

Added

  • synchronous collections by default
    • all collections were async by default until versions 2.x, you had to await every collection pipeline
    • this changes with the release of version 3.0: all collections are sync by default
    • synchronous collections work like JavaScript’s array methods
    • you must explicitly call collection.all() to retrieve the resulting array from a synchronous collection
  • a collection becomes async as soon as you provide an async callback method to methods like map, filter, find, and so on:

Updated

  • bump dependencies
  • change main entrypoint in package.json to dist folder

Removed

  • remove index.js file which acted as a middleman to export from dist folder

Breaking Changes

  • collections are now synchronous by default, meaning you don’t need to await a collection if you’re not using an async callback
Sync Collections

Synchronous collections work like JavaScript’s Array methods. For example, the following pipeline stays a synchronous pipeline:

const Collect = require('@supercharge/collections')

const collection = Collect([1, 2, 3, 4, 5])
  .map(item => item * 2)
  .filter(item => item > 5)
  .sort((a, b) => b -a)

// on sync collections, you must explicitly call `.all()` to retrieve the result

const result = collection.all()
//  [10, 8, 6]
Async Collections

In comparison, a collection becomes async as soon as you provide an async callback method to methods like map, filter, find, and so on:

const Collect = require('@supercharge/collections')

const collection = Collect([1, 2, 3, 4, 5])
  .map(async item => item * 2) // the collection is async from here on
  .filter(item => item > 5)
  .sort((a, b) => b -a)

// async collections must be awaited

const result = await collection
//  [10, 8, 6]
marcuspoehls
published 2.4.0 •

Changelog

Source

2.4.0 - 2020-07-21

Added

  • uniqueBy(callback) method: create a collection of unique items where each unique item is identified by a value returned from the callback
  • GitHub Action to publish the package in the GitHub Package Registry
marcuspoehls
published 2.3.0 •

Changelog

Source

2.3.0 - 2020-07-19

Added

  • flatten() method: flatten the collection one level deep
  • typed collections: improved TypeScript type definitions enable IntelliSense (when possible) inside callback methods
marcuspoehls
published 2.2.0 •

Changelog

Source

2.2.0 - 2020-07-02

Added

  • filterIf(condition, callback) method: a variant of the the filter method only filtering the collection if the condition evaluates to true
marcuspoehls
published 2.1.0 •

Changelog

Source

2.1.0 - 2020-06-30

Added

  • count method
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