Socket
Socket
Sign inDemoInstall

array-reduce-x

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-reduce-x

Reduce an array (from left to right) to a single value.


Version published
Weekly downloads
792
increased by43.48%
Maintainers
1
Weekly downloads
 
Created
Source

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

array-reduce-x

Reduce an array (from left to right) to a single value.

module.exports*

This method applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value.

Kind: Exported member
Returns: * - The value that results from the reduction.
Throws:

  • TypeError If array is null or undefined.
  • TypeError If callBack is not a function.
  • TypeError If called on an empty array without an initial value.
ParamTypeDescription
arrayarrayThe array to iterate over.
callBackfunctionFunction to execute for each element.
[initialValue]*Value to use as the first argument to the first call of the callback. If no initial value is supplied, the first element in the array will be used. Calling reduce on an empty array without an initial value is an error.

Example

import reduce from 'array-reduce-x';

console.log(
  reduce(
    [0, 1, 2, 3],
    function(a, b) {
      return a + b;
    },
    0,
  ),
); // sum is 6

Keywords

FAQs

Package last updated on 28 Aug 2019

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