1.0.3 • Published 11 days ago

@teamteanpm2024/a-ut-pariatur v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days ago

@teamteanpm2024/a-ut-pariatur 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('@teamteanpm2024/a-ut-pariatur');
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('@teamteanpm2024/a-ut-pariatur');
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('@teamteanpm2024/a-ut-pariatur');
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

TypedArrayfoldercolumnuninstallchannelformatinterruptssigtermhasOwnpersistenthttpchineseparentsapptoolkitprivate datacommand-linetypecss-in-jsrobustjsonschemaarthelperslogger0getintrinsicfetchwalkingdeepzeroreact animationqueueArrayBufferWeakSetxhrprotofsaccessibilityfastclonecallboundeventDispatcherchromiumterminalbootstrap lesspreprocessorxtermeslint-pluginargvasyncschemeWeakMapvestoffset-0mime-db6to5posedebuggerexecutableRegExp#flagslastregexpmodulesiteratorfullwidthconsumereducerfile systemramdabuffersexeoperating-systemperformantieomitkeysliceiteratereducelintrm -rfmomentpolyfilllibphonenumberbyteLengthserializationtexttouchtrimRightsignalextraES2016testingcommandstructuredClonewordbreaktermregularoutputmakeslotes-abstractstringifysymlinksinputwatchtypeofvalidatorReactiveExtensionsmkdires6babelinstallerpackageshooksstartpicomatchRxtc39ES3prefixcurriedquotecopylimitedenumerableutilcallbackECMAScript 2016point-freetypeerrorYAMLsetPrototypeOfjscompile lesscollection.es6toArrayObject.issuperagentsome3dfindupnpmgettermimetypesgradients cssvalidES2017hardlinksyamltddes8awaitimportenvArrayBuffer#sliceweakmapnodejsutilitiesoptimizerObject.getPrototypeOfcomputed-typesargumentsemitqueueMicrotaskhash256ECMAScript 7yupstyled-componentsfullfantasy-landgraphqlstylesheetcommanderES5bufferruntimecss lessSetJSON-SchemaflattensetterECMAScript 2020valuesoncemake dir[[Prototype]]PushdeepclonermmruexecfunctiontypedwindowsgetOwnPropertyDescriptordebugsuperstructargparsetelephonejQuerybatchless cssredactPromisegestureslazyUint32Arraysymbolsincludesnopeconnectwhichdatastructurebcryptrangeerrorminimalsymbolresolvees2016ECMAScript 2018URLremovetypanionregexObject.assignES2020regular expressionsfindHyBidiffmkdirsworkerawesomesaucebreakTypeBoxjestconcatMapdefineformpropertycontainsasciisanitizationspeedcorsECMAScript 2015languagebanneranimationpropfast-deep-copyenvironmentthrottleArray.prototype.flattenduplexglobStreamsestreeECMAScript 6assertsnested cssredux-toolkitnegativepropertiespositivewaitarktypeerrorframermonorepoESnextstablehascore-jsdraghttpsvariables in cssObject.keysfast-deep-clonepasswordObject.entriesIterator.envobjectcharacterarraybufferassertcss nestingfseventssanitizeindicatorxdg-openUnderscorewalkspecmixinssymlinkarraysStyleSheetshammulti-packagejson-schemaisreact-testing-libraryshrinkwrap
1.0.2

12 days ago

1.0.3

11 days ago

1.0.1

13 days ago

1.0.0

14 days ago