|
8 | 8 | (function (intrinsic) {
|
9 | 9 | var platform = intrinsic.JsBuiltIn;
|
10 | 10 |
|
11 |
| - let FunctionsEnum = { |
12 |
| - ArrayValues: { className: "Array", methodName: "values", argumentsCount: 0, forceInline: true /*optional*/, alias: "Symbol.iterator" }, |
13 |
| - ArrayKeys: { className: "Array", methodName: "keys", argumentsCount: 0, forceInline: true /*optional*/ }, |
14 |
| - ArrayEntries: { className: "Array", methodName: "entries", argumentsCount: 0, forceInline: true /*optional*/ }, |
15 |
| - ArrayIndexOf: { className: "Array", methodName: "indexOf", argumentsCount: 1, forceInline: true /*optional*/ }, |
16 |
| - ArrayFilter: { className: "Array", methodName: "filter", argumentsCount: 1, forceInline: true /*optional*/ }, |
17 |
| - ArrayFlat: { className: "Array", methodName: "flat", argumentsCount: 0, forceInline: true /*optional*/ }, |
18 |
| - ArrayFlatMap: { className: "Array", methodName: "flatMap", argumentsCount: 1, forceInline: true /*optional*/ }, |
19 |
| - ArrayForEach: { className: "Array", methodName: "forEach", argumentsCount: 1, forceInline: true /*optional*/ }, |
20 |
| - ObjectFromEntries: { className: "Object", staticMethod: true, methodName: "fromEntries", argumentsCount: 1, forceInline: true /*optional*/ }, |
21 |
| - }; |
22 |
| - |
23 | 11 | var setPrototype = platform.builtInSetPrototype;
|
24 | 12 | var _objectDefineProperty = platform.builtInJavascriptObjectEntryDefineProperty;
|
25 | 13 | var Symbol = platform.Symbol;
|
26 | 14 | var CreateObject = platform.builtInJavascriptObjectEntryCreate;
|
27 | 15 |
|
28 | 16 | platform.registerChakraLibraryFunction("ArrayIterator", function (arrayObj, iterationKind) {
|
29 |
| - "use strict"; |
30 | 17 | __chakraLibrary.InitInternalProperties(this, 4, "__$arrayObj$__", "__$nextIndex$__", "__$kind$__", "__$internalDone$__");
|
31 | 18 | this.__$arrayObj$__ = arrayObj;
|
32 | 19 | this.__$nextIndex$__ = 0;
|
|
52 | 39 | // So, we need to set the prototype of attributes to null
|
53 | 40 | setPrototype({
|
54 | 41 | value: function () {
|
55 |
| - "use strict"; |
56 | 42 | let o = this;
|
57 | 43 |
|
58 | 44 | if (!(o instanceof __chakraLibrary.ArrayIterator)) {
|
|
100 | 86 | _objectDefineProperty(__chakraLibrary.ArrayIterator.prototype.next, 'name', setPrototype({ value: "next", writable: false, enumerable: false, configurable: true }, null));
|
101 | 87 |
|
102 | 88 | platform.registerChakraLibraryFunction("CreateArrayIterator", function (arrayObj, iterationKind) {
|
103 |
| - "use strict"; |
104 | 89 | return new __chakraLibrary.ArrayIterator(arrayObj, iterationKind);
|
105 | 90 | });
|
106 | 91 |
|
107 |
| - platform.registerFunction(FunctionsEnum.ArrayKeys, function () { |
108 |
| - "use strict"; |
| 92 | + platform.registerFunction(platform.FunctionKind.Array_keys, function () { |
109 | 93 | if (this === null || this === undefined) {
|
110 | 94 | __chakraLibrary.raiseThis_NullOrUndefined("Array.prototype.keys");
|
111 | 95 | }
|
112 | 96 | let o = __chakraLibrary.Object(this);
|
113 | 97 | return __chakraLibrary.CreateArrayIterator(o, 0 /* ArrayIterationKind.Key*/);
|
114 | 98 | });
|
115 | 99 |
|
116 |
| - platform.registerFunction(FunctionsEnum.ArrayValues, function () { |
117 |
| - "use strict"; |
| 100 | + platform.registerFunction(platform.FunctionKind.Array_values, function () { |
118 | 101 | if (this === null || this === undefined) {
|
119 | 102 | __chakraLibrary.raiseThis_NullOrUndefined("Array.prototype.values");
|
120 | 103 | }
|
121 | 104 | let o = __chakraLibrary.Object(this);
|
122 | 105 | return __chakraLibrary.CreateArrayIterator(o, 1 /* ArrayIterationKind.Value*/);
|
123 | 106 | });
|
124 | 107 |
|
125 |
| - platform.registerFunction(FunctionsEnum.ArrayEntries, function () { |
126 |
| - "use strict"; |
| 108 | + platform.registerFunction(platform.FunctionKind.Array_entries, function () { |
127 | 109 | if (this === null || this === undefined) {
|
128 | 110 | __chakraLibrary.raiseThis_NullOrUndefined("Array.prototype.entries");
|
129 | 111 | }
|
130 | 112 | let o = __chakraLibrary.Object(this);
|
131 | 113 | return __chakraLibrary.CreateArrayIterator(o, 2 /* ArrayIterationKind.KeyAndValue*/);
|
132 | 114 | });
|
133 | 115 |
|
134 |
| - platform.registerFunction(FunctionsEnum.ArrayIndexOf, function (searchElement, fromIndex) { |
| 116 | + platform.registerFunction(platform.FunctionKind.Array_indexOf, function (searchElement, fromIndex = undefined) { |
135 | 117 | // ECMAScript 2017 #sec-array.prototype.indexof
|
136 |
| - "use strict"; |
137 | 118 |
|
138 | 119 | if (this === null || this === undefined) {
|
139 | 120 | __chakraLibrary.raiseThis_NullOrUndefined("Array.prototype.indexOf");
|
|
190 | 171 | });
|
191 | 172 |
|
192 | 173 | platform.registerChakraLibraryFunction("CheckArrayAndGetLen", function (obj, builtInFunc) {
|
193 |
| - "use strict"; |
194 |
| - |
195 | 174 | if (__chakraLibrary.isArray(obj)) {
|
196 | 175 | return { o: obj, len: obj.length };
|
197 | 176 | } else {
|
|
202 | 181 | }
|
203 | 182 | });
|
204 | 183 |
|
205 |
| - platform.registerFunction(FunctionsEnum.ArrayFilter, function (callbackfn, thisArg) { |
| 184 | + platform.registerFunction(platform.FunctionKind.Array_filter, function (callbackfn, thisArg = undefined) { |
206 | 185 | // ECMAScript 2017 #sec-array.prototype.filter
|
207 |
| - "use strict"; |
208 | 186 |
|
209 | 187 | let objInfo = __chakraLibrary.CheckArrayAndGetLen(this, "Array.prototype.filter");
|
210 | 188 | let o = objInfo.o;
|
|
236 | 214 | {
|
237 | 215 | // this is FlattenIntoArray from the flat/flatMap proposal BUT with no mapperFunction
|
238 | 216 | // a seperate function has been made to handle the case where there is a mapperFunction
|
239 |
| - "use strict"; |
| 217 | + |
240 | 218 | //1. Let targetIndex be start.
|
241 | 219 | let targetIndex = start;
|
242 | 220 | //2. Let sourceIndex be 0.
|
|
279 | 257 | });
|
280 | 258 |
|
281 | 259 | platform.registerChakraLibraryFunction("FlattenIntoArrayMapped", function(target, source, sourceLen, start, mapperFunction, thisArg) {
|
282 |
| - "use strict"; |
283 | 260 | // this is FlattenIntoArray from the flat/flatMap proposal BUT with:
|
284 | 261 | // depth = 1 and the presence of a mapperFunction guaranteed
|
285 | 262 | // both these conditions are always met when this is called from flatMap
|
|
344 | 321 | return targetIndex;
|
345 | 322 | });
|
346 | 323 |
|
347 |
| - platform.registerFunction(FunctionsEnum.ArrayFlat, function (depth) { |
348 |
| - "use strict"; |
| 324 | + platform.registerFunction(platform.FunctionKind.Array_flat, function (depth = undefined) { |
349 | 325 | //1. Let O be ? ToObject(this value).
|
350 | 326 | //2. Let sourceLen be ? ToLength(? Get(O, "length")).
|
351 | 327 | let objInfo = __chakraLibrary.CheckArrayAndGetLen(this, "Array.prototype.flat");
|
|
363 | 339 | return A;
|
364 | 340 | });
|
365 | 341 |
|
366 |
| - platform.registerFunction(FunctionsEnum.ArrayFlatMap, function (mapperFunction, thisArg) { |
367 |
| - "use strict"; |
| 342 | + platform.registerFunction(platform.FunctionKind.Array_flatMap, function (mapperFunction, thisArg = undefined) { |
368 | 343 | //1. Let O be ? ToObject(this value).
|
369 | 344 | //2. Let sourceLen be ? ToLength(? Get(O, "length")).
|
370 | 345 |
|
|
385 | 360 | return A;
|
386 | 361 | });
|
387 | 362 |
|
388 |
| - platform.registerFunction(FunctionsEnum.ArrayForEach, function (callbackfn, thisArg) { |
| 363 | + platform.registerFunction(platform.FunctionKind.Array_forEach, function (callbackfn, thisArg = undefined) { |
389 | 364 | // ECMAScript 2017 #sec-array.prototype.foreach
|
390 |
| - "use strict"; |
391 | 365 |
|
392 | 366 | let objInfo = __chakraLibrary.CheckArrayAndGetLen(this, "Array.prototype.forEach");
|
393 | 367 | let o = objInfo.o;
|
|
410 | 384 | return undefined;
|
411 | 385 | });
|
412 | 386 |
|
413 |
| - platform.registerFunction(FunctionsEnum.ObjectFromEntries, function (iterable) { |
| 387 | + platform.registerFunction(platform.FunctionKind.Object_fromEntries, function (iterable) { |
414 | 388 | // #sec-object.fromentries
|
415 |
| - "use strict"; |
416 | 389 | if (iterable === null || iterable === undefined) {
|
417 | 390 | __chakraLibrary.raiseNeedObject("Object.fromEntries");
|
418 | 391 | }
|
|
0 commit comments