Socket
Socket
Sign inDemoInstall

accumulate-values

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    accumulate-values

Accumulate values via a reducer


Version published
Weekly downloads
69
decreased by-25.81%
Maintainers
1
Install size
9.58 kB
Created
Weekly downloads
 

Readme

Source

accumulate-values Build Status

Accumulate values via a reducer

Install

$ npm install --save accumulate-values

Usage

var accumulate = require('accumulate-values')
;[0, 1, 2].reduce(accumulate()) // => 3
;['0', '1', '2'].reduce(accumulate()) // => '012'
;[[0, 1], [2, 3]].reduce(accumulate()) // => 6

API

accumulate() -> function

Returns a function to be passed to Array.prototype.reduce. If the first item in the array is a number, future values are added to the initial value. If it is a string, future values are concatenated. If it is an array, future values are concatenated via [].concat.

License

MIT © Ben Drucker

Keywords

FAQs

Last updated on 06 Jun 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc