-
Notifications
You must be signed in to change notification settings - Fork 5
/
builtin.js
60 lines (53 loc) · 2.03 KB
/
builtin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* This preset includes types that are built-in into the JavaScript
language itself, this should work universally.
Types that were added in ES6 or beyond will be checked before inclusion
so that this module can be consumed by both ES5 and ES6 environments.
Some types cannot be encapsulated because their inner state is private:
`WeakMap`, `WeakSet`.
The Function type is not included because their closures would not be
serialized, so a revived Function that uses closures would not behave
as expected.
Symbols are similarly not included.
*/
import arrayNonindexKeys from './array-nonindex-keys.js';
import undef from '../types/undef.js';
import primitiveObjects from '../types/primitive-objects.js';
import specialNumbers from './special-numbers.js';
import date from '../types/date.js';
import error from '../types/error.js';
import errors from '../types/errors.js';
import regexp from '../types/regexp.js';
import map from '../types/map.js';
import set from '../types/set.js';
import arraybuffer from '../types/arraybuffer.js';
import typedArrays from '../types/typed-arrays.js';
import dataview from '../types/dataview.js';
import intlTypes from '../types/intl-types.js';
import bigint from '../types/bigint.js';
import bigintObject from '../types/bigint-object.js';
/**
* @type {import('typeson').Preset}
*/
const expObj = [
undef,
// ES5
arrayNonindexKeys, primitiveObjects, specialNumbers,
date, error, errors, regexp
].concat(
// ES2015 (ES6)
/* c8 ignore next */
typeof Map === 'function' ? map : [],
/* c8 ignore next */
typeof Set === 'function' ? set : [],
/* c8 ignore next */
typeof ArrayBuffer === 'function' ? arraybuffer : [],
/* c8 ignore next */
typeof Uint8Array === 'function' ? typedArrays : [],
/* c8 ignore next */
typeof DataView === 'function' ? dataview : [],
/* c8 ignore next */
typeof Intl !== 'undefined' ? intlTypes : [],
/* c8 ignore next */
typeof BigInt !== 'undefined' ? [bigint, bigintObject] : []
);
export default expObj;