forked from ljharb/es-abstract
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added: - AddValueToKeyedGroup - ArrayBufferByteLength - ArrayBufferCopyAndDetach - GetArrayBufferMaxByteLengthOption - GetIteratorFromMethod - GetViewByteLength - GroupBy - HasEitherUnicodeFlag - IsArrayBufferViewOutOfBounds - IsFixedLengthArrayBuffer - IsTypedArrayOutOfBounds - IsViewOutOfBounds - IteratorStepValue - MakeDataViewWithBufferWitnessRecord - MakeFullYear - MakeTypedArrayWithBufferWitnessRecord - MaybeSimpleCaseFolding - StringPaddingBuiltinsImpl - SystemTimeZoneIdentifier - TypedArrayByteLength - TypedArrayCreate (see "changed/removed") - TypedArrayGetElement - TypedArrayLength - TypedArraySetElement - ValidateAtomicAccessOnIntegerTypedArray - Changed/Removed: - `this*` AOs renamed to `This*`, or removed - `CreateMethodProperty` is removed; see `DefineMethodProperty` - `DefaultTimeZone` -> `SystemTimeZoneIdentifier` - `GetSubstitution`: fixed to match web reality - `ObjectDefineProperties` - `ToIndex`: remove unnecessary `ToLength` - `ToUint8Clamp`: refactor implementation - `StringPad` -> `StringPaddingBuiltinsImpl`; `StringPad` now requires a String fillString - `TypedArrayCreate` -> `TypedArrayCreateFromConstructor` - `ValidateAtomicAccess`: now takes a "Typed Array With Buffer Witness Record" - `ValidateTypedArray`: now requires `order`, and returns a "Typed Array With Buffer Witness Record" Also, all spec enums are now in all caps.
- Loading branch information
Showing
292 changed files
with
13,119 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
|
||
var $TypeError = require('es-errors/type'); | ||
|
||
var callBound = require('call-bind/callBound'); | ||
|
||
var $push = callBound('Array.prototype.push'); | ||
|
||
var SameValue = require('./SameValue'); | ||
|
||
var IsArray = require('../helpers/IsArray'); | ||
var every = require('../helpers/every'); | ||
var forEach = require('../helpers/forEach'); | ||
|
||
var hasOwn = require('hasown'); | ||
|
||
var isKeyedGroup = function (group) { | ||
return hasOwn(group, '[[Keys]]') | ||
&& hasOwn(group, '[[Elements]]') | ||
&& IsArray(group['[[Elements]]']); | ||
}; | ||
|
||
// https://tc39.es/ecma262/#sec-add-value-to-keyed-group | ||
|
||
module.exports = function AddValueToKeyedGroup(groups, key, value) { | ||
if (!IsArray(groups) || !every(groups, isKeyedGroup)) { | ||
throw new $TypeError('Assertion failed: `groups` must be a List of Records with [[Key]] and [[Elements]]'); | ||
} | ||
|
||
var matched = 0; | ||
forEach(groups, function (g) { // step 1 | ||
if (SameValue(g['[[Key]]'], key)) { // step 2 | ||
matched += 1; | ||
if (matched > 1) { | ||
throw new $TypeError('Assertion failed: Exactly one element of groups meets this criterion'); // step 2.a | ||
} | ||
|
||
$push(g['[[Elements]]'], value); // step 2.b | ||
} | ||
}); | ||
|
||
var group = { '[[Key]]': key, '[[Elements]]': [value] }; // step 2 | ||
|
||
$push(groups, group); // step 3 | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.