jscrewit 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/jscrewit.js CHANGED
@@ -1,4 +1,4 @@
1
- // JScrewIt 3.0.0 – https://jscrew.it
1
+ // JScrewIt 3.3.0 – https://jscrew.it
2
2
 
3
3
  (function () {
4
4
  'use strict';
@@ -61,7 +61,7 @@
61
61
  function esToString$1(arg)
62
62
  {
63
63
  if (typeof arg === 'symbol')
64
- throw new _TypeError$1('Cannot convert a symbol to a string');
64
+ throw _TypeError$1('Cannot convert a symbol to a string');
65
65
  var str = _String$1(arg);
66
66
  return str;
67
67
  }
@@ -576,13 +576,13 @@
576
576
  }
577
577
  function validateMask(mask) {
578
578
  if (!isMaskCompatible(mask))
579
- throw new _Error('Incompatible features');
579
+ throw _Error('Incompatible features');
580
580
  }
581
581
  var utilInspect;
582
582
  try {
583
- /* eslint-disable @typescript-eslint/no-require-imports, n/prefer-node-protocol */
584
- utilInspect = require('util').inspect;
585
- /* eslint-enable @typescript-eslint/no-require-imports, n/prefer-node-protocol */
583
+ /* eslint-disable @typescript-eslint/no-require-imports */
584
+ utilInspect = require('node:util').inspect;
585
+ /* eslint-enable @typescript-eslint/no-require-imports */
586
586
  }
587
587
  catch (_a) { }
588
588
  {
@@ -828,7 +828,7 @@
828
828
  var createMap = function () { return _Object_create(null); };
829
829
  function esToString(name) {
830
830
  if (typeof name === 'symbol')
831
- throw new _TypeError('Cannot convert a symbol to a string');
831
+ throw _TypeError('Cannot convert a symbol to a string');
832
832
  var str = _String(name);
833
833
  return str;
834
834
  }
@@ -865,7 +865,7 @@
865
865
  return str;
866
866
  }
867
867
  function throwUnknownFeatureError(name) {
868
- throw new _Error("Unknown feature ".concat(_JSON_stringify(name)));
868
+ throw _Error("Unknown feature ".concat(_JSON_stringify(name)));
869
869
  }
870
870
  function wrapCheck(check) {
871
871
  var wrappedCheck = function () { return !!check(); };
@@ -1191,6 +1191,46 @@
1191
1191
  return available;
1192
1192
  },
1193
1193
  },
1194
+ LOCALE_NUMERALS_IE11_WIN7:
1195
+ {
1196
+ description:
1197
+ 'Localized number formatting exclusive to Internet Explorer 11 on Windows 7.',
1198
+ check:
1199
+ function ()
1200
+ {
1201
+ var available =
1202
+ checkLocaleNumeral('lv', Infinity, /^......ī/) &&
1203
+ checkLocaleNumeral('ru', Infinity, /^беск.н.ч.о.ть/);
1204
+ return available;
1205
+ },
1206
+ excludes: ['RUSSIAN_INFINITY'],
1207
+ },
1208
+ LOCALE_NUMERALS_IE11_WIN7_8:
1209
+ {
1210
+ description:
1211
+ 'Localized number formatting exclusive to Internet Explorer 11 on Windows 7 and 8.',
1212
+ check:
1213
+ function ()
1214
+ {
1215
+ var available =
1216
+ checkLocaleNumeral('ar', NaN, /^ليس.برقم/) &&
1217
+ checkLocaleNumeral('ar', Infinity, /^..ا.نه..ة/) &&
1218
+ checkLocaleNumeral('cs', NaN, /^.....č/) &&
1219
+ checkLocaleNumeral('el', Infinity, /^Άπε..ο/) &&
1220
+ checkLocaleNumeral('el', NaN, /^μη.αριθ.ός/) &&
1221
+ checkLocaleNumeral('he', NaN, /^לא.מספר/) &&
1222
+ checkLocaleNumeral('he', Infinity, /^.ינ.וף.ח..ב/) &&
1223
+ checkLocaleNumeral('he', -Infinity, /^.......ש/) &&
1224
+ checkLocaleNumeral('ja', Infinity, /^.∞/) &&
1225
+ checkLocaleNumeral('ja', NaN, /^.....非数値/) &&
1226
+ checkLocaleNumeral('lt', Infinity, /^.......ė/) &&
1227
+ checkLocaleNumeral('pl', Infinity, /^.......ń.....ść/) &&
1228
+ checkLocaleNumeral('pl', NaN, /^..............ą/) &&
1229
+ checkLocaleNumeral('zh', Infinity, /^正/) &&
1230
+ checkLocaleNumeral('zh-cn', NaN, /^..字/);
1231
+ return available;
1232
+ },
1233
+ },
1194
1234
  NAME:
1195
1235
  {
1196
1236
  description: 'Existence of the name property for functions.',
@@ -1290,13 +1330,14 @@
1290
1330
  },
1291
1331
  RUSSIAN_INFINITY:
1292
1332
  {
1293
- description: 'Russian string representation of Infinity as "∞".',
1333
+ description: 'Russian string representation of Infinity as "∞".',
1294
1334
  check:
1295
1335
  function ()
1296
1336
  {
1297
1337
  var available = Infinity.toLocaleString('ru') === '∞';
1298
1338
  return available;
1299
1339
  },
1340
+ excludes: ['LOCALE_NUMERALS_IE11_WIN7'],
1300
1341
  },
1301
1342
  SELF:
1302
1343
  {
@@ -1529,13 +1570,22 @@
1529
1570
  ],
1530
1571
  attributes: { 'char-increment-restriction': null, 'web-worker-restriction': null },
1531
1572
  },
1573
+ IE_11_WIN_7:
1574
+ {
1575
+ inherits: 'IE_11',
1576
+ versions: ['11'],
1577
+ compatibilityTag: 'on Windows 7',
1578
+ compatibilityShortTag: 'W7',
1579
+ includes:
1580
+ { LOCALE_NUMERALS_IE11_WIN7: true, LOCALE_NUMERALS_IE11_WIN7_8: true },
1581
+ },
1532
1582
  IE_11_WIN_8:
1533
1583
  {
1534
1584
  inherits: 'IE_11',
1535
1585
  versions: ['11'],
1536
1586
  compatibilityTag: 'on Windows 8',
1537
1587
  compatibilityShortTag: 'W8',
1538
- includes: { RUSSIAN_INFINITY: true },
1588
+ includes: { LOCALE_NUMERALS_IE11_WIN7_8: true, RUSSIAN_INFINITY: true },
1539
1589
  },
1540
1590
  IE_11_WIN_10:
1541
1591
  {
@@ -2583,6 +2633,8 @@
2583
2633
  var LOCALE_INFINITY = Feature.LOCALE_INFINITY;
2584
2634
  var LOCALE_NUMERALS_BN = Feature.LOCALE_NUMERALS_BN;
2585
2635
  var LOCALE_NUMERALS_EXT = Feature.LOCALE_NUMERALS_EXT;
2636
+ var LOCALE_NUMERALS_IE11_WIN7 = Feature.LOCALE_NUMERALS_IE11_WIN7;
2637
+ var LOCALE_NUMERALS_IE11_WIN7_8 = Feature.LOCALE_NUMERALS_IE11_WIN7_8;
2586
2638
  var NAME = Feature.NAME;
2587
2639
  var NO_FF_SRC = Feature.NO_FF_SRC;
2588
2640
  var NO_IE_SRC = Feature.NO_IE_SRC;
@@ -2598,15 +2650,15 @@
2598
2650
  var V8_SRC = Feature.V8_SRC;
2599
2651
  var WINDOW = Feature.WINDOW;
2600
2652
 
2601
- function charDefaultDefinition(char)
2653
+ function charCommonDefinition(char)
2602
2654
  {
2603
- var solution = this._defaultResolveCharacter(char);
2655
+ var solution = this._commonResolveCharacter(char);
2604
2656
  return solution;
2605
2657
  }
2606
2658
 
2607
- function defineCharDefault()
2659
+ function defineCharCommon()
2608
2660
  {
2609
- var entry = define(charDefaultDefinition);
2661
+ var entry = define(charCommonDefinition);
2610
2662
  return entry;
2611
2663
  }
2612
2664
 
@@ -2691,15 +2743,17 @@
2691
2743
  var expr = '(' + number + ')[TO_LOCALE_STRING](' + locale + ')';
2692
2744
  if (index != null)
2693
2745
  {
2694
- if (index > 4)
2746
+ if (index % 10 === 8)
2747
+ expr = '(' + R_PADDINGS[3] + ' + ' + expr + ')[' + (index - index % 10 + 11) + ']';
2748
+ else if (index % 10 > 4)
2695
2749
  {
2696
- var paddingBlock = R_PADDINGS[10 - index];
2697
- expr = '(' + paddingBlock + ' + ' + expr + ')[10]';
2750
+ var paddingBlock = R_PADDINGS[10 - index % 10];
2751
+ expr = '(' + paddingBlock + ' + ' + expr + ')[' + (index - index % 10 + 10) + ']';
2698
2752
  }
2699
2753
  else
2700
2754
  expr += '[' + index + ']';
2701
2755
  }
2702
- var entry = define._callWithFeatures(expr, arguments, 3);
2756
+ var entry = define._callWithFeatures({ expr: expr, optimize: true }, arguments, 3);
2703
2757
  return entry;
2704
2758
  }
