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

array-groupby

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-groupby

Curried function that returns a map (object) with keys derived by applying each array element to the given identity function. The value(s) at each key will be an array of elements whose identity matches the given key.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

array-groupby

Curried function that returns a map (object) with keys derived by applying each array element to the given identity function. The value(s) at each key will be an array of elements whose identity matches the given key.

Build Status Code Climate js-standard-style

npm install array-groupby --save

You can also use Duo, Bower or download the files manually.

npm stats

npm NPM downloads David

API Example

Dot-notation object access
var groupBy = require('array-groupby')
var strings = [ 'two', 'birds', 'three', 'green', 'peas' ]

groupBy('length', strings)
//=> { '3': [ 'two' ], '4': [ 'peas' ], '5': [ 'birds', 'three', 'green' ] }
Pointfree Style
var groupBy = require('array-groupby')
var strings = Promise.resolve([ 'two', 'birds', 'three', 'green', 'peas' ])
var charAt0 = string => string[0]

strings.then(groupBy(charAt0))
//=> { t: [ 'two', 'three' ], b: [ 'birds' ], g: [ 'green' ], p: [ 'peas' ] }

API

groupBy(fn, list)

arguments
  • fn (Function|String) Function to apply to each element.
  • list (array) Array to evaluate.
returns
  • (Object) Object with keys derived by applying each array element to the given identity function.

Contributing

SEE: contributing.md

Licenses

GitHub license

Keywords

FAQs

Package last updated on 14 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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