|
88 | 88 |
|
89 | 89 | var ArrayInstanceForEach = platform.builtInArray_prototype_forEach; |
90 | 90 | var ArrayInstanceIndexOf = platform.builtInArray_prototype_indexOf; |
91 | | - var ArrayInstancePush = platform.builtInJavascriptArrayEntryPush; |
92 | 91 | var ArrayInstanceJoin = platform.builtInJavascriptArrayEntryJoin; |
93 | 92 |
|
94 | 93 | var FunctionInstanceBind = platform.builtInJavascriptFunctionEntryBind; |
|
113 | 112 | repeat(str, count) { return callInstanceFunc(platform.builtInJavascriptStringEntryRepeat, str, count); }, |
114 | 113 |
|
115 | 114 | forEach(array, func) { return callInstanceFunc(ArrayInstanceForEach, array, func); }, |
116 | | - push(array, ...els) { return callInstanceFunc(ArrayInstancePush, array, ...els); }, |
117 | 115 | join(array, sep) { return callInstanceFunc(ArrayInstanceJoin, array, sep); }, |
118 | 116 | arrayIndexOf(array, el, from) { return callInstanceFunc(ArrayInstanceIndexOf, array, el, from); }, |
119 | 117 | map(array, func) { return callInstanceFunc(platform.builtInJavascriptArrayEntryMap, array, func); }, |
|
697 | 695 | const seen = []; |
698 | 696 | const O = typeof locales === "string" ? [locales] : Internal.ToObject(locales); |
699 | 697 | const len = Internal.ToLength(O.length); |
700 | | - let k = 0; |
| 698 | + let k = 0, i = 0;; |
701 | 699 |
|
702 | 700 | while (k < len) { |
703 | 701 | const Pk = Internal.ToString(k); |
|
717 | 715 | // See comment in platform.normalizeLanguageTag about when this happens |
718 | 716 | platform.raiseLocaleNotWellFormed(tag); |
719 | 717 | } else if (_.arrayIndexOf(seen, canonicalizedTag) === -1) { |
720 | | - _.push(seen, canonicalizedTag); |
| 718 | + _.defineProperty(seen, i++, {value: canonicalizedTag, enumerable: true, configurable: true, writable: true}); |
721 | 719 | } |
722 | 720 | } |
723 | 721 |
|
|
737 | 735 | */ |
738 | 736 | const LookupSupportedLocales = function (isAvailableLocale, requestedLocales) { |
739 | 737 | const subset = []; |
| 738 | + let i = 0; |
740 | 739 | _.forEach(requestedLocales, function (locale) { |
741 | 740 | const noExtensionsLocale = parseLangtag(locale).base; |
742 | 741 | if (BestAvailableLocale(isAvailableLocale, noExtensionsLocale) !== undefined) { |
743 | | - _.push(subset, locale); |
| 742 | + _.defineProperty(subset, i++, {value: locale, enumerable: true, configurable: true, writable: true}); |
744 | 743 | } |
745 | 744 | }); |
746 | 745 |
|
|
2206 | 2205 |
|
2207 | 2206 | if (extensionFilter !== undefined) { // Filter to expected sub-tags |
2208 | 2207 | var filtered = []; |
| 2208 | + let i = 0; |
2209 | 2209 | callInstanceFunc(ArrayInstanceForEach, subTags, (function (subTag) { |
2210 | 2210 | var parts = platform.builtInRegexMatch(subTag, /([^-]*)-?(.*)?/); // [0] entire thing; [1] key; [2] value |
2211 | 2211 | var key = parts[1]; |
2212 | 2212 | if (callInstanceFunc(ArrayInstanceIndexOf, extensionFilter, key) !== -1) { |
2213 | | - callInstanceFunc(ArrayInstancePush, filtered, subTag); |
| 2213 | + _.defineProperty(filtered, i++, {value: subTag, enumerable: true, configurable: true, writable: true}); |
2214 | 2214 | } |
2215 | 2215 | })); |
2216 | 2216 | subTags = filtered; |
|
2463 | 2463 |
|
2464 | 2464 | // TODO: Use sets here to prevent duplicates |
2465 | 2465 | let seen = []; |
| 2466 | + let i = 0; |
2466 | 2467 |
|
2467 | 2468 | forEachIfPresent(locales, length, function (locale) { |
2468 | 2469 | if ((typeof locale !== 'string' && typeof locale !== 'object') || locale === null) { |
|
2478 | 2479 | tag = platform.normalizeLanguageTag(tag); |
2479 | 2480 |
|
2480 | 2481 | if (tag !== undefined && callInstanceFunc(ArrayInstanceIndexOf, seen, tag) === -1) { |
2481 | | - callInstanceFunc(ArrayInstancePush, seen, tag); |
| 2482 | + _.defineProperty(seen, i++, {value: tag, writable: true, enumerable: true, configurable: true}); |
2482 | 2483 | } |
2483 | 2484 | }); |
2484 | 2485 |
|
|
3227 | 3228 | // Currently you cannot format date pieces and time pieces together, so this builds up a format template for each separately. |
3228 | 3229 | function EcmaOptionsToWindowsTemplate(options) { |
3229 | 3230 | var template = []; |
| 3231 | + template.__proto__ = null; |
| 3232 | + let i = 0; |
3230 | 3233 |
|
3231 | 3234 | if (options.weekday) { |
3232 | 3235 | if (options.weekday === 'narrow' || options.weekday === 'short') { |
3233 | | - callInstanceFunc(ArrayInstancePush, template, 'dayofweek.abbreviated'); |
| 3236 | + template[i++] = 'dayofweek.abbreviated'; |
3234 | 3237 | } else if (options.weekday === 'long') { |
3235 | | - callInstanceFunc(ArrayInstancePush, template, 'dayofweek.full'); |
| 3238 | + template[i++] = 'dayofweek.full'; |
3236 | 3239 | } |
3237 | 3240 | } |
3238 | 3241 |
|
3239 | 3242 | // TODO: Era not supported |
3240 | 3243 | if (options.year) { |
3241 | 3244 | if (options.year === '2-digit') { |
3242 | | - callInstanceFunc(ArrayInstancePush, template, 'year.abbreviated'); |
| 3245 | + template[i++] = 'year.abbreviated'; |
3243 | 3246 | } else if (options.year === 'numeric') { |
3244 | | - callInstanceFunc(ArrayInstancePush, template, 'year.full'); |
| 3247 | + template[i++] = 'year.full'; |
3245 | 3248 | } |
3246 | 3249 | } |
3247 | 3250 |
|
3248 | 3251 | if (options.month) { |
3249 | 3252 | if (options.month === '2-digit' || options.month === 'numeric') { |
3250 | | - callInstanceFunc(ArrayInstancePush, template, 'month.numeric') |
| 3253 | + template[i++] = 'month.numeric'; |
3251 | 3254 | } else if (options.month === 'short' || options.month === 'narrow') { |
3252 | | - callInstanceFunc(ArrayInstancePush, template, 'month.abbreviated'); |
| 3255 | + template[i++] = 'month.abbreviated'; |
3253 | 3256 | } else if (options.month === 'long') { |
3254 | | - callInstanceFunc(ArrayInstancePush, template, 'month.full'); |
| 3257 | + template[i++] = 'month.full'; |
3255 | 3258 | } |
3256 | 3259 | } |
3257 | 3260 |
|
3258 | 3261 | if (options.day) { |
3259 | | - callInstanceFunc(ArrayInstancePush, template, 'day'); |
| 3262 | + template[i++] = 'day'; |
3260 | 3263 | } |
3261 | 3264 |
|
3262 | 3265 | if (options.timeZoneName) { |
3263 | 3266 | if (options.timeZoneName === "short") { |
3264 | | - callInstanceFunc(ArrayInstancePush, template, 'timezone.abbreviated'); |
| 3267 | + template[i++] = 'timezone.abbreviated'; |
3265 | 3268 | } else if (options.timeZoneName === "long") { |
3266 | | - callInstanceFunc(ArrayInstancePush, template, 'timezone.full'); |
| 3269 | + template[i++] = 'timezone.full'; |
3267 | 3270 | } |
3268 | 3271 | } |
3269 | 3272 |
|
3270 | 3273 | callInstanceFunc(ArrayInstanceForEach, ['hour', 'minute', 'second'], function (opt) { |
3271 | 3274 | if (options[opt]) { |
3272 | | - callInstanceFunc(ArrayInstancePush, template, opt); |
| 3275 | + template[i++] = opt; |
3273 | 3276 | } |
3274 | 3277 | }); |
3275 | 3278 |
|
3276 | 3279 | // TODO: Timezone Name not supported. |
3277 | | - return getArrayLength(template) > 0 ? callInstanceFunc(ArrayInstanceJoin, template, ' ') : undefined; |
| 3280 | + return i > 0 ? callInstanceFunc(ArrayInstanceJoin, template, ' ') : undefined; |
3278 | 3281 | } |
3279 | 3282 |
|
3280 | 3283 | var WindowsToEcmaCalendarMap = { |
|
0 commit comments