2705
2759
 
@@ -2727,11 +2781,12 @@
2727
2781
 
2728
2782
  function useLocaleNumeralDefinition(char, locale, number, index)
2729
2783
  {
2730
- CHARACTERS[char] =
2731
- [
2732
- defineLocalizedNumeral._callWithFeatures(locale, number, index, arguments, 4),
2733
- defineCharDefault(),
2734
- ];
2784
+ var entries = CHARACTERS[char];
2785
+ var entry = defineLocalizedNumeral._callWithFeatures(locale, number, index, arguments, 4);
2786
+ if (entries)
2787
+ entries.splice(entries.length - 1, 0, entry);
2788
+ else
2789
+ CHARACTERS[char] = [entry, defineCharCommon()];
2735
2790
  }
2736
2791
 
2737
2792
  function useLocaleNumeralDigitDefinitions(locale, zeroCharCode)
@@ -2901,10 +2956,7 @@
2901
2956
  [
2902
2957
  define('"".fontcolor()[12]'),
2903
2958
  ],
2904
- '#':
2905
- [
2906
- defineCharDefault(),
2907
- ],
2959
+ // '#'
2908
2960
  // '$'
2909
2961
  '%':
2910
2962
  [
@@ -2912,12 +2964,12 @@
2912
2964
  define('escape(0 + AT)[20]', AT),
2913
2965
  define('escape(FLAT)[21]', FLAT),
2914
2966
  define('escape(ANY_FUNCTION)[0]', IE_SRC),
2915
- defineCharDefault(),
2967
+ defineCharCommon(),
2916
2968
  ],
2917
2969
  '&':
2918
2970
  [
2919
2971
  define('"".fontcolor("".fontcolor([]))[31]', ESC_HTML_QUOT),
2920
- defineCharDefault(),
2972
+ defineCharCommon(),
2921
2973
  ],
2922
2974
  // '\''
2923
2975
  '(':
@@ -2933,7 +2985,7 @@
2933
2985
  ',':
2934
2986
  [
2935
2987
  define('(RP_0_S + F_A_L_S_E)[1]'),
2936
- define({ expr: '[[]].concat([[]])', solutionType: SolutionType.OBJECT }),
2988
+ define({ expr: '[[]][CONCAT]([[]])', solutionType: SolutionType.OBJECT }),
2937
2989
  ],
2938
2990
  '-': '(.0000001 + [])[2]',
2939
2991
  '.': '(11e20 + [])[1]',
@@ -2965,7 +3017,7 @@
2965
3017
  '?':
2966
3018
  [
2967
3019
  define('(RP_0_S + RegExp())[2]'),
2968
- defineCharDefault(),
3020
+ defineCharCommon(),
2969
3021
  ],
2970
3022
  // '@'
2971
3023
  'A':
@@ -2984,7 +3036,7 @@
2984
3036
  define('escape(F_A_L_S_E)[11]'),
2985
3037
  define('(RP_4_A + "".fontcolor())[10]', CAPITAL_HTML),
2986
3038
  define('(RP_3_WA + Function("return console")())[11]', CONSOLE),
2987
- defineCharDefault(),
3039
+ defineCharCommon(),
2988
3040
  ],
2989
3041
  'D':
2990
3042
  [
@@ -3002,6 +3054,7 @@
3002
3054
  'E':
3003
3055
  [
3004
3056
  define('btoa("0NaN")[1]'),
3057
+ define('escape(RP_4_A + "".italics())[10]'),
3005
3058
  define('(RP_5_A + "".link())[10]', CAPITAL_HTML),
3006
3059
  ],
3007
3060
  'F':
@@ -3028,7 +3081,7 @@
3028
3081
  'K':
3029
3082
  [
3030
3083
  define('(RP_5_A + "".strike())[10]', CAPITAL_HTML),
3031
- defineCharDefault(),
3084
+ defineCharCommon(),
3032
3085
  ],
3033
3086
  'L':
3034
3087
  [
@@ -3054,7 +3107,7 @@
3054
3107
  define('btoa("".italics())[0]'),
3055
3108
  define('(RP_0_S + Function("return statusbar")())[11]', BARPROP),
3056
3109
  define('"0".sup()[10]', CAPITAL_HTML),
3057
- defineCharDefault(),
3110
+ defineCharCommon(),
3058
3111
  ],
3059
3112
  'Q':
3060
3113
  [
@@ -3153,7 +3206,7 @@
3153
3206
  'k':
3154
3207
  [
3155
3208
  define('20[TO_STRING]("21")'),
3156
- defineCharDefault(),
3209
+ defineCharCommon(),
3157
3210
  ],
3158
3211
  'l': '"false"[2]',
3159
3212
  'm':
@@ -3177,7 +3230,7 @@
3177
3230
  [
3178
3231
  define('212[TO_STRING]("31")[1]'),
3179
3232
  define('"".fontcolor(true + "".fontcolor())[30]', ESC_HTML_QUOT),
3180
- defineCharDefault(),
3233
+ defineCharCommon(),
3181
3234
  ],
3182
3235
  'r': '"true"[1]',
3183
3236
  's': '"false"[3]',
@@ -3301,8 +3354,9 @@
3301
3354
  define('Infinity[TO_LOCALE_STRING]("ja")[SLICE_OR_SUBSTR]("-1")'),
3302
3355
  define('Infinity[TO_LOCALE_STRING]("ja").at("-1")', AT),
3303
3356
  define('Infinity[TO_LOCALE_STRING]()', LOCALE_INFINITY),
3357
+ define('Infinity[TO_LOCALE_STRING]("ja")[1]', LOCALE_NUMERALS_IE11_WIN7_8),
3304
3358
  define('Infinity[TO_LOCALE_STRING]("ru")', RUSSIAN_INFINITY),
3305
- defineCharDefault(),
3359
+ defineCharCommon(),
3306
3360
  ],
3307
3361
  });
3308
3362
 
@@ -3314,7 +3368,7 @@
3314
3368
  RegExp: define({ expr: 'RegExp.name', optimize: { complexOpt: false } }, NAME),
3315
3369
  String: define('String.name', NAME),
3316
3370
  fromCharCo:
3317
- define({ expr: '"from3har3o".split(3).join("C")', optimize: { complexOpt: false } }),
3371
+ define({ expr: '"from3har3o"[SPLIT](3)[JOIN]("C")', optimize: { complexOpt: false } }),
3318
3372
  mCh: define('atob("bUNo")'),
3319
3373
  });
3320
3374
 
@@ -3404,10 +3458,11 @@
3404
3458
  [
3405
3459
  define('[].at', AT),
3406
3460
  ],
3407
- FILTER:
3461
+ CONCAT:
3408
3462
  [
3409
- define('[].filter'),
3463
+ define({ expr: '"concat"', solutionType: SolutionType.COMBINED_STRING }),
3410
3464
  ],
3465
+ FILTER: '[].filter',
3411
3466
  FLAT:
