UNPKG

5.39 kBJavaScriptView Raw
1import { StringPredicate } from './predicates/string.js';
2import { NumberPredicate } from './predicates/number.js';
3import { BigIntPredicate } from './predicates/bigint.js';
4import { BooleanPredicate } from './predicates/boolean.js';
5import { Predicate } from './predicates/predicate.js';
6import { ArrayPredicate } from './predicates/array.js';
7import { ObjectPredicate } from './predicates/object.js';
8import { DatePredicate } from './predicates/date.js';
9import { ErrorPredicate } from './predicates/error.js';
10import { MapPredicate } from './predicates/map.js';
11import { WeakMapPredicate } from './predicates/weak-map.js';
12import { SetPredicate } from './predicates/set.js';
13import { WeakSetPredicate } from './predicates/weak-set.js';
14import { TypedArrayPredicate } from './predicates/typed-array.js';
15import { ArrayBufferPredicate } from './predicates/array-buffer.js';
16import { DataViewPredicate } from './predicates/data-view.js';
17import { AnyPredicate } from './predicates/any.js';
18const predicates = (object, options) => {
19 Object.defineProperties(object, {
20 string: {
21 get: () => new StringPredicate(options),
22 },
23 number: {
24 get: () => new NumberPredicate(options),
25 },
26 bigint: {
27 get: () => new BigIntPredicate(options),
28 },
29 boolean: {
30 get: () => new BooleanPredicate(options),
31 },
32 undefined: {
33 get: () => new Predicate('undefined', options),
34 },
35 null: {
36 get: () => new Predicate('null', options),
37 },
38 nullOrUndefined: {
39 get: () => new Predicate('nullOrUndefined', options),
40 },
41 nan: {
42 get: () => new Predicate('nan', options),
43 },
44 symbol: {
45 get: () => new Predicate('symbol', options),
46 },
47 array: {
48 get: () => new ArrayPredicate(options),
49 },
50 object: {
51 get: () => new ObjectPredicate(options),
52 },
53 date: {
54 get: () => new DatePredicate(options),
55 },
56 error: {
57 get: () => new ErrorPredicate(options),
58 },
59 map: {
60 get: () => new MapPredicate(options),
61 },
62 weakMap: {
63 get: () => new WeakMapPredicate(options),
64 },
65 set: {
66 get: () => new SetPredicate(options),
67 },
68 weakSet: {
69 get: () => new WeakSetPredicate(options),
70 },
71 function: {
72 get: () => new Predicate('Function', options),
73 },
74 buffer: {
75 get: () => new Predicate('Buffer', options),
76 },
77 regExp: {
78 get: () => new Predicate('RegExp', options),
79 },
80 promise: {
81 get: () => new Predicate('Promise', options),
82 },
83 typedArray: {
84 get: () => new TypedArrayPredicate('TypedArray', options),
85 },
86 int8Array: {
87 get: () => new TypedArrayPredicate('Int8Array', options),
88 },
89 uint8Array: {
90 get: () => new TypedArrayPredicate('Uint8Array', options),
91 },
92 uint8ClampedArray: {
93 get: () => new TypedArrayPredicate('Uint8ClampedArray', options),
94 },
95 int16Array: {
96 get: () => new TypedArrayPredicate('Int16Array', options),
97 },
98 uint16Array: {
99 get: () => new TypedArrayPredicate('Uint16Array', options),
100 },
101 int32Array: {
102 get: () => new TypedArrayPredicate('Int32Array', options),
103 },
104 uint32Array: {
105 get: () => new TypedArrayPredicate('Uint32Array', options),
106 },
107 float32Array: {
108 get: () => new TypedArrayPredicate('Float32Array', options),
109 },
110 float64Array: {
111 get: () => new TypedArrayPredicate('Float64Array', options),
112 },
113 arrayBuffer: {
114 get: () => new ArrayBufferPredicate('ArrayBuffer', options),
115 },
116 sharedArrayBuffer: {
117 get: () => new ArrayBufferPredicate('SharedArrayBuffer', options),
118 },
119 dataView: {
120 get: () => new DataViewPredicate(options),
121 },
122 iterable: {
123 get: () => new Predicate('Iterable', options),
124 },
125 any: {
126 value: (...predicates) => new AnyPredicate(predicates, options),
127 },
128 });
129 return object;
130};
131export default predicates;
132export { ObjectPredicate } from './predicates/object.js';
133export { StringPredicate } from './predicates/string.js';
134export { NumberPredicate } from './predicates/number.js';
135export { BigIntPredicate } from './predicates/bigint.js';
136export { BooleanPredicate } from './predicates/boolean.js';
137export { ArrayPredicate } from './predicates/array.js';
138export { DatePredicate } from './predicates/date.js';
139export { ErrorPredicate } from './predicates/error.js';
140export { MapPredicate } from './predicates/map.js';
141export { WeakMapPredicate } from './predicates/weak-map.js';
142export { SetPredicate } from './predicates/set.js';
143export { WeakSetPredicate } from './predicates/weak-set.js';
144export { TypedArrayPredicate } from './predicates/typed-array.js';
145export { ArrayBufferPredicate } from './predicates/array-buffer.js';
146export { DataViewPredicate } from './predicates/data-view.js';
147export { AnyPredicate } from './predicates/any.js';