npm install object.groupby

An ESnext spec-compliant `Object.groupBy` shim/polyfill/replacement that works as far down as ES3.

About object.groupby

The "object.groupby" npm package is an essential tool for developers working with JavaScript, particularly those who need to implement data manipulation techniques efficiently. This node module offers a compliant solution with the ESnext specification, providing a `Object.groupBy` shim/polyfill/replacement that is compatible back to ES3, making it incredibly versatile across different JavaScript environments. The key purpose of "object.groupby" is to allow developers to easily group objects based on shared property values, facilitating more organized data structures and streamlined data processing tasks. This package enhances code readability and maintainability, crucial for large-scale projects where data management is a core component.

For developers looking to integrate "object.groupby" into their projects, the installation process is straightforward using the command `npm install object.groupby`. This simple command sets up the package in your development environment, allowing you to immediately benefit from its features. The benefits of using "object.groupby" include reduced development time and increased accuracy in data manipulation tasks. By grouping objects based on predefined criteria, developers can minimize the complexity of handling large datasets and improve the performance of data-driven applications. This makes "object.groupby" an invaluable addition to your development toolkit, especially when working with complex data structures that require efficient sorting and grouping mechanisms.

The "object.groupby" module also stands out with its robust compatibility and performance, thanks to its compliance with the ESnext specification. This ensures that developers can use the latest JavaScript features without sacrificing the performance and compatibility with older JavaScript versions. As a result, "object.groupby" is not only a tool for current projects but also a future-proof solution that can adapt to evolving development standards and practices. With its powerful features and backward compatibility, "object.groupby" is a top choice for developers aiming to enhance their applications' data processing capabilities.

More from es-shims

es-shims npm packages

Find the best node modules for your project.

Search npm

regexp.prototype.flags

ES6 spec-compliant RegExp.prototype.flags shim...

Read more
,

string.prototype.trimend

ES2019 spec-compliant String.prototype.trimEnd shim...

Read more
,

string.prototype.trimstart

ES2019 spec-compliant String.prototype.trimStart shim...

Read more
,

arraybuffer.prototype.slice

ES spec-compliant shim for ArrayBuffer.prototype...

Read more
,

string.prototype.matchall

Spec-compliant polyfill for String.prototype...

Read more
,

object.groupby

An ESnext spec-compliant `Object.groupBy` shim/polyfill/replacement that works as far down as ES3...

Read more
,

array.prototype.tosorted

An ESnext spec-compliant `Array.prototype...

Read more
,

es-iterator-helpers

An ESnext spec-compliant iterator helpers shim/polyfill/replacement that works as far down as ES3...

Read more
,

array.prototype.toreversed

An ESnext spec-compliant `Array.prototype...

Read more
,

typedarray.prototype.slice

ES spec-compliant shim for TypedArray.prototype...

Read more
,

string.prototype.replaceall

Spec-compliant polyfill for String.prototype...

Read more
,

error-cause

An ES-spec-compliant shim/polyfill/replacement for the `...

Read more

Dependencies

Core dependencies of this npm package and its dev dependencies.

call-bind, define-properties, es-abstract, @es-shims/api, @ljharb/eslint-config, aud, auto-changelog, es-value-fixtures, eslint, evalmd, for-each, functions-have-names, in-publish, npmignore, nyc, object-inspect, safe-publish-latest, tape

Documentation

A README file for the object.groupby code repository. View Code

object.groupby Version Badge

github actions coverage License Downloads

npm badge

An ESnext spec-compliant Object.groupBy 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.

Getting started

npm install --save object.groupby

Usage/Examples

var groupBy = require('object.groupby');
var assert = require('assert');

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

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

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

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

assert.equal(shimmed, Object.groupBy);
assert.deepEqual(Object.groupBy(arr, parity), groupBy(arr, parity));

Tests

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