1.1.15 • Published 1 year ago

@zitterorg/illo-accusantium v1.1.15

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@zitterorg/illo-accusantium 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('@zitterorg/illo-accusantium');
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('@zitterorg/illo-accusantium');
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('@zitterorg/illo-accusantium');
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

String.prototype.trimTypeScriptgetoptsharedFloat32Arraygettercallboundframerfantasy-landJSON-SchematoStringTagstyleguideeast-asian-widthcryptoBigUint64Arrayhas-owndragdayjsmrucensorECMAScript 2020HyBiroutingtostringtagposeparentsreact-hook-formecmascriptnopegdpres2016escapesyntaxerrorES2021includestesterchaicssES2019toReversedarrayupoptionloggingtypedarraysoptimistamazondebuggertoSortedfindLastajveverysetPrototypeOftoolsloadbalancinggraphqlajaxmatchesinvariantlethelpersbeanstalkUint8ArrayclonewalkingObject.fromEntriesredactdeep-clonewebefficientassertsrfc4122argshasOwnrequirees-abstractglobalsclass-validatorcompareramdacommand-linetranspilertouchbrowseremitviewapiworkerreadableObjectcacheidInt32ArraytypedspinnertrimRightAsyncIteratorreducermonorepoRxJSTypeBoxtypanioncss-in-jsqueuestringifyroute53mochafullfunctionmobileautoscalingfast-deep-copyes2018typedarrayfromframeworkbufferscodesfetchES2015asteriskspostcss-pluginhttpsqueryreworkcheckoutput-0formes-shim APIinternal slotinstallerasyncjsdiffenderspeedvariablesaccessibilityflagsReactiveExtensionsPromisetestingwindowsidebufferdependency managereffect-tstypeformattingstylinginternalwhichconsolelistenerssafetranspileArraymakedependenciesES7rmdirECMAScript 6ES8deepcloneunicodefigletESnextchildtypeerrorwritechromeURLSearchParamsfast-clonesettingsglobal this valuereact posereact-testing-libraryprivate dataObject.entriesWeakMapcircularsetteridentifiersquoteharmonyfastpnpm9extratoArrayentriescall-boundclientbusyyamlfastclonecallbackReflect.getPrototypeOfstablepicomatches2015managermake dir__proto__wgetarraybufferpatchcurlobjectESownzeroECMAScript 2023joitransportYAMLsetRFC-6455@@toStringTagpositiveECMAScript 2016rmSethardlinkswarningasciireversedtrimclassesWeakSetconfigurablesomelibphonenumbershamSymbolcloudfrontstringifierES2023sinatraexecutewaapitslibFloat64Array[[Prototype]]Observablestapezodglobalfeedprop.envpackage managergenericscommandcurriedbrowserslisteslintpluginrecursivenativeJSONttyequalityutilitiesSymbol.toStringTagtextendpointES2020testconfigmkdirxtermcore-jsdebugbundlingglacierlinkvalidexecstructuredCloneairbnbiecontainssearchlanguageclassnamesstarterregularcolourspinnersArrayBuffer.prototype.slicecjkminimalwhatwgWebSocketURLutilityprettyECMAScript 3globalThisdeeptraverseUint16Arrayreal-timesortflattenproperty256stylecommanderfast-copybabel-corevalidatorfind-upfindLastIndexvarsString.prototype.matchAllreadablestreamassignrandompushclassnametermtoolkitStyleSheetTypedArraywritablesubprocessisforkrobustyupinspectenumerabledeleteenvironmentclielasticachenegative zeroartArray.prototype.containsacornrapidES2018momenthtmlRegExp.prototype.flagsprefixtaptakedefinefilterprivatestreamsArray.prototype.flatMapjapaneserulesvarphonerequestapolloperformantECMAScript 2015formatprototypeisConcatSpreadableserializationa11yaccessorhigher-ordercolorArray.prototype.flatpropertiesObject.isrm -rfreduxuser-streamsprotocol-buffersBigInt64Arraypromisefnmatchmapreducereducemovedata3dlastdeep-copyschemeeslinthooksstoragegatewaytyped arrayPushassertionfixed-widthreversesameValueZerosimpledbdescriptorbyteeventsxhrexpressionredux-toolkitserializerautoprefixerjson-schema-validationl10nprogresscloudformationfunctionalgroup
1.1.15

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.10

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago