Socket
Socket
Sign inDemoInstall

@ndhoule/foldl

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ndhoule/foldl

Apply a function to each value in a collection, accumulating the results into a single return value.


Version published
Weekly downloads
21K
decreased by-10.96%
Maintainers
1
Weekly downloads
 
Created
Source

foldl CI

Apply a function to each value in a collection, accumulating the results into a single return value.

Installation

$ component install ndhoule/foldl
$ npm install @ndhoule/foldl

API

reduce(iterator : Function, accumulator : *, collection : Array|Object)

Reduces all the values in a collection down into a single value. Does so by iterating through the collection from left to right, repeatedly calling an iterator function and passing to it four arguments: (accumulator, value, index, collection).

foldl(function(total, n) {
  return total + n;
}, 0, [1, 2, 3]);
//=> 6

var phonebook = { bob: '555-111-2345', tim: '655-222-6789', sheila: '655-333-1298' };

foldl(function(results, phoneNumber) {
 if (phoneNumber[0] === '6') {
   return results.concat(phoneNumber);
 }
 return results;
}, [], phonebook);
// => ['655-222-6789', '655-333-1298']

License

Released under the MIT license.

Keywords

FAQs

Package last updated on 02 May 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