Sha256: 7620febe6c77d4fca48921ab91567a767bab27bd4e0a924899470429620e8da0

Contents?: true

Size: 899 Bytes

Versions: 26

Compression:

Stored size: 899 Bytes

Contents

'use strict';

var callBound = require('call-bind/callBound');
var GetIntrinsic = require('get-intrinsic');
var SameValue = require('es-abstract/2023/SameValue');

var $TypeError = GetIntrinsic('%TypeError%');

var $filter = callBound('Array.prototype.filter');
var $push = callBound('Array.prototype.push');

module.exports = function AddValueToKeyedGroup(groups, key, value) {
	var found = $filter(groups, function (group) {
		return SameValue(group['[[Key]]'], key); // eslint-disable-line new-cap
	});
	if (found.length > 0) {
		var g = found[0];
		if (found.length !== 1) {
			throw new $TypeError('Assertion failed: more than 1 Record inside `groups` has a `[[Key]]` that is SameValue to `key`');
		}
		$push(g['[[Elements]]'], value); // step 1.a.ii
	} else {
		var group = { '[[Key]]': key, '[[Elements]]': [value] }; // eslint-disable-line sort-keys
		$push(groups, group); // step 3
	}
};

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
immosquare-cleaner-0.1.32 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.31 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.30 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.29 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.28 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.27 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.26 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.25 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.24 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.23 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.22 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.21 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.20 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.19 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.18 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.17 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.16 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.14 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.13 node_modules/object.groupby/aos/AddValueToKeyedGroup.js
immosquare-cleaner-0.1.12 node_modules/object.groupby/aos/AddValueToKeyedGroup.js