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