Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

array.prototype.reduce

Package Overview
Dependencies
5
Maintainers
1
Versions
6
Issues
File Explorer

Advanced tools

array.prototype.reduce

An ES5 spec-compliant `Array.prototype.reduce` shim/polyfill/replacement that works as far down as ES3.

    1.0.5latest

Version published
Maintainers
1
Weekly downloads
5,430,312
decreased by-22%

Weekly downloads

Changelog

Source

v1.0.5 - 2022-11-03

Commits

  • [meta] use npmignore to autogenerate an npmignore file a2333c6
  • [Deps] update es-abstract 86a838f
  • [actions] update rebase action to use reusable workflow 4710394
  • [Dev Deps] update aud, tape e2bcb57
  • [Deps] update define-properties, es-abstract 4c693aa
  • [Deps] update es-abstract ca5557c
  • [Dev Deps] update functions-have-names dcb2d35

Readme

Source

array.prototype.reduce Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ES5 spec-compliant Array.prototype.reduce shim/polyfill/replacement that works as far down as ES3.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec.

Because Array.prototype.reduce depends on a receiver (the “this” value), the main export takes the array to operate on as the first argument.

Example

var reduce = require('array.prototype.reduce'); var assert = require('assert'); assert.equal(reduce([1, 2, 3], function (prev, x) { return prev + x; }), 6); assert.equal(reduce([1, 2, 3], function (prev, x) { return prev + x; }, 1), 7); var reduce = require('array.prototype.reduce'); var assert = require('assert'); /* when Array#reduce is not present */ delete Array.prototype.reduce; var shimmed = reduce.shim(); assert.equal(shimmed, reduce.getPolyfill()); var arr = [1, 2, 3]; var sum = function (a, b) { return a + b; }; assert.equal(arr.reduce(sum), reduce(arr, sum)); assert.equal(arr.reduce(sum), 6); assert.equal(arr.reduce(sum, 1), 7); var reduce = require('array.prototype.reduce'); var assert = require('assert'); /* when Array#reduce is present */ var shimmed = reduce.shim(); assert.equal(shimmed, Array.prototype.reduce); assert.equal(arr.reduce(sum), reduce(arr, sum));

Tests

Simply clone the repo, npm install, and run npm test

Keywords

FAQs

What is array.prototype.reduce?

An ES5 spec-compliant `Array.prototype.reduce` shim/polyfill/replacement that works as far down as ES3.

Is array.prototype.reduce popular?

The npm package array.prototype.reduce receives a total of 4,528,835 weekly downloads. As such, array.prototype.reduce popularity was classified as popular.

Is array.prototype.reduce well maintained?

We found that array.prototype.reduce demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 04 Nov 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc