caoge c760052ff9 机车状态修改 8 mēneši atpakaļ
..
test c760052ff9 机车状态修改 8 mēneši atpakaļ
.editorconfig c760052ff9 机车状态修改 8 mēneši atpakaļ
.eslintrc c760052ff9 机车状态修改 8 mēneši atpakaļ
.nycrc c760052ff9 机车状态修改 8 mēneši atpakaļ
CHANGELOG.md c760052ff9 机车状态修改 8 mēneši atpakaļ
LICENSE c760052ff9 机车状态修改 8 mēneši atpakaļ
README.md c760052ff9 机车状态修改 8 mēneši atpakaļ
auto.js c760052ff9 机车状态修改 8 mēneši atpakaļ
implementation.js c760052ff9 机车状态修改 8 mēneši atpakaļ
index.js c760052ff9 机车状态修改 8 mēneši atpakaļ
package.json c760052ff9 机车状态修改 8 mēneši atpakaļ
polyfill.js c760052ff9 机车状态修改 8 mēneši atpakaļ
shim.js c760052ff9 机车状态修改 8 mēneši atpakaļ

README.md

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