find-primordials 1.0.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.
@@ -0,0 +1,836 @@
1
+
2
+ /*
3
+ * All ECMA-262 primordials organized by category
4
+ * Each entry defines: globals, instanceMethods, staticMethods (in alphabetical order)
5
+ */
6
+
7
+ /**
8
+ * @typedef {object} PrimordialCategory
9
+ * @property {string[]} globals
10
+ * @property {string[]} instanceMethods
11
+ * @property {string[]} staticMethods
12
+ * @property {string[]} [instanceProperties]
13
+ * @property {string[]} [staticProperties]
14
+ * @property {string[]} [wellKnownSymbols]
15
+ */
16
+
17
+ /** @type {Record<string, PrimordialCategory>} */
18
+ export const primordials = {
19
+ AggregateError: {
20
+ globals: ['AggregateError'],
21
+ instanceMethods: [],
22
+ staticMethods: [],
23
+ },
24
+ Array: {
25
+ globals: ['Array'],
26
+ instanceMethods: [
27
+ 'at',
28
+ 'concat',
29
+ 'copyWithin',
30
+ 'entries',
31
+ 'every',
32
+ 'fill',
33
+ 'filter',
34
+ 'find',
35
+ 'findIndex',
36
+ 'findLast',
37
+ 'findLastIndex',
38
+ 'flat',
39
+ 'flatMap',
40
+ 'forEach',
41
+ 'includes',
42
+ 'indexOf',
43
+ 'join',
44
+ 'keys',
45
+ 'lastIndexOf',
46
+ 'map',
47
+ 'pop',
48
+ 'push',
49
+ 'reduce',
50
+ 'reduceRight',
51
+ 'reverse',
52
+ 'shift',
53
+ 'slice',
54
+ 'some',
55
+ 'sort',
56
+ 'splice',
57
+ 'toLocaleString',
58
+ 'toReversed',
59
+ 'toSorted',
60
+ 'toSpliced',
61
+ 'toString',
62
+ 'unshift',
63
+ 'values',
64
+ 'with',
65
+ ],
66
+ staticMethods: [
67
+ 'from',
68
+ 'fromAsync',
69
+ 'isArray',
70
+ 'of',
71
+ ],
72
+ },
73
+ ArrayBuffer: {
74
+ globals: ['ArrayBuffer'],
75
+ instanceMethods: [
76
+ 'resize',
77
+ 'slice',
78
+ 'transfer',
79
+ 'transferToFixedLength',
80
+ ],
81
+ instanceProperties: [
82
+ 'byteLength',
83
+ 'detached',
84
+ 'maxByteLength',
85
+ 'resizable',
86
+ ],
87
+ staticMethods: ['isView'],
88
+ },
89
+ AsyncGenerator: {
90
+ globals: [],
91
+ instanceMethods: [
92
+ 'next',
93
+ 'return',
94
+ 'throw',
95
+ ],
96
+ staticMethods: [],
97
+ },
98
+ AsyncGeneratorFunction: {
99
+ globals: ['AsyncGeneratorFunction'],
100
+ instanceMethods: [],
101
+ staticMethods: [],
102
+ },
103
+ AsyncIterator: {
104
+ globals: ['AsyncIterator'],
105
+ instanceMethods: [
106
+ 'drop',
107
+ 'every',
108
+ 'filter',
109
+ 'find',
110
+ 'flatMap',
111
+ 'forEach',
112
+ 'map',
113
+ 'reduce',
114
+ 'some',
115
+ 'take',
116
+ 'toArray',
117
+ ],
118
+ staticMethods: ['from'],
119
+ },
120
+ Atomics: {
121
+ globals: ['Atomics'],
122
+ instanceMethods: [],
123
+ staticMethods: [
124
+ 'add',
125
+ 'and',
126
+ 'compareExchange',
127
+ 'exchange',
128
+ 'isLockFree',
129
+ 'load',
130
+ 'notify',
131
+ 'or',
132
+ 'store',
133
+ 'sub',
134
+ 'wait',
135
+ 'waitAsync',
136
+ 'xor',
137
+ ],
138
+ },
139
+ BigInt: {
140
+ globals: ['BigInt'],
141
+ instanceMethods: [
142
+ 'toLocaleString',
143
+ 'toString',
144
+ 'valueOf',
145
+ ],
146
+ staticMethods: [
147
+ 'asIntN',
148
+ 'asUintN',
149
+ ],
150
+ },
151
+ Boolean: {
152
+ globals: ['Boolean'],
153
+ instanceMethods: [
154
+ 'toString',
155
+ 'valueOf',
156
+ ],
157
+ staticMethods: [],
158
+ },
159
+ DataView: {
160
+ globals: ['DataView'],
161
+ instanceMethods: [
162
+ 'getBigInt64',
163
+ 'getBigUint64',
164
+ 'getFloat16',
165
+ 'getFloat32',
166
+ 'getFloat64',
167
+ 'getInt8',
168
+ 'getInt16',
169
+ 'getInt32',
170
+ 'getUint8',
171
+ 'getUint16',
172
+ 'getUint32',
173
+ 'setBigInt64',
174
+ 'setBigUint64',
175
+ 'setFloat16',
176
+ 'setFloat32',
177
+ 'setFloat64',
178
+ 'setInt8',
179
+ 'setInt16',
180
+ 'setInt32',
181
+ 'setUint8',
182
+ 'setUint16',
183
+ 'setUint32',
184
+ ],
185
+ instanceProperties: [
186
+ 'buffer',
187
+ 'byteLength',
188
+ 'byteOffset',
189
+ ],
190
+ staticMethods: [],
191
+ },
192
+ Date: {
193
+ globals: ['Date'],
194
+ instanceMethods: [
195
+ 'getDate',
196
+ 'getDay',
197
+ 'getFullYear',
198
+ 'getHours',
199
+ 'getMilliseconds',
200
+ 'getMinutes',
201
+ 'getMonth',
202
+ 'getSeconds',
203
+ 'getTime',
204
+ 'getTimezoneOffset',
205
+ 'getUTCDate',
206
+ 'getUTCDay',
207
+ 'getUTCFullYear',
208
+ 'getUTCHours',
209
+ 'getUTCMilliseconds',
210
+ 'getUTCMinutes',
211
+ 'getUTCMonth',
212
+ 'getUTCSeconds',
213
+ 'setDate',
214
+ 'setFullYear',
215
+ 'setHours',
216
+ 'setMilliseconds',
217
+ 'setMinutes',
218
+ 'setMonth',
219
+ 'setSeconds',
220
+ 'setTime',
221
+ 'setUTCDate',
222
+ 'setUTCFullYear',
223
+ 'setUTCHours',
224
+ 'setUTCMilliseconds',
225
+ 'setUTCMinutes',
226
+ 'setUTCMonth',
227
+ 'setUTCSeconds',
228
+ 'toDateString',
229
+ 'toISOString',
230
+ 'toJSON',
231
+ 'toLocaleDateString',
232
+ 'toLocaleString',
233
+ 'toLocaleTimeString',
234
+ 'toString',
235
+ 'toTimeString',
236
+ 'toUTCString',
237
+ 'valueOf',
238
+ ],
239
+ staticMethods: [
240
+ 'now',
241
+ 'parse',
242
+ 'UTC',
243
+ ],
244
+ },
245
+ decodeURI: {
246
+ globals: ['decodeURI'],
247
+ instanceMethods: [],
248
+ staticMethods: [],
249
+ },
250
+ decodeURIComponent: {
251
+ globals: ['decodeURIComponent'],
252
+ instanceMethods: [],
253
+ staticMethods: [],
254
+ },
255
+ encodeURI: {
256
+ globals: ['encodeURI'],
257
+ instanceMethods: [],
258
+ staticMethods: [],
259
+ },
260
+ encodeURIComponent: {
261
+ globals: ['encodeURIComponent'],
262
+ instanceMethods: [],
263
+ staticMethods: [],
264
+ },
265
+ Error: {
266
+ globals: ['Error'],
267
+ instanceMethods: ['toString'],
268
+ staticMethods: [
269
+ 'captureStackTrace',
270
+ 'isError',
271
+ ],
272
+ },
273
+ eval: {
274
+ globals: ['eval'],
275
+ instanceMethods: [],
276
+ staticMethods: [],
277
+ },
278
+ EvalError: {
279
+ globals: ['EvalError'],
280
+ instanceMethods: [],
281
+ staticMethods: [],
282
+ },
283
+ FinalizationRegistry: {
284
+ globals: ['FinalizationRegistry'],
285
+ instanceMethods: [
286
+ 'register',
287
+ 'unregister',
288
+ ],
289
+ staticMethods: [],
290
+ },
291
+ Function: {
292
+ globals: ['Function'],
293
+ instanceMethods: [
294
+ 'apply',
295
+ 'bind',
296
+ 'call',
297
+ 'toString',
298
+ ],
299
+ staticMethods: [],
300
+ },
301
+ Generator: {
302
+ globals: [],
303
+ instanceMethods: [
304
+ 'next',
305
+ 'return',
306
+ 'throw',
307
+ ],
308
+ staticMethods: [],
309
+ },
310
+ GeneratorFunction: {
311
+ globals: ['GeneratorFunction'],
312
+ instanceMethods: [],
313
+ staticMethods: [],
314
+ },
315
+ globalThis: {
316
+ globals: ['globalThis'],
317
+ instanceMethods: [],
318
+ staticMethods: [],
319
+ },
320
+ Infinity: {
321
+ globals: ['Infinity'],
322
+ instanceMethods: [],
323
+ staticMethods: [],
324
+ },
325
+ isFinite: {
326
+ globals: ['isFinite'],
327
+ instanceMethods: [],
328
+ staticMethods: [],
329
+ },
330
+ isNaN: {
331
+ globals: ['isNaN'],
332
+ instanceMethods: [],
333
+ staticMethods: [],
334
+ },
335
+ Iterator: {
336
+ globals: ['Iterator'],
337
+ instanceMethods: [
338
+ 'drop',
339
+ 'every',
340
+ 'filter',
341
+ 'find',
342
+ 'flatMap',
343
+ 'forEach',
344
+ 'map',
345
+ 'reduce',
346
+ 'some',
347
+ 'take',
348
+ 'toArray',
349
+ ],
350
+ staticMethods: ['from'],
351
+ },
352
+ JSON: {
353
+ globals: ['JSON'],
354
+ instanceMethods: [],
355
+ staticMethods: [
356
+ 'isRawJSON',
357
+ 'parse',
358
+ 'rawJSON',
359
+ 'stringify',
360
+ ],
361
+ },
362
+ Map: {
363
+ globals: ['Map'],
364
+ instanceMethods: [
365
+ 'clear',
366
+ 'delete',
367
+ 'entries',
368
+ 'forEach',
369
+ 'get',
370
+ 'has',
371
+ 'keys',
372
+ 'set',
373
+ 'values',
374
+ ],
375
+ instanceProperties: ['size'],
376
+ staticMethods: ['groupBy'],
377
+ },
378
+ Math: {
379
+ globals: ['Math'],
380
+ instanceMethods: [],
381
+ staticMethods: [
382
+ 'abs',
383
+ 'acos',
384
+ 'acosh',
385
+ 'asin',
386
+ 'asinh',
387
+ 'atan',
388
+ 'atan2',
389
+ 'atanh',
390
+ 'cbrt',
391
+ 'ceil',
392
+ 'clz32',
393
+ 'cos',
394
+ 'cosh',
395
+ 'exp',
396
+ 'expm1',
397
+ 'f16round',
398
+ 'floor',
399
+ 'fround',
400
+ 'hypot',
401
+ 'imul',
402
+ 'log',
403
+ 'log10',
404
+ 'log1p',
405
+ 'log2',
406
+ 'max',
407
+ 'min',
408
+ 'pow',
409
+ 'random',
410
+ 'round',
411
+ 'sign',
412
+ 'sin',
413
+ 'sinh',
414
+ 'sqrt',
415
+ 'sumPrecise',
416
+ 'tan',
417
+ 'tanh',
418
+ 'trunc',
419
+ ],
420
+ staticProperties: [
421
+ 'E',
422
+ 'LN10',
423
+ 'LN2',
424
+ 'LOG10E',
425
+ 'LOG2E',
426
+ 'PI',
427
+ 'SQRT1_2',
428
+ 'SQRT2',
429
+ ],
430
+ },
431
+ NaN: {
432
+ globals: ['NaN'],
433
+ instanceMethods: [],
434
+ staticMethods: [],
435
+ },
436
+ Number: {
437
+ globals: ['Number'],
438
+ instanceMethods: [
439
+ 'toExponential',
440
+ 'toFixed',
441
+ 'toLocaleString',
442
+ 'toPrecision',
443
+ 'toString',
444
+ 'valueOf',
445
+ ],
446
+ staticMethods: [
447
+ 'isFinite',
448
+ 'isInteger',
449
+ 'isNaN',
450
+ 'isSafeInteger',
451
+ 'parseFloat',
452
+ 'parseInt',
453
+ ],
454
+ staticProperties: [
455
+ 'EPSILON',
456
+ 'MAX_SAFE_INTEGER',
457
+ 'MAX_VALUE',
458
+ 'MIN_SAFE_INTEGER',
459
+ 'MIN_VALUE',
460
+ 'NaN',
461
+ 'NEGATIVE_INFINITY',
462
+ 'POSITIVE_INFINITY',
463
+ ],
464
+ },
465
+ Object: {
466
+ globals: ['Object'],
467
+ instanceMethods: [
468
+ 'hasOwnProperty',
469
+ 'isPrototypeOf',
470
+ 'propertyIsEnumerable',
471
+ 'toLocaleString',
472
+ 'toString',
473
+ 'valueOf',
474
+ ],
475
+ staticMethods: [
476
+ 'assign',
477
+ 'create',
478
+ 'defineProperties',
479
+ 'defineProperty',
480
+ 'entries',
481
+ 'freeze',
482
+ 'fromEntries',
483
+ 'getOwnPropertyDescriptor',
484
+ 'getOwnPropertyDescriptors',
485
+ 'getOwnPropertyNames',
486
+ 'getOwnPropertySymbols',
487
+ 'getPrototypeOf',
488
+ 'groupBy',
489
+ 'hasOwn',
490
+ 'is',
491
+ 'isExtensible',
492
+ 'isFrozen',
493
+ 'isSealed',
494
+ 'keys',
495
+ 'preventExtensions',
496
+ 'seal',
497
+ 'setPrototypeOf',
498
+ 'values',
499
+ ],
500
+ },
501
+ parseFloat: {
502
+ globals: ['parseFloat'],
503
+ instanceMethods: [],
504
+ staticMethods: [],
505
+ },
506
+ parseInt: {
507
+ globals: ['parseInt'],
508
+ instanceMethods: [],
509
+ staticMethods: [],
510
+ },
511
+ Promise: {
512
+ globals: ['Promise'],
513
+ instanceMethods: [
514
+ 'catch',
515
+ 'finally',
516
+ 'then',
517
+ ],
518
+ staticMethods: [
519
+ 'all',
520
+ 'allSettled',
521
+ 'any',
522
+ 'race',
523
+ 'reject',
524
+ 'resolve',
525
+ 'try',
526
+ 'withResolvers',
527
+ ],
528
+ },
529
+ Proxy: {
530
+ globals: ['Proxy'],
531
+ instanceMethods: [],
532
+ staticMethods: ['revocable'],
533
+ },
534
+ RangeError: {
535
+ globals: ['RangeError'],
536
+ instanceMethods: [],
537
+ staticMethods: [],
538
+ },
539
+ ReferenceError: {
540
+ globals: ['ReferenceError'],
541
+ instanceMethods: [],
542
+ staticMethods: [],
543
+ },
544
+ Reflect: {
545
+ globals: ['Reflect'],
546
+ instanceMethods: [],
547
+ staticMethods: [
548
+ 'apply',
549
+ 'construct',
550
+ 'defineProperty',
551
+ 'deleteProperty',
552
+ 'get',
553
+ 'getOwnPropertyDescriptor',
554
+ 'getPrototypeOf',
555
+ 'has',
556
+ 'isExtensible',
557
+ 'ownKeys',
558
+ 'preventExtensions',
559
+ 'set',
560
+ 'setPrototypeOf',
561
+ ],
562
+ },
563
+ RegExp: {
564
+ globals: ['RegExp'],
565
+ instanceMethods: [
566
+ 'exec',
567
+ 'test',
568
+ 'toString',
569
+ ],
570
+ instanceProperties: [
571
+ 'dotAll',
572
+ 'flags',
573
+ 'global',
574
+ 'hasIndices',
575
+ 'ignoreCase',
576
+ 'multiline',
577
+ 'source',
578
+ 'sticky',
579
+ 'unicode',
580
+ 'unicodeSets',
581
+ ],
582
+ staticMethods: ['escape'],
583
+ },
584
+ Set: {
585
+ globals: ['Set'],
586
+ instanceMethods: [
587
+ 'add',
588
+ 'clear',
589
+ 'delete',
590
+ 'difference',
591
+ 'entries',
592
+ 'forEach',
593
+ 'has',
594
+ 'intersection',
595
+ 'isDisjointFrom',
596
+ 'isSubsetOf',
597
+ 'isSupersetOf',
598
+ 'keys',
599
+ 'symmetricDifference',
600
+ 'union',
601
+ 'values',
602
+ ],
603
+ instanceProperties: ['size'],
604
+ staticMethods: [],
605
+ },
606
+ SharedArrayBuffer: {
607
+ globals: ['SharedArrayBuffer'],
608
+ instanceMethods: [
609
+ 'grow',
610
+ 'slice',
611
+ ],
612
+ instanceProperties: [
613
+ 'byteLength',
614
+ 'growable',
615
+ 'maxByteLength',
616
+ ],
617
+ staticMethods: [],
618
+ },
619
+ String: {
620
+ globals: ['String'],
621
+ instanceMethods: [
622
+ 'at',
623
+ 'charAt',
624
+ 'charCodeAt',
625
+ 'codePointAt',
626
+ 'concat',
627
+ 'endsWith',
628
+ 'includes',
629
+ 'indexOf',
630
+ 'isWellFormed',
631
+ 'lastIndexOf',
632
+ 'localeCompare',
633
+ 'match',
634
+ 'matchAll',
635
+ 'normalize',
636
+ 'padEnd',
637
+ 'padStart',
638
+ 'repeat',
639
+ 'replace',
640
+ 'replaceAll',
641
+ 'search',
642
+ 'slice',
643
+ 'split',
644
+ 'startsWith',
645
+ 'substring',
646
+ 'toLocaleLowerCase',
647
+ 'toLocaleUpperCase',
648
+ 'toLowerCase',
649
+ 'toString',
650
+ 'toUpperCase',
651
+ 'toWellFormed',
652
+ 'trim',
653
+ 'trimEnd',
654
+ 'trimStart',
655
+ 'valueOf',
656
+ ],
657
+ staticMethods: [
658
+ 'fromCharCode',
659
+ 'fromCodePoint',
660
+ 'raw',
661
+ ],
662
+ },
663
+ Symbol: {
664
+ globals: ['Symbol'],
665
+ instanceMethods: [
666
+ 'description',
667
+ 'toString',
668
+ 'valueOf',
669
+ ],
670
+ staticMethods: [
671
+ 'for',
672
+ 'keyFor',
673
+ ],
674
+ wellKnownSymbols: [
675
+ 'asyncIterator',
676
+ 'hasInstance',
677
+ 'isConcatSpreadable',
678
+ 'iterator',
679
+ 'match',
680
+ 'matchAll',
681
+ 'replace',
682
+ 'search',
683
+ 'species',
684
+ 'split',
685
+ 'toPrimitive',
686
+ 'toStringTag',
687
+ 'unscopables',
688
+ ],
689
+ },
690
+ SyntaxError: {
691
+ globals: ['SyntaxError'],
692
+ instanceMethods: [],
693
+ staticMethods: [],
694
+ },
695
+ TypedArray: {
696
+ globals: [
697
+ 'BigInt64Array',
698
+ 'BigUint64Array',
699
+ 'Float16Array',
700
+ 'Float32Array',
701
+ 'Float64Array',
702
+ 'Int8Array',
703
+ 'Int16Array',
704
+ 'Int32Array',
705
+ 'Uint8Array',
706
+ 'Uint8ClampedArray',
707
+ 'Uint16Array',
708
+ 'Uint32Array',
709
+ ],
710
+ instanceMethods: [
711
+ 'at',
712
+ 'copyWithin',
713
+ 'entries',
714
+ 'every',
715
+ 'fill',
716
+ 'filter',
717
+ 'find',
718
+ 'findIndex',
719
+ 'findLast',
720
+ 'findLastIndex',
721
+ 'forEach',
722
+ 'includes',
723
+ 'indexOf',
724
+ 'join',
725
+ 'keys',
726
+ 'lastIndexOf',
727
+ 'map',
728
+ 'reduce',
729
+ 'reduceRight',
730
+ 'reverse',
731
+ 'set',
732
+ 'slice',
733
+ 'some',
734
+ 'sort',
735
+ 'subarray',
736
+ 'toLocaleString',
737
+ 'toReversed',
738
+ 'toSorted',
739
+ 'toString',
740
+ 'values',
741
+ 'with',
742
+ ],
743
+ instanceProperties: [
744
+ 'buffer',
745
+ 'byteLength',
746
+ 'byteOffset',
747
+ 'length',
748
+ ],
749
+ staticMethods: [
750
+ 'from',
751
+ 'of',
752
+ ],
753
+ },
754
+ TypeError: {
755
+ globals: ['TypeError'],
756
+ instanceMethods: [],
757
+ staticMethods: [],
758
+ },
759
+ undefined: {
760
+ globals: ['undefined'],
761
+ instanceMethods: [],
762
+ staticMethods: [],
763
+ },
764
+ URIError: {
765
+ globals: ['URIError'],
766
+ instanceMethods: [],
767
+ staticMethods: [],
768
+ },
769
+ WeakMap: {
770
+ globals: ['WeakMap'],
771
+ instanceMethods: [
772
+ 'delete',
773
+ 'get',
774
+ 'has',
775
+ 'set',
776
+ ],
777
+ staticMethods: [],
778
+ },
779
+ WeakRef: {
780
+ globals: ['WeakRef'],
781
+ instanceMethods: ['deref'],
782
+ staticMethods: [],
783
+ },
784
+ WeakSet: {
785
+ globals: ['WeakSet'],
786
+ instanceMethods: [
787
+ 'add',
788
+ 'delete',
789
+ 'has',
790
+ ],
791
+ staticMethods: [],
792
+ },
793
+ };
794
+
795
+ // Build lookup maps for efficient querying
796
+ /** @type {Set<string>} */
797
+ export const allGlobals = new Set();
798
+ /** @type {Map<string, string[]>} methodName -> [categoryNames] */
799
+ export const allStaticMethods = new Map();
800
+ /** @type {Map<string, string[]>} methodName -> [categoryNames] */
801
+ export const allInstanceMethods = new Map();
802
+ /** @type {Map<string, string>} globalName -> categoryName */
803
+ export const globalToCategory = new Map();
804
+
805
+ for (const [category, info] of Object.entries(primordials)) {
806
+ for (const global of info.globals) {
807
+ allGlobals.add(global);
808
+ globalToCategory.set(global, category);
809
+ }
810
+
811
+ for (const method of info.staticMethods) {
812
+ if (!allStaticMethods.has(method)) {
813
+ allStaticMethods.set(method, []);
814
+ }
815
+ allStaticMethods.get(method)?.push(category);
816
+ }
817
+
818
+ for (const method of info.instanceMethods) {
819
+ if (!allInstanceMethods.has(method)) {
820
+ allInstanceMethods.set(method, []);
821
+ }
822
+ allInstanceMethods.get(method)?.push(category);
823
+ }
824
+ }
825
+
826
+ // TypedArray globals for type checking
827
+ export const typedArrayGlobals = new Set(primordials.TypedArray.globals);
828
+
829
+ // Methods that exist on multiple types and need type disambiguation
830
+ /** @type {Set<string>} */
831
+ export const ambiguousInstanceMethods = new Set();
832
+ for (const [method, categories] of allInstanceMethods) {
833
+ if (categories.length > 1) {
834
+ ambiguousInstanceMethods.add(method);
835
+ }
836
+ }