Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3
An ESnext spec-compliant `Array.prototype.group` shim/polyfill/replacement that works as far down as ES3.
License
es-shims/Array.prototype.group
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The proposal this was based on changed, and is now in the language asObject.groupBy/Map.groupBy.
The replacement packages are:
Please use those instead.
An ESnext spec-compliantArray.prototype.group
shim/polyfill/replacement that works as far down as ES3.
This package implements thees-shim API interface. It works in an ES3-supported environment and complies with the proposedspec.
BecauseArray.prototype.group
depends on a receiver (thethis
value), the main export takes the array to operate on as the first argument.
npm install --save array.prototype.group
vargroup=require('array.prototype.group');varassert=require('assert');vararr=[0,1,2,3,4,5];varparity=function(x){returnx%2===0 ?'even' :'odd';};varresults=group(arr,function(x,i,a){assert.equal(x,arr[i]);assert.equal(a,arr);returnparity(x);});assert.deepEqual(results,{__proto__:null,even:[0,2,4],odd:[1,3,5],});
vargroup=require('array.prototype.group');varassert=require('assert');/* when Array#group is not present */deleteArray.prototype.group;varshimmed=group.shim();assert.equal(shimmed,group.getPolyfill());assert.deepEqual(arr.group(parity),group(arr,parity));
vargroup=require('array.prototype.group');varassert=require('assert');/* when Array#group is present */varshimmed=group.shim();assert.equal(shimmed,Array.prototype.group);assert.deepEqual(arr.group(parity),group(arr,parity));
Simply clone the repo,npm install
, and runnpm test
About
An ESnext spec-compliant `Array.prototype.group` shim/polyfill/replacement that works as far down as ES3.
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.