3412
3467
  [
3413
3468
  define('[].flat', FLAT),
@@ -3416,11 +3471,24 @@
3416
3471
  [
3417
3472
  define('[][SLICE_OR_FLAT].call("false")'),
3418
3473
  ],
3474
+ JOIN:
3475
+ [
3476
+ define({ expr: '"join"', solutionType: SolutionType.COMBINED_STRING }),
3477
+ ],
3419
3478
  LOCALE_AR:
3420
3479
  [
3421
3480
  define({ expr: '"ar-td"', solutionType: SolutionType.COMBINED_STRING }),
3422
3481
  define({ expr: '"ar"', solutionType: SolutionType.COMBINED_STRING }, SHORT_LOCALES),
3423
3482
  ],
3483
+ LOCALE_HE:
3484
+ [
3485
+ define({ expr: '"He"', solutionType: SolutionType.COMBINED_STRING }),
3486
+ define({ expr: '"he"', solutionType: SolutionType.COMBINED_STRING }),
3487
+ ],
3488
+ MAP:
3489
+ [
3490
+ define({ expr: '"map"', optimize: true, solutionType: SolutionType.COMBINED_STRING }),
3491
+ ],
3424
3492
  PLAIN_OBJECT:
3425
3493
  [
3426
3494
  define('Function("return{}")()'),
@@ -3439,6 +3507,10 @@
3439
3507
  define({ expr: '"slice"', solutionType: SolutionType.COMBINED_STRING }),
3440
3508
  define({ expr: '"substr"', solutionType: SolutionType.COMBINED_STRING }),
3441
3509
  ],
3510
+ SPLIT:
3511
+ [
3512
+ define({ expr: '"split"', optimize: true, solutionType: SolutionType.COMBINED_STRING }),
3513
+ ],
3442
3514
  TO_LOCALE_STRING:
3443
3515
  [
3444
3516
  define
@@ -3664,102 +3736,106 @@
3664
3736
 
3665
3737
  FH_R_PADDING_SHIFTS = [define(1, IE_SRC), define(0, NO_IE_SRC)];
3666
3738
 
3667
- var FORMAT_MAPPER_ENTRIES =
3668
- [
3669
- define
3670
- (
3671
- (function () {
3672
- var formatMapper =
3673
- function (accessor)
3674
- {
3675
- var mapper =
3676
- 'Function("return function(falsefalse){return function(undefined){return ' +
3677
- 'falsefalse' + accessor + '}}")()';
3678
- return mapper;
3679
- };
3680
- formatMapper.argName = 'undefined';
3681
- return formatMapper;
3682
- })()
3683
- ),
3684
- define
3685
- (
3686
- (function () {
3687
- var formatMapper =
3688
- function (accessor)
3689
- {
3690
- var mapper =
3691
- 'Function("return function(undefined){return this' + accessor + '}")().bind';
3692
- return mapper;
3693
- };
3694
- formatMapper.argName = 'undefined';
3695
- return formatMapper;
3696
- })()
3697
- ),
3698
- define
3699
- (
3700
- (function () {
3701
- var formatMapper =
3702
- function (accessor)
3703
- {
3704
- var mapper =
3705
- 'Function("return function(f){return this' + accessor + '}")().bind';
3706
- return mapper;
3707
- };
3708
- formatMapper.argName = 'f';
3709
- return formatMapper;
3710
- })()
3711
- ),
3712
- define
3713
- (
3714
- (function () {
3715
- var formatMapper =
3716
- function (accessor)
3717
- {
3718
- var mapper =
3719
- 'Function("return falsefalse=>undefined=>falsefalse' + accessor + '")()';
3720
- return mapper;
3721
- };
3722
- formatMapper.argName = 'undefined';
3723
- return formatMapper;
3724
- })(),
3725
- ARROW
3726
- ),
3727
- ];
3728
-
3729
3739
  FORMAT_MAPPER_LONG =
3730
3740
  defineList
3731
3741
  (
3732
- FORMAT_MAPPER_ENTRIES,
3742
+ [
3743
+ define
3744
+ (
3745
+ (function () {
3746
+ var formatMapper =
3747
+ function (accessor)
3748
+ {
3749
+ var mapper =
3750
+ 'Function("return function(falsefalse){return function(undefined){return ' +
3751
+ 'falsefalse' + accessor + '}}")()';
3752
+ return mapper;
3753
+ };
3754
+ formatMapper.argName = 'undefined';
3755
+ return formatMapper;
3756
+ })()
3757
+ ),
3758
+ define
3759
+ (
3760
+ (function () {
3761
+ var formatMapper =
3762
+ function (accessor)
3763
+ {
3764
+ var mapper =
3765
+ 'Function("return function(f){return this' + accessor + '}")().bind';
3766
+ return mapper;
3767
+ };
3768
+ formatMapper.argName = 'f';
3769
+ return formatMapper;
3770
+ })()
3771
+ ),
3772
+ define
3773
+ (
3774
+ (function () {
3775
+ var formatMapper =
3776
+ function (accessor)
3777
+ {
3778
+ var mapper =
3779
+ 'Function("return falsefalse=>undefined=>falsefalse' + accessor + '")()';
3780
+ return mapper;
3781
+ };
3782
+ formatMapper.argName = 'undefined';
3783
+ return formatMapper;
3784
+ })(),
3785
+ ARROW
3786
+ ),
3787
+ ],
3733
3788
  [
3734
3789
  define(0),
3735
- define(2, ARRAY_ITERATOR),
3790
+ define(1, ARRAY_ITERATOR),
3736
3791
  define(0, NO_FF_SRC),
3737
3792
  define(0, NO_V8_SRC),
3738
- define(2, ARRAY_ITERATOR, CAPITAL_HTML),
3793
+ define(1, ARRAY_ITERATOR, CAPITAL_HTML),
3739
3794
  define(0, ARRAY_ITERATOR, AT),
3740
3795
  define(0, ARRAY_ITERATOR, FLAT),
3741
3796
  define(0, ARRAY_ITERATOR, NO_IE_SRC),
3742
3797
  define(0, ARRAY_ITERATOR, CAPITAL_HTML, IE_SRC),
3743
- define(3),
3798
+ define(2),
3744
3799
  ]
3745
3800
  );
3746
3801
 
3747
3802
  FORMAT_MAPPER_SHORT =
3748
3803
  defineList
3749
3804
  (
3750
- FORMAT_MAPPER_ENTRIES,
3751
3805
  [
3752
- define(0),
3753
- define(1, ARRAY_ITERATOR),
3754
- define(0, NO_FF_SRC),
3755
- define(0, NO_V8_SRC),
3756
- define(1, ARRAY_ITERATOR, CAPITAL_HTML),
3757
- define(0, ARRAY_ITERATOR, AT),
3758
- define(0, ARRAY_ITERATOR, FLAT),
3759
- define(0, ARRAY_ITERATOR, NO_IE_SRC),
3760
- define(0, ARRAY_ITERATOR, CAPITAL_HTML, IE_SRC),
3761
- define(3),
3762
- ]
3806
+ define
3807
+ (
3808
+ (function () {
3809
+ var formatMapper =
3810
+ function (accessor)
3811
+ {
3812
+ var mapper =
3813
+ 'Function("return function(undefined){return function(falsefalse){return ' +
3814
+ 'undefined[1][undefined[0]' + accessor + ']}}")()';
3815
+ return mapper;
3816
+ };
3817
+ formatMapper.argName = 'falsefalse';
3818
+ return formatMapper;
3819
+ })()
3820
+ ),
3821
+ define
3822
+ (
3823
+ (function () {
3824
+ var formatMapper =
3825
+ function (accessor)
3826
+ {
3827
+ var mapper =
3828
+ 'Function("return undefined=>falsefalse=>undefined[1][undefined[0]' +
3829
+ accessor + ']")()';
3830
+ return mapper;
3831
+ };
3832
+ formatMapper.argName = 'falsefalse';
3833
+ return formatMapper;
3834
+ })(),
3835
+ ARROW
3836
+ ),
3837
+ ],
3838
+ [define(0), define(1)]
3763
3839
  );
3764
3840
 
3765
3841
  FROM_CHAR_CODE =
@@ -3938,15 +4014,58 @@
3938
4014
  useLocaleNumeralDefinition('ي', '"ar"', NaN, 1);
3939
4015
  useLocaleNumeralDefinition('س', '"ar"', NaN, 2);
3940
4016
  useLocaleNumeralDefinition('ر', '"ar"', NaN, 4, LOCALE_NUMERALS_EXT);
4017
+ useLocaleNumeralDefinition('ب', '"ar"', NaN, 4, LOCALE_NUMERALS_IE11_WIN7_8);
3941
4018
  useLocaleNumeralDefinition('ق', '"ar"', NaN, 5, LOCALE_NUMERALS_EXT);
4019
+ useLocaleNumeralDefinition('ر', '"ar"', NaN, 5, LOCALE_NUMERALS_IE11_WIN7_8);
3942
4020
  useLocaleNumeralDefinition('م', '"ar"', NaN, 6, LOCALE_NUMERALS_EXT);
4021
+ useLocaleNumeralDefinition('ق', '"ar"', NaN, 6, LOCALE_NUMERALS_IE11_WIN7_8);
4022
+ useLocaleNumeralDefinition('م', '"ar"', NaN, 7, LOCALE_NUMERALS_IE11_WIN7_8);
4023
+ useLocaleNumeralDefinition('ا', '"ar"', Infinity, 2, LOCALE_NUMERALS_IE11_WIN7_8);
4024
+ useLocaleNumeralDefinition('ن', '"ar"', Infinity, 4, LOCALE_NUMERALS_IE11_WIN7_8);
4025
+ useLocaleNumeralDefinition('ه', '"ar"', Infinity, 5, LOCALE_NUMERALS_IE11_WIN7_8);
4026
+ useLocaleNumeralDefinition('ة', '"ar"', Infinity, 8, LOCALE_NUMERALS_IE11_WIN7_8);
3943
4027
  useLocaleNumeralDigitDefinitions('"bn"', 0x09e6, LOCALE_NUMERALS_BN);
4028
+ useLocaleNumeralDefinition('č', '"cs"', NaN, 5, LOCALE_NUMERALS_IE11_WIN7_8);
4029
+ useLocaleNumeralDefinition('μ', '"el"', NaN, 0, LOCALE_NUMERALS_IE11_WIN7_8);
4030
+ useLocaleNumeralDefinition('η', '"el"', NaN, 1, LOCALE_NUMERALS_IE11_WIN7_8);
4031
+ useLocaleNumeralDefinition('α', '"el"', NaN, 3, LOCALE_NUMERALS_IE11_WIN7_8);
4032
+ useLocaleNumeralDefinition('ρ', '"el"', NaN, 4, LOCALE_NUMERALS_IE11_WIN7_8);
4033
+ useLocaleNumeralDefinition('ι', '"el"', NaN, 5, LOCALE_NUMERALS_IE11_WIN7_8);
4034
+ useLocaleNumeralDefinition('θ', '"el"', NaN, 6, LOCALE_NUMERALS_IE11_WIN7_8);
4035
+ useLocaleNumeralDefinition('ό', '"el"', NaN, 8, LOCALE_NUMERALS_IE11_WIN7_8);
4036
+ useLocaleNumeralDefinition('ς', '"el"', NaN, 9, LOCALE_NUMERALS_IE11_WIN7_8);
4037
+ useLocaleNumeralDefinition('Ά', '"el"', Infinity, 0, LOCALE_NUMERALS_IE11_WIN7_8);
4038
+ useLocaleNumeralDefinition('π', '"el"', Infinity, 1, LOCALE_NUMERALS_IE11_WIN7_8);
4039
+ useLocaleNumeralDefinition('ε', '"el"', Infinity, 2, LOCALE_NUMERALS_IE11_WIN7_8);
4040
+ useLocaleNumeralDefinition('ο', '"el"', Infinity, 5, LOCALE_NUMERALS_IE11_WIN7_8);
3944
4041
  useLocaleNumeralDigitDefinitions('"fa"', 0x06f0);
3945
4042
  useLocaleNumeralDefinition('٬', '"fa"', 1000, 1);
3946
4043
  useLocaleNumeralDefinition('ن', '"fa"', NaN, 0, LOCALE_NUMERALS_EXT);
3947
4044
  useLocaleNumeralDefinition('ا', '"fa"', NaN, 1, LOCALE_NUMERALS_EXT);
3948
4045
  useLocaleNumeralDefinition('ع', '"fa"', NaN, 2, LOCALE_NUMERALS_EXT);
3949
4046
  useLocaleNumeralDefinition('د', '"fa"', NaN, 3, LOCALE_NUMERALS_EXT);
4047
+ useLocaleNumeralDefinition('ש', 'LOCALE_HE', -Infinity, 7, LOCALE_NUMERALS_IE11_WIN7_8);
4048
+ useLocaleNumeralDefinition('י', 'LOCALE_HE', Infinity, 1, LOCALE_NUMERALS_IE11_WIN7_8);
4049
+ useLocaleNumeralDefinition('נ', 'LOCALE_HE', Infinity, 2, LOCALE_NUMERALS_IE11_WIN7_8);
4050
+ useLocaleNumeralDefinition('ו', 'LOCALE_HE', Infinity, 4, LOCALE_NUMERALS_IE11_WIN7_8);
4051
+ useLocaleNumeralDefinition('ף', 'LOCALE_HE', Infinity, 5, LOCALE_NUMERALS_IE11_WIN7_8);
4052
+ useLocaleNumeralDefinition('ח', 'LOCALE_HE', Infinity, 7, LOCALE_NUMERALS_IE11_WIN7_8);
4053
+ useLocaleNumeralDefinition('ב', 'LOCALE_HE', Infinity, 10, LOCALE_NUMERALS_IE11_WIN7_8);
4054
+ useLocaleNumeralDefinition('ל', 'LOCALE_HE', NaN, 0, LOCALE_NUMERALS_IE11_WIN7_8);
4055
+ useLocaleNumeralDefinition('א', 'LOCALE_HE', NaN, 1, LOCALE_NUMERALS_IE11_WIN7_8);
4056
+ useLocaleNumeralDefinition('מ', 'LOCALE_HE', NaN, 3, LOCALE_NUMERALS_IE11_WIN7_8);
4057
+ useLocaleNumeralDefinition('ס', 'LOCALE_HE', NaN, 4, LOCALE_NUMERALS_IE11_WIN7_8);
4058
+ useLocaleNumeralDefinition('פ', 'LOCALE_HE', NaN, 5, LOCALE_NUMERALS_IE11_WIN7_8);
4059
+ useLocaleNumeralDefinition('ר', 'LOCALE_HE', NaN, 6, LOCALE_NUMERALS_IE11_WIN7_8);
4060
+ useLocaleNumeralDefinition('非', '"ja"', NaN, 5, LOCALE_NUMERALS_IE11_WIN7_8);
4061
+ useLocaleNumeralDefinition('数', '"ja"', NaN, 6, LOCALE_NUMERALS_IE11_WIN7_8);
4062
+ useLocaleNumeralDefinition('値', '"ja"', NaN, 7, LOCALE_NUMERALS_IE11_WIN7_8);
4063
+ useLocaleNumeralDefinition('ė', '"lt"', Infinity, 7, LOCALE_NUMERALS_IE11_WIN7_8);
4064
+ useLocaleNumeralDefinition('ī', '"lv"', Infinity, 6, LOCALE_NUMERALS_IE11_WIN7);
4065
+ useLocaleNumeralDefinition('ń', '"pl"', Infinity, 7, LOCALE_NUMERALS_IE11_WIN7_8);
4066
+ useLocaleNumeralDefinition('ś', '"pl"', Infinity, 13, LOCALE_NUMERALS_IE11_WIN7_8);
4067
+ useLocaleNumeralDefinition('ć', '"pl"', Infinity, 14, LOCALE_NUMERALS_IE11_WIN7_8);
4068
+ useLocaleNumeralDefinition('ą', '"pl"', NaN, 14, LOCALE_NUMERALS_IE11_WIN7_8);
3950
4069
  useLocaleNumeralDefinition('н', '"ru"', NaN, 0, LOCALE_NUMERALS_EXT);
3951
4070
  useLocaleNumeralDefinition('е', '"ru"', NaN, 1, LOCALE_NUMERALS_EXT);
3952
4071
  useLocaleNumeralDefinition('ч', '"ru"', NaN, 3, LOCALE_NUMERALS_EXT);
@@ -3954,6 +4073,17 @@
3954
4073
  useLocaleNumeralDefinition('с', '"ru"', NaN, 5, LOCALE_NUMERALS_EXT);
3955
4074
  useLocaleNumeralDefinition('л', '"ru"', NaN, 6, LOCALE_NUMERALS_EXT);
3956
4075
  useLocaleNumeralDefinition('о', '"ru"', NaN, 7, LOCALE_NUMERALS_EXT);
4076
+ useLocaleNumeralDefinition('б', '"ru"', Infinity, 0, LOCALE_NUMERALS_IE11_WIN7);
4077
+ useLocaleNumeralDefinition('е', '"ru"', Infinity, 1, LOCALE_NUMERALS_IE11_WIN7);
4078
+ useLocaleNumeralDefinition('с', '"ru"', Infinity, 2, LOCALE_NUMERALS_IE11_WIN7);
4079
+ useLocaleNumeralDefinition('к', '"ru"', Infinity, 3, LOCALE_NUMERALS_IE11_WIN7);
4080
+ useLocaleNumeralDefinition('н', '"ru"', Infinity, 5, LOCALE_NUMERALS_IE11_WIN7);
4081
+ useLocaleNumeralDefinition('ч', '"ru"', Infinity, 7, LOCALE_NUMERALS_IE11_WIN7);
4082
+ useLocaleNumeralDefinition('о', '"ru"', Infinity, 9, LOCALE_NUMERALS_IE11_WIN7);
4083
+ useLocaleNumeralDefinition('т', '"ru"', Infinity, 11, LOCALE_NUMERALS_IE11_WIN7);
4084
+ useLocaleNumeralDefinition('ь', '"ru"', Infinity, 12, LOCALE_NUMERALS_IE11_WIN7);
4085
+ useLocaleNumeralDefinition('正', '"zh"', Infinity, 0, LOCALE_NUMERALS_IE11_WIN7_8);
4086
+ useLocaleNumeralDefinition('字', '"zh-cn"', NaN, 2, LOCALE_NUMERALS_IE11_WIN7_8);
3957
4087
  }
