You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

array.prototype.group

Package Overview
Dependencies
6
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

array.prototype.group

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


Version published
Maintainers
1
Created

Changelog

Source

v1.1.3 - 2024-03-23

Commits

  • [Deps] update call-bind, es-abstract, es-errors 4b6ab21
  • [Deps] update define-properties, es-abstract, get-intrinsic aefd4b9
  • [readme] add deprecation notice 078df3e
  • [actions] remove redundant finisher 9e768d8
  • [Refactor] use es-errors where possible, so things that only need those do not need get-intrinsic ef8fda5
  • [Deps] update call-bind, define-properties, es-abstract, es-shim-unscopables, get-intrinsic b768483
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, tape 5055f43
  • [Dev Deps] update aud, npmignore, tape 0ab824c
  • [Deps] use 2023 es-abstract impls 94d3e09
  • [Refactor] use es-object-atoms where possible 8d4ffc9
  • [meta] add missing engines.node e190cc1
  • [Dev Deps] update tape a35df78

Readme

Source

DEPRECATED

The proposal this was based on changed, and is now in the language as Object.groupBy/Map.groupBy.

The replacement packages are:

Please use those instead.

array.prototype.group Version Badge

github actions coverage License Downloads

npm badge

An ESnext spec-compliant Array.prototype.group 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 proposed spec.

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

Getting started

npm install --save array.prototype.group

Usage/Examples

var group = require('array.prototype.group');
var assert = require('assert');

var arr = [0, 1, 2, 3, 4, 5];
var parity = function (x) { return x % 2 === 0 ? 'even' : 'odd'; };

var results = group(arr, function (x, i, a) {
    assert.equal(x, arr[i]);
    assert.equal(a, arr);
    return parity(x);
});

assert.deepEqual(results, {
    __proto__: null,
    even: [0, 2, 4],
    odd: [1, 3, 5],
});
var group = require('array.prototype.group');
var assert = require('assert');
/* when Array#group is not present */
delete Array.prototype.group;
var shimmed = group.shim();

assert.equal(shimmed, group.getPolyfill());
assert.deepEqual(arr.group(parity), group(arr, parity));
var group = require('array.prototype.group');
var assert = require('assert');
/* when Array#group is present */
var shimmed = group.shim();

assert.equal(shimmed, Array.prototype.group);
assert.deepEqual(arr.group(parity), group(arr, parity));

Tests

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

Keywords

FAQs

Package last updated on 23 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc