-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate to
@mrhenry/polyfill-library
(#1772)
* migrate to mrhenry/polyfill-library * upgrade to polyfill-library 5.0.0
- Loading branch information
1 parent
6630007
commit fada6c7
Showing
54 changed files
with
482 additions
and
316 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@mrhenry/babel-plugin-core-web", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "browser feature polyfills as a babel plugin", | ||
"main": "lib/index.js", | ||
"author": "Simon Menke <[email protected]>", | ||
|
@@ -33,7 +33,7 @@ | |
"dependencies": { | ||
"@babel/helper-module-imports": "^7.15.4", | ||
"@babel/types": "^7.23.5", | ||
"@mrhenry/core-web": "^1.2.1", | ||
"@mrhenry/core-web": "^1.2.2", | ||
"fast-deep-equal": "^3.1.3" | ||
}, | ||
"bugs": { | ||
|
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.
Large diffs are not rendered by default.
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
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
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
declare module 'polyfill-library'; | ||
declare module 'polyfill-library/lib/sources.js'; | ||
declare module '@mrhenry/polyfill-library'; | ||
declare module '@mrhenry/polyfill-library/lib/sources.js'; |
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
Large diffs are not rendered by default.
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
32 changes: 32 additions & 0 deletions
32
packages/core-web/helpers/_ESAbstract.AddValueToKeyedGroup.js
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,32 @@ | ||
import SameValue from "@mrhenry/core-web/helpers/_ESAbstract.SameValue"; | ||
import SameValueNonNumber from "@mrhenry/core-web/helpers/_ESAbstract.SameValueNonNumber"; | ||
import Type from "@mrhenry/core-web/helpers/_ESAbstract.Type"; | ||
|
||
// _ESAbstract.AddValueToKeyedGroup | ||
/* global SameValue */ | ||
|
||
// 7.3.35 AddValueToKeyedGroup ( groups, key, value ) | ||
// eslint-disable-next-line no-unused-vars | ||
function AddValueToKeyedGroup(groups, key, value) { | ||
// 1. For each Record { [[Key]], [[Elements]] } g of groups, do | ||
for (var i = 0; i < groups.length; i++) { | ||
var g = groups[i]; | ||
// a. If SameValue(g.[[Key]], key) is true, then | ||
if (SameValue(g["[[Key]]"], key)) { | ||
// i. Assert: Exactly one element of groups meets this criterion. | ||
// ii. Append value to g.[[Elements]]. | ||
g["[[Elements]]"].push(value); | ||
// iii. Return unused. | ||
return; | ||
} | ||
} | ||
// 2. Let group be the Record { [[Key]]: key, [[Elements]]: « value » }. | ||
var group = { | ||
"[[Key]]": key, | ||
"[[Elements]]": [value] | ||
}; | ||
// 3. Append group to groups. | ||
groups.push(group); | ||
// 4. Return unused. | ||
} | ||
export default AddValueToKeyedGroup; |
18 changes: 9 additions & 9 deletions
18
packages/core-web/helpers/_ESAbstract.AdvanceStringIndex.js
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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import CodePointAt from "@mrhenry/core-web/helpers/_ESAbstract.CodePointAt"; | ||
import UTF16SurrogatePairToCodePoint from "@mrhenry/core-web/helpers/_ESAbstract.UTF16SurrogatePairToCodePoint"; | ||
|
||
// _ESAbstract.AdvanceStringIndex | ||
/* global */ | ||
/* global CodePointAt */ | ||
|
||
// 22.2.5.2.3 AdvanceStringIndex ( S, index, unicode ) | ||
function AdvanceStringIndex(S, index, unicode) { // eslint-disable-line no-unused-vars | ||
// eslint-disable-next-line no-unused-vars | ||
function AdvanceStringIndex(S, index, unicode) { | ||
// 1. Assert: index ≤ 253 - 1. | ||
if (index > Number.MAX_SAFE_INTEGER) { | ||
throw new TypeError('Assertion failed: `index` must be <= 2**53'); | ||
} | ||
// 2. If unicode is false, return index + 1. | ||
if (unicode === false) { | ||
return index + 1; | ||
} | ||
// 3. Let length be the number of code units in S. | ||
// 3. Let length be the length of S. | ||
var length = S.length; | ||
// 4. If index + 1 ≥ length, return index + 1. | ||
if (index + 1 >= length) { | ||
return index + 1; | ||
} | ||
// 5. Let cp be ! CodePointAt(S, index). | ||
var cp = S.codePointAt(index); | ||
// 5. Let cp be CodePointAt(S, index). | ||
var cp = CodePointAt(S, index); | ||
// 6. Return index + cp.[[CodeUnitCount]]. | ||
return index + cp.length; | ||
return index + cp["[[CodeUnitCount]]"]; | ||
} | ||
export default AdvanceStringIndex; |
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
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,60 @@ | ||
import UTF16SurrogatePairToCodePoint from "@mrhenry/core-web/helpers/_ESAbstract.UTF16SurrogatePairToCodePoint"; | ||
|
||
// _ESAbstract.CodePointAt | ||
/* global UTF16SurrogatePairToCodePoint */ | ||
// 11.1.4 Static Semantics: CodePointAt ( string, position ) | ||
// eslint-disable-next-line no-unused-vars | ||
function CodePointAt(string, position) { | ||
// 1. Let size be the length of string. | ||
var size = string.length; | ||
// 2. Assert: position ≥ 0 and position < size. | ||
// 3. Let first be the code unit at index position within string. | ||
var first = String.prototype.charCodeAt.call(string, position); | ||
// 4. Let cp be the code point whose numeric value is the numeric value of first. | ||
var cp = first; | ||
|
||
var firstIsLeading = first >= 0xd800 && first <= 0xdbff; | ||
var firstIsTrailing = first >= 0xdc00 && first <= 0xdfff; | ||
|
||
// 5. If first is neither a leading surrogate nor a trailing surrogate, then | ||
if (!firstIsLeading && !firstIsTrailing) { | ||
// a. Return the Record { [[CodePoint]]: cp, [[CodeUnitCount]]: 1, [[IsUnpairedSurrogate]]: false }. | ||
return { | ||
"[[CodePoint]]": cp, | ||
"[[CodeUnitCount]]": 1, | ||
"[[IsUnpairedSurrogate]]": false | ||
}; | ||
} | ||
// 6. If first is a trailing surrogate or position + 1 = size, then | ||
if (firstIsTrailing || position + 1 === size) { | ||
// a. Return the Record { [[CodePoint]]: cp, [[CodeUnitCount]]: 1, [[IsUnpairedSurrogate]]: true }. | ||
return { | ||
"[[CodePoint]]": cp, | ||
"[[CodeUnitCount]]": 1, | ||
"[[IsUnpairedSurrogate]]": true | ||
}; | ||
} | ||
// 7. Let second be the code unit at index position + 1 within string. | ||
var second = String.prototype.charCodeAt.call(string, position + 1); | ||
|
||
var secondIsTrailing = second >= 0xdc00 && second <= 0xdfff; | ||
|
||
// 8. If second is not a trailing surrogate, then | ||
if (!secondIsTrailing) { | ||
// a. Return the Record { [[CodePoint]]: cp, [[CodeUnitCount]]: 1, [[IsUnpairedSurrogate]]: true }. | ||
return { | ||
"[[CodePoint]]": cp, | ||
"[[CodeUnitCount]]": 1, | ||
"[[IsUnpairedSurrogate]]": true | ||
}; | ||
} | ||
// 9. Set cp to UTF16SurrogatePairToCodePoint(first, second). | ||
cp = UTF16SurrogatePairToCodePoint(first, second); | ||
// 10. Return the Record { [[CodePoint]]: cp, [[CodeUnitCount]]: 2, [[IsUnpairedSurrogate]]: false }. | ||
return { | ||
"[[CodePoint]]": cp, | ||
"[[CodeUnitCount]]": 2, | ||
"[[IsUnpairedSurrogate]]": false | ||
}; | ||
} | ||
export default CodePointAt; |
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
2 changes: 2 additions & 0 deletions
2
packages/core-web/helpers/_ESAbstract.CreateRegExpStringIterator.js
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
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,92 @@ | ||
import AddValueToKeyedGroup from "@mrhenry/core-web/helpers/_ESAbstract.AddValueToKeyedGroup"; | ||
import SameValue from "@mrhenry/core-web/helpers/_ESAbstract.SameValue"; | ||
import SameValueNonNumber from "@mrhenry/core-web/helpers/_ESAbstract.SameValueNonNumber"; | ||
import Type from "@mrhenry/core-web/helpers/_ESAbstract.Type"; | ||
import Call from "@mrhenry/core-web/helpers/_ESAbstract.Call"; | ||
import GetIterator from "@mrhenry/core-web/helpers/_ESAbstract.GetIterator"; | ||
import GetMethod from "@mrhenry/core-web/helpers/_ESAbstract.GetMethod"; | ||
import GetV from "@mrhenry/core-web/helpers/_ESAbstract.GetV"; | ||
import ToObject from "@mrhenry/core-web/helpers/_ESAbstract.ToObject"; | ||
import IsCallable from "@mrhenry/core-web/helpers/_ESAbstract.IsCallable"; | ||
import IteratorClose from "@mrhenry/core-web/helpers/_ESAbstract.IteratorClose"; | ||
import IteratorStep from "@mrhenry/core-web/helpers/_ESAbstract.IteratorStep"; | ||
import IteratorNext from "@mrhenry/core-web/helpers/_ESAbstract.IteratorNext"; | ||
import IteratorComplete from "@mrhenry/core-web/helpers/_ESAbstract.IteratorComplete"; | ||
import ToBoolean from "@mrhenry/core-web/helpers/_ESAbstract.ToBoolean"; | ||
import Get from "@mrhenry/core-web/helpers/_ESAbstract.Get"; | ||
import IteratorValue from "@mrhenry/core-web/helpers/_ESAbstract.IteratorValue"; | ||
import RequireObjectCoercible from "@mrhenry/core-web/helpers/_ESAbstract.RequireObjectCoercible"; | ||
import ToPropertyKey from "@mrhenry/core-web/helpers/_ESAbstract.ToPropertyKey"; | ||
import ToPrimitive from "@mrhenry/core-web/helpers/_ESAbstract.ToPrimitive"; | ||
import OrdinaryToPrimitive from "@mrhenry/core-web/helpers/_ESAbstract.OrdinaryToPrimitive"; | ||
import ToString from "@mrhenry/core-web/helpers/_ESAbstract.ToString"; | ||
|
||
// _ESAbstract.GroupBy | ||
/* global AddValueToKeyedGroup, Call, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, RequireObjectCoercible, ToPropertyKey */ | ||
|
||
// 7.3.36 GroupBy ( items, callbackfn, keyCoercion ) | ||
// eslint-disable-next-line no-unused-vars | ||
function GroupBy(items, callbackfn, keyCoercion) { | ||
// 1. Perform ? RequireObjectCoercible(items). | ||
RequireObjectCoercible(items); | ||
// 2. If IsCallable(callbackfn) is false, throw a TypeError exception. | ||
if (IsCallable(callbackfn) === false) { | ||
throw new TypeError("callbackfn is not callable."); | ||
} | ||
// 3. Let groups be a new empty List. | ||
var groups = []; | ||
// 4. Let iteratorRecord be ? GetIterator(items, sync). | ||
var iteratorRecord = GetIterator(items); | ||
// 5. Let k be 0. | ||
var k = 0; | ||
// 6. Repeat, | ||
// eslint-disable-next-line no-constant-condition | ||
while (true) { | ||
// a. If k ≥ 253 - 1, then | ||
if (k >= Number.MAX_SAFE_INTEGER) { | ||
// i. Let error be ThrowCompletion(a newly created TypeError object). | ||
var error = new TypeError("k greater than or equal to MAX_SAFE_INTEGER"); | ||
// ii. Return ? IteratorClose(iteratorRecord, error). | ||
return IteratorClose(iteratorRecord, error); | ||
} | ||
// b. Let next be ? IteratorStep(iteratorRecord). | ||
var next = IteratorStep(iteratorRecord); | ||
// c. If next is false, then | ||
if (next === false) { | ||
// i. Return groups. | ||
return groups; | ||
} | ||
// d. Let value be ? IteratorValue(next). | ||
var value = IteratorValue(next); | ||
// e. Let key be Completion(Call(callbackfn, undefined, « value, 𝔽(k) »)). | ||
var key; | ||
try { | ||
key = Call(callbackfn, undefined, [value, k]); | ||
} catch (err) { | ||
// f. IfAbruptCloseIterator(key, iteratorRecord). | ||
return IteratorClose(iteratorRecord, err); | ||
} | ||
// g. If keyCoercion is property, then | ||
if (keyCoercion === "property") { | ||
// i. Set key to Completion(ToPropertyKey(key)). | ||
try { | ||
key = ToPropertyKey(key); | ||
} catch (err) { | ||
// ii. IfAbruptCloseIterator(key, iteratorRecord). | ||
return IteratorClose(iteratorRecord, err); | ||
} | ||
} | ||
// h. Else, | ||
else { | ||
// i. Assert: keyCoercion is zero. | ||
// ii. If key is -0𝔽, set key to +0𝔽. | ||
// eslint-disable-next-line no-compare-neg-zero | ||
if (key === -0) key = 0; | ||
} | ||
// i. Perform AddValueToKeyedGroup(groups, key, value). | ||
AddValueToKeyedGroup(groups, key, value); | ||
// j. Set k to k + 1. | ||
k = k + 1; | ||
} | ||
} | ||
export default GroupBy; |
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
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
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
Oops, something went wrong.