3958
4088
  )();
3959
4089
 
@@ -4691,8 +4821,8 @@
4691
4821
  function getMantissa()
4692
4822
  {
4693
4823
  var lastDigitIndex = usefulDigits - 1;
4694
- var preMantissa = digits.slice(0, lastDigitIndex);
4695
- var lastDigit = +digits[lastDigitIndex];
4824
+ var preMantissa = digitsBeforeDot.slice(0, lastDigitIndex);
4825
+ var lastDigit = +digitsBeforeDot[lastDigitIndex];
4696
4826
  var value = evalNumber(preMantissa, lastDigit, exp);
4697
4827
  for (;;)
4698
4828
  {
@@ -4709,9 +4839,9 @@
4709
4839
  var str;
4710
4840
  var match = /^(\d+)(?:\.(\d+))?(?:e(.+))?$/.exec(number);
4711
4841
  var digitsAfterDot = match[2] || '';
4712
- var digits = (match[1] + digitsAfterDot).replace(/^0+/, '');
4713
- var usefulDigits = digits.search(/0*$/);
4714
- var exp = (match[3] | 0) - digitsAfterDot.length + digits.length - usefulDigits;
4842
+ var digitsBeforeDot = (match[1] + digitsAfterDot).replace(/^0+/, '');
4843
+ var usefulDigits = digitsBeforeDot.search(/0*$/);
4844
+ var exp = (match[3] | 0) - digitsAfterDot.length + digitsBeforeDot.length - usefulDigits;
4715
4845
  var mantissa = getMantissa();
4716
4846
  if (exp >= 0)
4717
4847
  {
@@ -4974,7 +5104,7 @@
4974
5104
  var chain = stack.slice(stackIndex);
4975
5105
  var feature = featureFromMask(encoder.mask);
4976
5106
  var message = 'Circular reference detected: ' + chain.join(' < ') + ' – ' + feature;
4977
- var error = new _SyntaxError(message);
5107
+ var error = _SyntaxError(message);
4978
5108
  assignNoEnum$1(error, { chain: chain, feature: feature });
4979
5109
  throw error;
4980
5110
  }
@@ -5193,7 +5323,7 @@
5193
5323
  var stackLength = stack.length;
5194
5324
  if (stackLength)
5195
5325
  message += ' in the definition of ' + stack[stackLength - 1];
5196
- throw new _SyntaxError(message);
5326
+ throw _SyntaxError(message);
5197
5327
  }
5198
5328
 
5199
5329
  var matchSimpleAt =
@@ -5234,7 +5364,18 @@
5234
5364
  (
5235
5365
  Encoder.prototype,
5236
5366
  {
5237
- _createCharDefaultSolution:
5367
+ _commonResolveCharacter:
5368
+ function (char)
5369
+ {
5370
+ var charCode = char.charCodeAt();
5371
+ var atobOpt = charCode < 0x100;
5372
+ var stdOpt = !atobOpt;
5373
+ var solution =
5374
+ this._createCharCommonSolution(char, charCode, atobOpt, stdOpt, stdOpt, stdOpt);
5375
+ return solution;
5376
+ },
5377
+
5378
+ _createCharCommonSolution:
5238
5379
  function (char, charCode, atobOpt, charCodeOpt, escSeqOpt, unescapeOpt)
5239
5380
  {
5240
5381
  var solution;
@@ -5268,17 +5409,6 @@
5268
5409
  return solution;
5269
5410
  },
5270
5411
 
5271
- _defaultResolveCharacter:
5272
- function (char)
5273
- {
5274
- var charCode = char.charCodeAt();
5275
- var atobOpt = charCode < 0x100;
5276
- var stdOpt = !atobOpt;
5277
- var solution =
5278
- this._createCharDefaultSolution(char, charCode, atobOpt, stdOpt, stdOpt, stdOpt);
5279
- return solution;
5280
- },
5281
-
5282
5412
  _getPaddingBlock:
5283
5413
  function (length)
5284
5414
  {
@@ -5288,6 +5418,8 @@
5288
5418
  throwSyntaxError(this, 'Undefined regular padding block with length ' + length);
5289
5419
  },
5290
5420
 
5421
+ _guardResolution: noop,
5422
+
5291
5423
  _replaceCharByAtob: replaceCharByAtob,
5292
5424
 
5293
5425
  _replaceCharByCharCode: replaceCharByCharCode,
@@ -5496,11 +5628,9 @@
5496
5628
  var firstSolution = options.firstSolution;
5497
5629
  var maxLength = options.maxLength;
5498
5630
  if (firstSolution)
5499
- {
5500
5631
  buffer.append(firstSolution);
5501
- if (buffer.length > maxLength)
5502
- return;
5503
- }
5632
+ if (buffer.length > maxLength)
5633
+ return;
5504
5634
  var length = str.length;
5505
5635
  for (var index = 0; index < length;)
5506
5636
  {
@@ -5563,19 +5693,21 @@
5563
5693
  var solution = charCache[char];
5564
5694
  if (solution === undefined)
5565
5695
  {
5696
+ var charName = _JSON_stringify$1(char);
5566
5697
  callResolver
5567
5698
  (
5568
5699
  this,
5569
- _JSON_stringify$1(char),
5700
+ charName,
5570
5701
  function ()
5571
5702
  {
5572
5703
  var entries = CHARACTERS[char];
5573
5704
  if (!entries || _Array_isArray$1(entries))
5574
5705
  {
5706
+ this._guardResolution(charName);
5575
5707
  if (entries)
5576
5708
  solution = findOptimalSolution(this, char, entries);
5577
5709
  if (!solution)
5578
- solution = this._defaultResolveCharacter(char);
5710
+ solution = this._commonResolveCharacter(char);
5579
5711
  }
5580
5712
  else
5581
5713
  {
@@ -5606,6 +5738,7 @@
5606
5738
  var entries = this.constantDefinitions[constant];
5607
5739
  if (_Array_isArray$1(entries))
5608
5740
  {
5741
+ this._guardResolution(constant);
5609
5742
  solution =
5610
5743
  findOptimalSolution(this, constant, entries, SolutionType.OBJECT);
5611
5744
  }
@@ -5624,6 +5757,12 @@
5624
5757
  }
5625
5758
  );
5626
5759
 
5760
+ STATIC_ENCODER._guardResolution =
5761
+ function (name)
5762
+ {
5763
+ throw _Error$1('Unable to resolve ' + name + ' statically');
5764
+ };
5765
+
5627
5766
  initStaticEncoder(STATIC_ENCODER);
5628
5767
 
5629
5768
  function createFigurator(startValues, joiner)
@@ -5747,6 +5886,49 @@
5747
5886
  return figurator;
5748
5887
  }
5749
5888
 
5889
+ function joinWithMaxLength(maxLength)
5890
+ {
5891
+ for (var index = arguments.length; ;)
5892
+ {
5893
+ if (maxLength < 0)
5894
+ return;
5895
+ if (--index < 1)
5896
+ break;
5897
+ var str = arguments[index];
5898
+ maxLength -= str.length;
5899
+ }
5900
+ var array = _Array_prototype_slice_call(arguments, 1);
5901
+ var result = array.join('');
5902
+ return result;
5903
+ }
5904
+
5905
+ // Length of the shortest possible concat head replacement "[]".
5906
+ var CONCAT_HEAD_MIN_LENGTH = 2;
5907
+
5908
+ // The overhead of "[" + "]" plus the minimum concat head replacement length.
5909
+ var CONCAT_HEAD_MIN_OVERHEAD = 2 + CONCAT_HEAD_MIN_LENGTH;
5910
+
5911
+ // Length of the shortest possible concat part replacements "+[] and "![]".
5912
+ var CONCAT_PART_MIN_LENGTH = 3;
5913
+
5914
+ // The overhead of "[" + "](" + ")" plus the minimum concat part replacement length.
5915
+ var CONCAT_PART_MIN_OVERHEAD = 4 + CONCAT_PART_MIN_LENGTH;
5916
+
5917
+ // Length of the shortest possible joiner replacement "[]".
5918
+ var JOINER_MIN_LENGTH = 2;
5919
+
5920
+ // The overhead of "[" + "](" + ")" plus the minimum joiner replacement length.
5921
+ var JOINING_MIN_OVERHEAD = 4 + JOINER_MIN_LENGTH;
5922
+
5923
+ // Length of the shortest possible separator replacement "[]".
5924
+ var SEPARATOR_MIN_LENGTH = 2;
5925
+
5926
+ // The overhead of "[" + "](" + ")" plus the minimum separator replacement length.
5927
+ var SEPARATION_MIN_OVERHEAD = 4 + SEPARATOR_MIN_LENGTH;
5928
+
5929
+ // Length of the shortest possible sequence replacement "([]+[])".
5930
+ var SEQUENCE_MIN_LENGTH = 7;
5931
+
5750
5932
  /**
5751
5933
  * An object that exposes properties used to split a string into an array of strings or to join
5752
5934
  * array elements into a string.
@@ -5762,6 +5944,81 @@
5762
5944
  * to join them into a single string.
5763
5945
  */
5764
5946
 
5947
+ function createConcatenationReplacement
5948
+ (encoder, array, allowZeroForEmptyElements, forceString, maxLength)
5949
+ {
5950
+ var concatReplacement = encoder.resolveConstant('CONCAT').replacement;
5951
+ var concatCount = array.length - 1;
5952
+ maxLength -=
5953
+ CONCAT_HEAD_MIN_OVERHEAD + concatCount * (concatReplacement.length + CONCAT_PART_MIN_OVERHEAD);
5954
+ if (maxLength < 0)
5955
+ return;
5956
+ var options = { screwMode: forceString ? SCREW_AS_STRING : SCREW_NORMAL };
5957
+ var replacements = [];
5958
+ for (var index = 0; index <= concatCount; ++index)
5959
+ {
5960
+ var element = array[index];
5961
+ var elementReplacement = undefinedAsString(replaceStaticString(element, options));
5962
+ var minLength = index ? CONCAT_PART_MIN_LENGTH : CONCAT_HEAD_MIN_LENGTH;
5963
+ if (index)
5964
+ {
5965
+ if (elementReplacement === '[]')
5966
+ elementReplacement = allowZeroForEmptyElements ? '+[]' : '[[]]';
5967
+ replacements.push('[', concatReplacement, '](', elementReplacement, ')');
5968
+ }
5969
+ else
5970
+ replacements.push('[', elementReplacement, ']');
5971
+ maxLength -= elementReplacement.length - minLength;
5972
+ if (maxLength < 0)
5973
+ return;
5974
+ }
5975
+ var concatenationReplacement = replacements.join('');
5976
+ return concatenationReplacement;
5977
+ }
5978
+
5979
+ function createSubstitutionsReplacement(encoder, substitutions, maxLength)
5980
+ {
5981
+ var substitutionCount = substitutions ? substitutions.length : 0;
5982
+ if (!substitutionCount)
5983
+ return '';
5984
+ var splitReplacement = encoder.resolveConstant('SPLIT').replacement;
5985
+ var joinReplacement = encoder.resolveConstant('JOIN').replacement;
5986
+ maxLength -=
5987
+ substitutionCount *
5988
+ (
5989
+ splitReplacement.length + SEPARATION_MIN_OVERHEAD +
5990
+ joinReplacement.length + JOINING_MIN_OVERHEAD
5991
+ );
5992
+ if (maxLength < 0)
5993
+ return;
5994
+ var replacements = [];
5995
+ for (var index = 0; index < substitutionCount; ++index)
5996
+ {
5997
+ var substitution = substitutions[index];
5998
+ var separatorReplacement = undefinedAsString(encoder.replaceExpr(substitution.separator));
5999
+ var joinerReplacement = undefinedAsString(encoder.replaceString(substitution.joiner));
6000
+ maxLength -=
6001
+ separatorReplacement.length - SEPARATOR_MIN_LENGTH +
6002
+ joinerReplacement.length - JOINER_MIN_LENGTH;
6003
+ if (maxLength < 0)
6004
+ return;
6005
+ replacements.push
6006
+ (
6007
+ '[',
6008
+ splitReplacement,
6009
+ '](',
6010
+ separatorReplacement,
6011
+ ')[',
6012
+ joinReplacement,
6013
+ '](',
6014
+ joinerReplacement,
6015
+ ')'
6016
+ );
6017
+ }
6018
+ var substitutionsReplacement = replacements.join('');
6019
+ return substitutionsReplacement;
6020
+ }
6021
+
5765
6022
  function replaceJoinedArrayString(array, joiner, maxLength)
5766
6023
  {
5767
6024
  var str = array.join(joiner);
@@ -5770,18 +6027,8 @@
5770
6027
  return replacement;
5771
6028
  }
5772
6029
 
5773
- function undefinedAsString(replacement)
5774
- {
5775
- if (replacement === '[][[]]')
5776
- replacement += '+[]';
5777
- return replacement;
5778
- }
5779
-
5780
6030
  /**
5781
- * Replaces a given array of strings with equivalent JSFuck code.
5782
- *
5783
- * Array elements may only contain characters with static definitions in their string
5784
- * representations.
6031
+ * Replaces a given array of statically replaceable strings with equivalent JSFuck code.
5785
6032
  *
5786
6033
  * @function Encoder#replaceStringArray
5787
6034
  *
@@ -5790,7 +6037,7 @@
5790
6037
  *
5791
6038
  * @param {Delimiter[]} insertions
5792
6039
  * An array of delimiters of which at most one will be used to compose a joined string and split it
5793
- * into an array of strings.
6040
+ * into an array of strings. Every joiner in the insertions must be a statically replaceable string.
5794
6041
  *
5795
6042
  * The encoder can pick an insertion and insert a joiner between any two adjacent elements to mark
5796
6043
  * the boundary between them. The separator is then used to split the concatenated string back into
@@ -5838,143 +6085,69 @@
5838
6085
  // applied.
5839
6086
  if (substitutions || count > 2)
5840
6087
  {
5841
- var preReplacement =
5842
- function ()
5843
- {
5844
- // Length of the shortest string replacement "([]+[])".
5845
- var STRING_REPLACEMENT_MIN_LENGTH = 7;
5846
-
5847
- // This is for the overhead of "[" + "](" + ")" plus the length of the shortest
5848
- // separator replacement "[]".
5849
- var SEPARATOR_MIN_OVERHEAD = 6;
5850
-
5851
- // This is for the overhead of "[" + "](" + ")" plus the length of the shortest
5852
- // joiner replacement "[]".
5853
- var JOINER_MIN_OVERHEAD = 6;
5854
-
5855
- var joinCount = substitutions ? substitutions.length : 0;
5856
- var splitCount = joinCount + 1;
5857
- var maxSplitReplacementLength =
5858
- (maxLength - STRING_REPLACEMENT_MIN_LENGTH) / splitCount - SEPARATOR_MIN_OVERHEAD;
5859
- var splitReplacement =
5860
- this.replaceString('split', { maxLength: maxSplitReplacementLength, optimize: true });
5861
- if (!splitReplacement)
5862
- return;
5863
- var preReplacement = '';
5864
- if (joinCount)
5865
- {
5866
- var maxJoinReplacementLength =
5867
- (
5868
- maxLength - STRING_REPLACEMENT_MIN_LENGTH -
5869
- splitCount * (splitReplacement.length + SEPARATOR_MIN_OVERHEAD)
5870
- ) /
5871
- joinCount -
5872
- JOINER_MIN_OVERHEAD;
5873
- var joinReplacement =
5874
- this.replaceString('join', { maxLength: maxJoinReplacementLength });
5875
- if (!joinReplacement)
5876
- return;
5877
- substitutions.forEach
5878
- (
5879
- function (substitution)
5880
- {
5881
- var separatorReplacement =
5882
- undefinedAsString(this.replaceExpr(substitution.separator));
5883
- var joinerReplacement =
5884
- undefinedAsString(this.replaceString(substitution.joiner));
5885
- preReplacement +=
5886
- '[' + splitReplacement + '](' + separatorReplacement + ')[' +
5887
- joinReplacement + '](' + joinerReplacement + ')';
5888
- },
5889
- this
5890
- );
5891
- }
5892
- preReplacement += '[' + splitReplacement + ']';
5893
- return preReplacement;
5894
- }
5895
- .call(this);
6088
+ var splitReplacement = this.resolveConstant('SPLIT').replacement;
6089
+ var minSubstitutionsReplacementLength =
6090
+ maxLength -
6091
+ SEQUENCE_MIN_LENGTH -
6092
+ splitReplacement.length -
6093
+ SEPARATION_MIN_OVERHEAD;
6094
+ var substitutionsReplacement =
6095
+ createSubstitutionsReplacement(this, substitutions, minSubstitutionsReplacementLength);
5896
6096
  }
5897
- if (!substitutions && count > 1)
5898
- {
5899
- var concatReplacement =
5900
- this.replaceString('concat', { maxLength: maxLength, optimize: true });
5901
- }
5902
- if (preReplacement)
6097
+ if (substitutionsReplacement != null)
5903
6098
  // Approach 1: (array[0] + joiner + array[1] + joiner + array[2]...).split(separator)
5904
6099
  {
5905
- // 2 is for the additional overhead of "(" + ")".
5906
- var maxBulkLength = maxLength - (preReplacement.length + 2);
5907
- var optimalStrReplacement;
6100
+ var maxBulkLength =
6101
+ maxLength - substitutionsReplacement.length - splitReplacement.length -
6102
+ SEPARATION_MIN_OVERHEAD + SEPARATOR_MIN_LENGTH;
6103
+ var optimalSeqReplacement;
5908
6104
  var optimalSeparatorReplacement;
5909
6105
  insertions.forEach
5910
6106
  (
5911
6107
  function (insertion)
5912
6108
  {
5913
- var strReplacement =
6109
+ var seqReplacement =
5914
6110
  replaceJoinedArrayString(array, insertion.joiner, maxBulkLength);
5915
- if (!strReplacement)
6111
+ if (!seqReplacement)
5916
6112
  return;
5917
6113
  var separatorReplacement = undefinedAsString(this.replaceExpr(insertion.separator));
5918
- var bulkLength = strReplacement.length + separatorReplacement.length;
6114
+ var bulkLength = seqReplacement.length + separatorReplacement.length;
5919
6115
  if (!(bulkLength > maxBulkLength))
5920
6116
  {
5921
6117
  maxBulkLength = bulkLength;
5922
- optimalStrReplacement = strReplacement;
6118
+ optimalSeqReplacement = seqReplacement;
5923
6119
  optimalSeparatorReplacement = separatorReplacement;
5924
6120
  }
5925
6121
  },
5926
6122
  this
5927
6123
  );
5928
- if (optimalStrReplacement)
6124
+ if (optimalSeqReplacement)
5929
6125
  {
5930
6126
  replacement =
5931
- optimalStrReplacement + preReplacement + '(' + optimalSeparatorReplacement + ')';
6127
+ optimalSeqReplacement + substitutionsReplacement + '[' + splitReplacement + '](' +
6128
+ optimalSeparatorReplacement + ')';
5932
6129
  maxLength = replacement.length - 1;
5933
6130
  }
5934
6131
  }
5935
- if
5936
- (
5937
- !substitutions &&
5938
- (
5939
- count <= 1 ||
5940
- concatReplacement &&
5941
- // 4 is the length of the shortest possible replacement "[[]]".
5942
- // 7 is the length of the shortest possible additional overhead for each following array
5943
- // element, as in "[" + "](+[])" or "[" + "](![])".
5944
- !(4 + (concatReplacement.length + 7) * (count - 1) > maxLength)
5945
- )
5946
- )
6132
+ if (!substitutions)
5947
6133
  // Approach 2: [array[0]].concat(array[1]).concat(array[2])...
5948
6134
  {
5949
- var arrayReplacement;
5950
- var options = { screwMode: forceString ? SCREW_AS_STRING : SCREW_NORMAL };
5951
- if
5952
- (
5953
- !array.some
5954
- (
5955
- function (element)
5956
- {
5957
- var elementReplacement =
5958
- undefinedAsString(replaceStaticString(element, options));
5959
- if (arrayReplacement)
5960
- {
5961
- if (elementReplacement === '[]')
5962
- elementReplacement = allowZeroForEmptyElements ? '+[]' : '[[]]';
5963
- arrayReplacement +=
5964
- '[' + concatReplacement + '](' + elementReplacement + ')';
5965
- }
5966
- else
5967
- arrayReplacement = '[' + elementReplacement + ']';
5968
- var result = arrayReplacement.length > maxLength;
5969
- return result;
5970
- }
5971
- )
5972
- )
6135
+ var arrayReplacement =
6136
+ createConcatenationReplacement
6137
+ (this, array, allowZeroForEmptyElements, forceString, maxLength);
6138
+ if (arrayReplacement)
5973
6139
  replacement = arrayReplacement;
5974
6140
  }
5975
6141
  return replacement;
5976
6142
  }
5977
6143
 
6144
+ function undefinedAsString(replacement)
6145
+ {
6146
+ if (replacement === '[][[]]')
6147
+ replacement += '+[]';
6148
+ return replacement;
6149
+ }
6150
+
5978
6151
  var ENCODING_TYPE_COMBINED = 'combined';
5979
6152
  var ENCODING_TYPE_EXPRESSION = 'expression';
5980
6153
  var ENCODING_TYPE_TEXT = 'text';
@@ -5982,6 +6155,12 @@
5982
6155
  var FALSE_FREE_DELIMITER = { joiner: 'false', separator: 'false' };
5983
6156
  var FALSE_TRUE_DELIMITER = { joiner: '', separator: 'Function("return/(?=false|true)/")()' };
5984
6157
 
6158
+ // Underestimated minimum length of the joining: "[" + joinReplacement + "]([])".
6159
+ var JOINING_MIN_LENGTH = 8;
6160
+
6161
+ // Underestimated minimum overhead of the mapping: "[" + "](" + mapperReplacement + ")".
6162
+ var MAPPING_MIN_OVERHEAD = 12;
6163
+
5985
6164
  var REPLACERS =
5986
6165
  {
5987
6166
  identifier:
@@ -6079,23 +6258,62 @@
6079
6258
  return charKeyArrayStr;
6080
6259
  }
6081
6260
 
6082
- function createJSFuckArrayMapping(encoder, arrayStr, mapper, legend)
6261
+ function createLongStrCodesOutput(encoder, arrayReplacement, fromCharCode, arg, maxLength)
6083
6262
  {
6084
- var result =
6085
- arrayStr + '[' + encoder.replaceString('map', { optimize: true }) + '](' +
6086
- encoder.replaceExpr(mapper, true) + '(' + legend + '))';
6087
- return result;
6263
+ var mapReplacement = encoder.resolveConstant('MAP').replacement;
6264
+ var maxCharArrayLength = maxLength - JOINING_MIN_LENGTH;
6265
+ var maxMapReplacementLength =
6266
+ maxCharArrayLength - arrayReplacement.length - MAPPING_MIN_OVERHEAD;
6267
+ if (mapReplacement.length > maxMapReplacementLength)
6268
+ return;
6269
+ var formatter = encoder.findDefinition(FROM_CHAR_CODE_CALLBACK_FORMATTER);
6270
+ var formatterExpr = formatter(fromCharCode, arg);
6271
+ var mapper = 'Function("return ' + formatterExpr + '")()';
6272
+ var mapperReplacement = encoder._replaceMapper(mapper);
6273
+ var charArrayReplacement =
6274
+ joinWithMaxLength
6275
+ (
6276
+ maxCharArrayLength,
6277
+ arrayReplacement,
6278
+ '[',
6279
+ mapReplacement,
6280
+ '](',
6281
+ mapperReplacement,
6282
+ ')'
6283
+ );
6284
+ if (!charArrayReplacement)
6285
+ return;
6286
+ var replacement = encoder._joinCharArray(charArrayReplacement, maxLength);
6287
+ return replacement;
6088
6288
  }
6089
6289
 
6090
- function createLongStrCodesOutput(encoder, strCodeArrayStr, fromCharCode, arg)
6290
+ function createMappedArrayEncoding(encoder, arrayReplacement, mapper, legend, maxLength)
6091
6291
  {
6092
- var formatter = encoder.findDefinition(FROM_CHAR_CODE_CALLBACK_FORMATTER);
6093
- var formatterExpr = formatter(fromCharCode, arg);
6094
- var output =
6095
- strCodeArrayStr + '[' + encoder.replaceString('map', { optimize: true }) + '](' +
6096
- encoder.replaceExpr('Function("return ' + formatterExpr + '")()', true) + ')[' +
6097
- encoder.replaceString('join') + ']([])';
6098
- return output;
6292
+ var mapReplacement = encoder.resolveConstant('MAP').replacement;
6293
+ var maxCharArrayLength = maxLength - JOINING_MIN_LENGTH;
6294
+ var maxMapReplacementLength =
6295
+ // 2 is for the calling parentheses around the legend replacement.
6296
+ maxCharArrayLength - arrayReplacement.length - MAPPING_MIN_OVERHEAD - legend.length - 2;
6297
+ if (mapReplacement.length > maxMapReplacementLength)
6298
+ return;
6299
+ var mapperReplacement = encoder._replaceMapper(mapper);
6300
+ var charArrayReplacement =
6301
+ joinWithMaxLength
6302
+ (
6303
+ maxCharArrayLength,
6304
+ arrayReplacement,
6305
+ '[',
6306
+ mapReplacement,
6307
+ '](',
6308
+ mapperReplacement,
6309
+ '(',
6310
+ legend,
6311
+ '))'
6312
+ );
6313
+ if (!charArrayReplacement)
6314
+ return;
6315
+ var replacement = encoder._joinCharArray(charArrayReplacement, maxLength);
6316
+ return replacement;
6099
6317
  }
6100
6318
 
6101
6319
  function createReindexMap(count, radix, amendingCount, coerceToInt)
@@ -6163,41 +6381,58 @@
6163
6381
  var strCodeCacheKey = 'strCodeCache' + (radix ? 'Radix' + radix : '');
6164
6382
  var cache = inputData[strCodeCacheKey] || (inputData[strCodeCacheKey] = createEmpty());
6165
6383
  var strCodeArray = splitter(input, radix, cache);
6166
- var strCodeArrayStr = encoder.replaceFalseFreeArray(strCodeArray, maxLength);
6384
+ var strCodeArrayStr =
6385
+ encoder.replaceStringArray(strCodeArray, [FALSE_FREE_DELIMITER], null, false, false, maxLength);
6167
6386
  if (strCodeArrayStr)
6168
6387
  {
6169
- var output;
6388
+ var replacement;
6170
6389
  if (radix)
6171
6390
  {
6172
- output =
6391
+ replacement =
6173
6392
  createLongStrCodesOutput
6174
- (encoder, strCodeArrayStr, fromCharCode, 'parseInt(undefined,' + radix + ')');
6393
+ (
6394
+ encoder,
6395
+ strCodeArrayStr,
6396
+ fromCharCode,
6397
+ 'parseInt(undefined,' + radix + ')',
6398
+ maxLength
6399
+ );
6175
6400
  }
6176
6401
  else
6177
6402
  {
6178
6403
  var long = strCodeArray.length > encoder._maxDecodableArgs;
6179
6404
  if (long)
6180
6405
  {
6181
- output =
6182
- createLongStrCodesOutput(encoder, strCodeArrayStr, fromCharCode, 'undefined');
6406
+ replacement =
6407
+ createLongStrCodesOutput
6408
+ (
6409
+ encoder,
6410
+ strCodeArrayStr,
6411
+ fromCharCode,
6412
+ 'undefined',
6413
+ maxLength
6414
+ );
6183
6415
  }
6184
6416
  else
6185
6417
  {
6186
6418
  var returnString = encoder.findDefinition(OPTIMAL_RETURN_STRING);
6187
6419
  var str = returnString + '.' + fromCharCode + '(';
6188
- output =
6189
- encoder.resolveConstant('Function').replacement +
6190
- '(' +
6191
- encoder.replaceString(str, { optimize: true }) +
6192
- '+' +
6193
- strCodeArrayStr +
6194
- '+' +
6195
- encoder.resolveCharacter(')').replacement +
6196
- ')()';
6420
+ replacement =
6421
+ joinWithMaxLength
6422
+ (
6423
+ maxLength,
6424
+ encoder.resolveConstant('Function').replacement,
6425
+ '(',
6426
+ encoder.replaceString(str, { optimize: true }),
6427
+ '+',
6428
+ strCodeArrayStr,
6429
+ '+',
6430
+ encoder.resolveCharacter(')').replacement,
6431
+ ')()'
6432
+ );
6197
6433
  }
6198
6434
  }
6199
- if (!(output.length > maxLength))
6200
- return output;
6435
+ return replacement;
6201
6436
  }
6202
6437
  }
6203
6438
 
@@ -6256,8 +6491,7 @@
6256
6491
  var legend = encodeDictLegend(encoder, dictChars, maxLength - minCharIndexArrayStrLength);
6257
6492
  if (!legend)
6258
6493
  return;
6259
- var figureLegendInsertions =
6260
- encoder._callGetFigureLegendInsertions(getFigureLegendInsertions, figurator, figures);
6494
+ var figureLegendInsertions = getFigureLegendInsertions(figurator, figures);
6261
6495
  var figureMaxLength = maxLength - legend.length;
6262
6496
  var figureLegend =
6263
6497
  encoder.replaceStringArray
@@ -6284,13 +6518,10 @@
6284
6518
  );
6285
6519
  if (!charIndexFigureArrayStr)
6286
6520
  return;
6287
- var formatMapper = encoder.findDefinition(FORMAT_MAPPER_SHORT);
6288
- var argName = formatMapper.argName;
6289
- var accessor = '.indexOf(' + argName + ')';
6290
- var mapper = formatMapper(accessor);
6291
- var charIndexArrayStr =
6292
- createJSFuckArrayMapping(encoder, charIndexFigureArrayStr, mapper, figureLegend);
6293
- var output = encoder.createDictEncoding(legend, charIndexArrayStr, maxLength);
6521
+ var formatMapper = encoder._findFormatMapperShort();
6522
+ var output =
6523
+ encoder._createDblDictEncoding
6524
+ (formatMapper, charIndexFigureArrayStr, figureLegend, legend, maxLength);
6294
6525
  return output;
6295
6526
  }
6296
6527
 
@@ -6798,7 +7029,7 @@
6798
7029
  return output;
6799
7030
  },
6800
7031
  ENCODING_TYPE_TEXT,
6801
- 193
7032
+ 194
6802
7033
  ),
6803
7034
 
6804
7035
  /* -------------------------------------------------------------------------------------- *\
@@ -6853,7 +7084,7 @@
6853
7084
  return output;
6854
7085
  },
6855
7086
  ENCODING_TYPE_TEXT,
6856
- 347
7087
+ 173
6857
7088
  ),
6858
7089
 
6859
7090
  /* -------------------------------------------------------------------------------------- *\
@@ -6943,11 +7174,51 @@
6943
7174
  (
6944
7175
  Encoder.prototype,
6945
7176
  {
6946
- _callGetFigureLegendInsertions:
6947
- function (getFigureLegendInsertions, figurator, figures)
7177
+ _createDblDictEncoding:
7178
+ function (formatMapper, charIndexFigureArrayStr, figureLegend, legend, maxLength)
6948
7179
  {
6949
- var figureLegendInsertions = getFigureLegendInsertions(figurator, figures);
6950
- return figureLegendInsertions;
7180
+ var argName = formatMapper.argName;
7181
+ var accessor = '.indexOf(' + argName + ')';
7182
+ var mapper = formatMapper(accessor);
7183
+ var concatReplacement = this.resolveConstant('CONCAT').replacement;
7184
+ var maxCombinedLegendLength = maxLength - charIndexFigureArrayStr.length - 10;
7185
+ var combinedLegend =
7186
+ joinWithMaxLength
7187
+ (
7188
+ maxCombinedLegendLength,
7189
+ '[',
7190
+ figureLegend,
7191
+ '][',
7192
+ concatReplacement,
7193
+ '](',
7194
+ legend,
7195
+ ')'
7196
+ );
7197
+ if (!combinedLegend)
7198
+ return;
7199
+ var replacement =
7200
+ createMappedArrayEncoding
7201
+ (this, charIndexFigureArrayStr, mapper, combinedLegend, maxLength);
7202
+ return replacement;
7203
+ },
7204
+
7205
+ _createDictEncoding:
7206
+ function (charIndexArrayStr, legend, radix, coerceToInt, maxLength)
7207
+ {
7208
+ var mapper;
7209
+ if (radix)
7210
+ {
7211
+ var formatMapper = this.findDefinition(FORMAT_MAPPER_LONG);
7212
+ var argName = formatMapper.argName;
7213
+ var parseIntArg = (coerceToInt ? '+' : '') + argName;
7214
+ var accessor = '[parseInt(' + parseIntArg + ',' + radix + ')]';
7215
+ mapper = formatMapper(accessor);
7216
+ }
7217
+ else
7218
+ mapper = '"".charAt.bind';
7219
+ var replacement =
7220
+ createMappedArrayEncoding(this, charIndexArrayStr, mapper, legend, maxLength);
7221
+ return replacement;
6951
7222
  },
6952
7223
 
6953
7224
  _encodeByCharCodes:
@@ -7044,7 +7315,7 @@
7044
7315
  if (!charIndexArrayStr)
7045
7316
  return;
7046
7317
  var output =
7047
- this.createDictEncoding(legend, charIndexArrayStr, maxLength, radix, coerceToInt);
7318
+ this._createDictEncoding(charIndexArrayStr, legend, radix, coerceToInt, maxLength);
7048
7319
  return output;
7049
7320
  },
7050
7321
 
@@ -7092,41 +7363,33 @@
7092
7363
  perfInfo.perfLog = perfLog;
7093
7364
  delete this.perfLog;
7094
7365
  if (output == null)
7095
- throw new _Error$1('Encoding failed');
7366
+ throw _Error$1('Encoding failed');
7096
7367
  return output;
7097
7368
  },
7098
7369
 
7099
- _maxDecodableArgs: 65533, // Limit imposed by Internet Explorer.
7370
+ _findFormatMapperShort:
7371
+ function ()
7372
+ {
7373
+ var formatMapper = this.findDefinition(FORMAT_MAPPER_SHORT);
7374
+ return formatMapper;
7375
+ },
7100
7376
 
7101
- createDictEncoding:
7102
- function (legend, charIndexArrayStr, maxLength, radix, coerceToInt)
7377
+ _joinCharArray:
7378
+ function (charArrayReplacement, maxLength)
7103
7379
  {
7104
- var mapper;
7105
- if (radix)
7106
- {
7107
- var formatMapper = this.findDefinition(FORMAT_MAPPER_LONG);
7108
- var argName = formatMapper.argName;
7109
- var parseIntArg = (coerceToInt ? '+' : '') + argName;
7110
- var accessor = '[parseInt(' + parseIntArg + ',' + radix + ')]';
7111
- mapper = formatMapper(accessor);
7112
- }
7113
- else
7114
- mapper = '"".charAt.bind';
7115
- var output =
7116
- createJSFuckArrayMapping(this, charIndexArrayStr, mapper, legend) + '[' +
7117
- this.replaceString('join') + ']([])';
7118
- if (!(output.length > maxLength))
7119
- return output;
7380
+ var joinReplacement = this.resolveConstant('JOIN').replacement;
7381
+ var replacement =
7382
+ joinWithMaxLength(maxLength, charArrayReplacement, '[', joinReplacement, ']([])');
7383
+ return replacement;
7120
7384
  },
7121
7385
 
7122
- // Array elements may not contain the substring "false", because the value false could be
7123
- // used as a separator in the encoding.
7124
- replaceFalseFreeArray:
7125
- function (array, maxLength)
7386
+ _maxDecodableArgs: 65533, // Limit imposed by Internet Explorer.
7387
+
7388
+ _replaceMapper:
7389
+ function (mapper)
7126
7390
  {
7127
- var result =
7128
- this.replaceStringArray(array, [FALSE_FREE_DELIMITER], null, false, false, maxLength);
7129
- return result;
7391
+ var mapperReplacement = this.replaceExpr(mapper, true);
7392
+ return mapperReplacement;
7130
7393
  },
7131
7394
 
7132
7395
  replaceStringArray: replaceStringArray,
@@ -7872,7 +8135,7 @@
7872
8135
  case 'none':
7873
8136
  return [, STRATEGY_NAMES_TEXT];
7874
8137
  }
7875
- throw new _Error$1('Invalid value for option ' + name);
8138
+ throw _Error$1('Invalid value for option ' + name);
7876
8139
  }
7877
8140
 
7878
8141
  function flushEncoderCache()
@@ -8023,7 +8286,7 @@
8023
8286
  {
8024
8287
  constant = _String$1(constant);
8025
8288
  if (!/^[$A-Z_a-z][$\w]*$/.test(constant))
8026
- throw new _SyntaxError('Invalid identifier ' + _JSON_stringify$1(constant));
8289
+ throw _SyntaxError('Invalid identifier ' + _JSON_stringify$1(constant));
8027
8290
  if (!encoder.hasOwnProperty('constantDefinitions'))
8028
8291
  encoder.constantDefinitions = _Object_create$1(CONSTANTS);
8029
8292
  var entries = [define(esToString$1(definition))];
@@ -8099,8 +8362,8 @@
8099
8362
  ENTRIES[name + ':available'] = entries.available;
8100
8363
  }
8101
8364
 
8102
- exposeEntries('FORMAT_MAPPER_LONG', FORMAT_MAPPER_LONG);
8103
- exposeEntries('FORMAT_MAPPER_SHORT', FORMAT_MAPPER_SHORT);
8365
+ exposeEntries('FORMAT_MAPPER_LONG', FORMAT_MAPPER_LONG);
8366
+ exposeEntries('FORMAT_MAPPER_SHORT', FORMAT_MAPPER_SHORT);
8104
8367
  exposeEntries('FROM_CHAR_CODE', FROM_CHAR_CODE);
8105
8368
  exposeEntries('FROM_CHAR_CODE_CALLBACK_FORMATTER', FROM_CHAR_CODE_CALLBACK_FORMATTER);
8106
8369
  exposeEntries('OPTIMAL_B', OPTIMAL_B);