is-what 4.1.0 → 4.1.4
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/README.md +3 -0
- package/dist/index.cjs +382 -0
- package/dist/{index.js → index.es.js} +0 -0
- package/{types → dist/types}/index.d.ts +0 -0
- package/package.json +38 -33
- package/.babelrc +0 -3
- package/.eslintignore +0 -9
- package/.github/FUNDING.yml +0 -12
- package/.prettierrc +0 -9
- package/.vscode/settings.json +0 -9
- package/build.js +0 -40
- package/src/index.ts +0 -415
- package/test/ava.ts +0 -419
- package/tsconfig.json +0 -15
package/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# is What? 🙉
|
2
2
|
|
3
|
+
<a href="https://www.npmjs.com/package/is-what"><img src="https://img.shields.io/npm/v/is-what.svg" alt="Total Downloads"></a>
|
4
|
+
<a href="https://www.npmjs.com/package/is-what"><img src="https://img.shields.io/npm/dw/is-what.svg" alt="Latest Stable Version"></a>
|
5
|
+
|
3
6
|
Very simple & small JS type check functions. It's fully TypeScript supported!
|
4
7
|
|
5
8
|
```
|
package/dist/index.cjs
ADDED
@@ -0,0 +1,382 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Returns the object type of the given payload
|
7
|
+
*
|
8
|
+
* @param {*} payload
|
9
|
+
* @returns {string}
|
10
|
+
*/
|
11
|
+
function getType(payload) {
|
12
|
+
return Object.prototype.toString.call(payload).slice(8, -1);
|
13
|
+
}
|
14
|
+
/**
|
15
|
+
* Returns whether the payload is undefined
|
16
|
+
*
|
17
|
+
* @param {*} payload
|
18
|
+
* @returns {payload is undefined}
|
19
|
+
*/
|
20
|
+
function isUndefined(payload) {
|
21
|
+
return getType(payload) === 'Undefined';
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* Returns whether the payload is null
|
25
|
+
*
|
26
|
+
* @param {*} payload
|
27
|
+
* @returns {payload is null}
|
28
|
+
*/
|
29
|
+
function isNull(payload) {
|
30
|
+
return getType(payload) === 'Null';
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
|
34
|
+
*
|
35
|
+
* @param {*} payload
|
36
|
+
* @returns {payload is PlainObject}
|
37
|
+
*/
|
38
|
+
function isPlainObject(payload) {
|
39
|
+
if (getType(payload) !== 'Object')
|
40
|
+
return false;
|
41
|
+
return payload.constructor === Object && Object.getPrototypeOf(payload) === Object.prototype;
|
42
|
+
}
|
43
|
+
/**
|
44
|
+
* Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
|
45
|
+
*
|
46
|
+
* @param {*} payload
|
47
|
+
* @returns {payload is PlainObject}
|
48
|
+
*/
|
49
|
+
function isObject(payload) {
|
50
|
+
return isPlainObject(payload);
|
51
|
+
}
|
52
|
+
/**
|
53
|
+
* Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
|
54
|
+
*
|
55
|
+
* @param {*} payload
|
56
|
+
* @returns {payload is { [K in any]: never }}
|
57
|
+
*/
|
58
|
+
function isEmptyObject(payload) {
|
59
|
+
return isPlainObject(payload) && Object.keys(payload).length === 0;
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
|
63
|
+
*
|
64
|
+
* @param {*} payload
|
65
|
+
* @returns {payload is PlainObject}
|
66
|
+
*/
|
67
|
+
function isFullObject(payload) {
|
68
|
+
return isPlainObject(payload) && Object.keys(payload).length > 0;
|
69
|
+
}
|
70
|
+
/**
|
71
|
+
* Returns whether the payload is an any kind of object (including special classes or objects with different prototypes)
|
72
|
+
*
|
73
|
+
* @param {*} payload
|
74
|
+
* @returns {payload is PlainObject}
|
75
|
+
*/
|
76
|
+
function isAnyObject(payload) {
|
77
|
+
return getType(payload) === 'Object';
|
78
|
+
}
|
79
|
+
/**
|
80
|
+
* Returns whether the payload is an object like a type passed in < >
|
81
|
+
*
|
82
|
+
* Usage: isObjectLike<{id: any}>(payload) // will make sure it's an object and has an `id` prop.
|
83
|
+
*
|
84
|
+
* @template T this must be passed in < >
|
85
|
+
* @param {*} payload
|
86
|
+
* @returns {payload is T}
|
87
|
+
*/
|
88
|
+
function isObjectLike(payload) {
|
89
|
+
return isAnyObject(payload);
|
90
|
+
}
|
91
|
+
/**
|
92
|
+
* Returns whether the payload is a function (regular or async)
|
93
|
+
*
|
94
|
+
* @param {*} payload
|
95
|
+
* @returns {payload is AnyFunction}
|
96
|
+
*/
|
97
|
+
function isFunction(payload) {
|
98
|
+
return typeof payload === 'function';
|
99
|
+
}
|
100
|
+
/**
|
101
|
+
* Returns whether the payload is an array
|
102
|
+
*
|
103
|
+
* @param {any} payload
|
104
|
+
* @returns {payload is any[]}
|
105
|
+
*/
|
106
|
+
function isArray(payload) {
|
107
|
+
return getType(payload) === 'Array';
|
108
|
+
}
|
109
|
+
/**
|
110
|
+
* Returns whether the payload is a an array with at least 1 item
|
111
|
+
*
|
112
|
+
* @param {*} payload
|
113
|
+
* @returns {payload is any[]}
|
114
|
+
*/
|
115
|
+
function isFullArray(payload) {
|
116
|
+
return isArray(payload) && payload.length > 0;
|
117
|
+
}
|
118
|
+
/**
|
119
|
+
* Returns whether the payload is a an empty array
|
120
|
+
*
|
121
|
+
* @param {*} payload
|
122
|
+
* @returns {payload is []}
|
123
|
+
*/
|
124
|
+
function isEmptyArray(payload) {
|
125
|
+
return isArray(payload) && payload.length === 0;
|
126
|
+
}
|
127
|
+
/**
|
128
|
+
* Returns whether the payload is a string
|
129
|
+
*
|
130
|
+
* @param {*} payload
|
131
|
+
* @returns {payload is string}
|
132
|
+
*/
|
133
|
+
function isString(payload) {
|
134
|
+
return getType(payload) === 'String';
|
135
|
+
}
|
136
|
+
/**
|
137
|
+
* Returns whether the payload is a string, BUT returns false for ''
|
138
|
+
*
|
139
|
+
* @param {*} payload
|
140
|
+
* @returns {payload is string}
|
141
|
+
*/
|
142
|
+
function isFullString(payload) {
|
143
|
+
return isString(payload) && payload !== '';
|
144
|
+
}
|
145
|
+
/**
|
146
|
+
* Returns whether the payload is ''
|
147
|
+
*
|
148
|
+
* @param {*} payload
|
149
|
+
* @returns {payload is string}
|
150
|
+
*/
|
151
|
+
function isEmptyString(payload) {
|
152
|
+
return payload === '';
|
153
|
+
}
|
154
|
+
/**
|
155
|
+
* Returns whether the payload is a number (but not NaN)
|
156
|
+
*
|
157
|
+
* This will return `false` for `NaN`!!
|
158
|
+
*
|
159
|
+
* @param {*} payload
|
160
|
+
* @returns {payload is number}
|
161
|
+
*/
|
162
|
+
function isNumber(payload) {
|
163
|
+
return getType(payload) === 'Number' && !isNaN(payload);
|
164
|
+
}
|
165
|
+
/**
|
166
|
+
* Returns whether the payload is a positive number (but not 0)
|
167
|
+
*
|
168
|
+
* @param {*} payload
|
169
|
+
* @returns {payload is number}
|
170
|
+
*/
|
171
|
+
function isPositiveNumber(payload) {
|
172
|
+
return isNumber(payload) && payload > 0;
|
173
|
+
}
|
174
|
+
/**
|
175
|
+
* Returns whether the payload is a negative number (but not 0)
|
176
|
+
*
|
177
|
+
* @param {*} payload
|
178
|
+
* @returns {payload is number}
|
179
|
+
*/
|
180
|
+
function isNegativeNumber(payload) {
|
181
|
+
return isNumber(payload) && payload < 0;
|
182
|
+
}
|
183
|
+
/**
|
184
|
+
* Returns whether the payload is a boolean
|
185
|
+
*
|
186
|
+
* @param {*} payload
|
187
|
+
* @returns {payload is boolean}
|
188
|
+
*/
|
189
|
+
function isBoolean(payload) {
|
190
|
+
return getType(payload) === 'Boolean';
|
191
|
+
}
|
192
|
+
/**
|
193
|
+
* Returns whether the payload is a regular expression (RegExp)
|
194
|
+
*
|
195
|
+
* @param {*} payload
|
196
|
+
* @returns {payload is RegExp}
|
197
|
+
*/
|
198
|
+
function isRegExp(payload) {
|
199
|
+
return getType(payload) === 'RegExp';
|
200
|
+
}
|
201
|
+
/**
|
202
|
+
* Returns whether the payload is a Map
|
203
|
+
*
|
204
|
+
* @param {*} payload
|
205
|
+
* @returns {payload is Map<any, any>}
|
206
|
+
*/
|
207
|
+
function isMap(payload) {
|
208
|
+
return getType(payload) === 'Map';
|
209
|
+
}
|
210
|
+
/**
|
211
|
+
* Returns whether the payload is a WeakMap
|
212
|
+
*
|
213
|
+
* @param {*} payload
|
214
|
+
* @returns {payload is WeakMap<any, any>}
|
215
|
+
*/
|
216
|
+
function isWeakMap(payload) {
|
217
|
+
return getType(payload) === 'WeakMap';
|
218
|
+
}
|
219
|
+
/**
|
220
|
+
* Returns whether the payload is a Set
|
221
|
+
*
|
222
|
+
* @param {*} payload
|
223
|
+
* @returns {payload is Set<any>}
|
224
|
+
*/
|
225
|
+
function isSet(payload) {
|
226
|
+
return getType(payload) === 'Set';
|
227
|
+
}
|
228
|
+
/**
|
229
|
+
* Returns whether the payload is a WeakSet
|
230
|
+
*
|
231
|
+
* @param {*} payload
|
232
|
+
* @returns {payload is WeakSet<any>}
|
233
|
+
*/
|
234
|
+
function isWeakSet(payload) {
|
235
|
+
return getType(payload) === 'WeakSet';
|
236
|
+
}
|
237
|
+
/**
|
238
|
+
* Returns whether the payload is a Symbol
|
239
|
+
*
|
240
|
+
* @param {*} payload
|
241
|
+
* @returns {payload is symbol}
|
242
|
+
*/
|
243
|
+
function isSymbol(payload) {
|
244
|
+
return getType(payload) === 'Symbol';
|
245
|
+
}
|
246
|
+
/**
|
247
|
+
* Returns whether the payload is a Date, and that the date is valid
|
248
|
+
*
|
249
|
+
* @param {*} payload
|
250
|
+
* @returns {payload is Date}
|
251
|
+
*/
|
252
|
+
function isDate(payload) {
|
253
|
+
return getType(payload) === 'Date' && !isNaN(payload);
|
254
|
+
}
|
255
|
+
/**
|
256
|
+
* Returns whether the payload is a Blob
|
257
|
+
*
|
258
|
+
* @param {*} payload
|
259
|
+
* @returns {payload is Blob}
|
260
|
+
*/
|
261
|
+
function isBlob(payload) {
|
262
|
+
return getType(payload) === 'Blob';
|
263
|
+
}
|
264
|
+
/**
|
265
|
+
* Returns whether the payload is a File
|
266
|
+
*
|
267
|
+
* @param {*} payload
|
268
|
+
* @returns {payload is File}
|
269
|
+
*/
|
270
|
+
function isFile(payload) {
|
271
|
+
return getType(payload) === 'File';
|
272
|
+
}
|
273
|
+
/**
|
274
|
+
* Returns whether the payload is a Promise
|
275
|
+
*
|
276
|
+
* @param {*} payload
|
277
|
+
* @returns {payload is Promise<any>}
|
278
|
+
*/
|
279
|
+
function isPromise(payload) {
|
280
|
+
return getType(payload) === 'Promise';
|
281
|
+
}
|
282
|
+
/**
|
283
|
+
* Returns whether the payload is an Error
|
284
|
+
*
|
285
|
+
* @param {*} payload
|
286
|
+
* @returns {payload is Error}
|
287
|
+
*/
|
288
|
+
function isError(payload) {
|
289
|
+
return getType(payload) === 'Error';
|
290
|
+
}
|
291
|
+
/**
|
292
|
+
* Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`)
|
293
|
+
*
|
294
|
+
* @param {*} payload
|
295
|
+
* @returns {payload is typeof NaN}
|
296
|
+
*/
|
297
|
+
function isNaNValue(payload) {
|
298
|
+
return getType(payload) === 'Number' && isNaN(payload);
|
299
|
+
}
|
300
|
+
/**
|
301
|
+
* Returns whether the payload is a primitive type (eg. Boolean | Null | Undefined | Number | String | Symbol)
|
302
|
+
*
|
303
|
+
* @param {*} payload
|
304
|
+
* @returns {(payload is boolean | null | undefined | number | string | symbol)}
|
305
|
+
*/
|
306
|
+
function isPrimitive(payload) {
|
307
|
+
return (isBoolean(payload) ||
|
308
|
+
isNull(payload) ||
|
309
|
+
isUndefined(payload) ||
|
310
|
+
isNumber(payload) ||
|
311
|
+
isString(payload) ||
|
312
|
+
isSymbol(payload));
|
313
|
+
}
|
314
|
+
/**
|
315
|
+
* Returns true whether the payload is null or undefined
|
316
|
+
*
|
317
|
+
* @param {*} payload
|
318
|
+
* @returns {(payload is null | undefined)}
|
319
|
+
*/
|
320
|
+
const isNullOrUndefined = isOneOf(isNull, isUndefined);
|
321
|
+
function isOneOf(a, b, c, d, e) {
|
322
|
+
return (value) => a(value) || b(value) || (!!c && c(value)) || (!!d && d(value)) || (!!e && e(value));
|
323
|
+
}
|
324
|
+
/**
|
325
|
+
* Does a generic check to check that the given payload is of a given type.
|
326
|
+
* In cases like Number, it will return true for NaN as NaN is a Number (thanks javascript!);
|
327
|
+
* It will, however, differentiate between object and null
|
328
|
+
*
|
329
|
+
* @template T
|
330
|
+
* @param {*} payload
|
331
|
+
* @param {T} type
|
332
|
+
* @throws {TypeError} Will throw type error if type is an invalid type
|
333
|
+
* @returns {payload is T}
|
334
|
+
*/
|
335
|
+
function isType(payload, type) {
|
336
|
+
if (!(type instanceof Function)) {
|
337
|
+
throw new TypeError('Type must be a function');
|
338
|
+
}
|
339
|
+
if (!Object.prototype.hasOwnProperty.call(type, 'prototype')) {
|
340
|
+
throw new TypeError('Type is not a class');
|
341
|
+
}
|
342
|
+
// Classes usually have names (as functions usually have names)
|
343
|
+
const name = type.name;
|
344
|
+
return getType(payload) === name || Boolean(payload && payload.constructor === type);
|
345
|
+
}
|
346
|
+
|
347
|
+
exports.getType = getType;
|
348
|
+
exports.isAnyObject = isAnyObject;
|
349
|
+
exports.isArray = isArray;
|
350
|
+
exports.isBlob = isBlob;
|
351
|
+
exports.isBoolean = isBoolean;
|
352
|
+
exports.isDate = isDate;
|
353
|
+
exports.isEmptyArray = isEmptyArray;
|
354
|
+
exports.isEmptyObject = isEmptyObject;
|
355
|
+
exports.isEmptyString = isEmptyString;
|
356
|
+
exports.isError = isError;
|
357
|
+
exports.isFile = isFile;
|
358
|
+
exports.isFullArray = isFullArray;
|
359
|
+
exports.isFullObject = isFullObject;
|
360
|
+
exports.isFullString = isFullString;
|
361
|
+
exports.isFunction = isFunction;
|
362
|
+
exports.isMap = isMap;
|
363
|
+
exports.isNaNValue = isNaNValue;
|
364
|
+
exports.isNegativeNumber = isNegativeNumber;
|
365
|
+
exports.isNull = isNull;
|
366
|
+
exports.isNullOrUndefined = isNullOrUndefined;
|
367
|
+
exports.isNumber = isNumber;
|
368
|
+
exports.isObject = isObject;
|
369
|
+
exports.isObjectLike = isObjectLike;
|
370
|
+
exports.isOneOf = isOneOf;
|
371
|
+
exports.isPlainObject = isPlainObject;
|
372
|
+
exports.isPositiveNumber = isPositiveNumber;
|
373
|
+
exports.isPrimitive = isPrimitive;
|
374
|
+
exports.isPromise = isPromise;
|
375
|
+
exports.isRegExp = isRegExp;
|
376
|
+
exports.isSet = isSet;
|
377
|
+
exports.isString = isString;
|
378
|
+
exports.isSymbol = isSymbol;
|
379
|
+
exports.isType = isType;
|
380
|
+
exports.isUndefined = isUndefined;
|
381
|
+
exports.isWeakMap = isWeakMap;
|
382
|
+
exports.isWeakSet = isWeakSet;
|
File without changes
|
File without changes
|
package/package.json
CHANGED
@@ -1,17 +1,26 @@
|
|
1
1
|
{
|
2
2
|
"name": "is-what",
|
3
3
|
"sideEffects": false,
|
4
|
-
"version": "4.1.
|
4
|
+
"version": "4.1.4",
|
5
5
|
"description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.",
|
6
|
-
"
|
7
|
-
"
|
8
|
-
"types": "./types/index.d.ts",
|
6
|
+
"module": "./dist/index.es.js",
|
7
|
+
"main": "./dist/index.cjs",
|
8
|
+
"types": "./dist/types/index.d.ts",
|
9
|
+
"exports": {
|
10
|
+
".": {
|
11
|
+
"import": "./dist/index.es.js",
|
12
|
+
"require": "./dist/index.cjs",
|
13
|
+
"types": "./dist/types/index.d.ts"
|
14
|
+
}
|
15
|
+
},
|
16
|
+
"files": [
|
17
|
+
"dist"
|
18
|
+
],
|
9
19
|
"scripts": {
|
10
|
-
"test": "
|
11
|
-
"lint": "tsc --noEmit
|
12
|
-
"
|
13
|
-
"
|
14
|
-
"release": "npm run build && np"
|
20
|
+
"test": "vitest run",
|
21
|
+
"lint": "tsc --noEmit && eslint ./src --ext .ts",
|
22
|
+
"build": "rollup -c ./scripts/build.js",
|
23
|
+
"release": "npm run lint && del dist && npm run build && np"
|
15
24
|
},
|
16
25
|
"repository": {
|
17
26
|
"type": "git",
|
@@ -39,41 +48,30 @@
|
|
39
48
|
"is-plain-object"
|
40
49
|
],
|
41
50
|
"author": "Luca Ban - Mesqueeb",
|
51
|
+
"funding": "https://github.com/sponsors/mesqueeb",
|
42
52
|
"license": "MIT",
|
43
53
|
"bugs": {
|
44
54
|
"url": "https://github.com/mesqueeb/is-what/issues"
|
45
55
|
},
|
46
56
|
"homepage": "https://github.com/mesqueeb/is-what#readme",
|
47
57
|
"devDependencies": {
|
48
|
-
"@
|
49
|
-
"@
|
50
|
-
"
|
51
|
-
"
|
52
|
-
"ava": "^3.15.0",
|
53
|
-
"babel-core": "^7.0.0-bridge.0",
|
54
|
-
"babel-preset-env": "^1.7.0",
|
55
|
-
"eslint": "^8.0.1",
|
58
|
+
"@typescript-eslint/eslint-plugin": "^5.10.1",
|
59
|
+
"@typescript-eslint/parser": "^5.10.1",
|
60
|
+
"del-cli": "^4.0.1",
|
61
|
+
"eslint": "^8.7.0",
|
56
62
|
"eslint-config-prettier": "^8.3.0",
|
57
|
-
"eslint-plugin-tree-shaking": "^1.
|
58
|
-
"np": "^7.
|
59
|
-
"prettier": "^2.
|
60
|
-
"
|
61
|
-
"rollup": "^
|
62
|
-
"
|
63
|
-
"
|
64
|
-
"typescript": "^4.4.4"
|
65
|
-
},
|
66
|
-
"engines": {
|
67
|
-
"node": ">=12.13",
|
68
|
-
"npm": ">=7"
|
63
|
+
"eslint-plugin-tree-shaking": "^1.10.0",
|
64
|
+
"np": "^7.6.0",
|
65
|
+
"prettier": "^2.5.1",
|
66
|
+
"rollup": "^2.66.0",
|
67
|
+
"rollup-plugin-typescript2": "^0.31.1",
|
68
|
+
"typescript": "^4.5.5",
|
69
|
+
"vitest": "^0.2.1"
|
69
70
|
},
|
70
71
|
"ava": {
|
71
72
|
"extensions": {
|
72
73
|
"ts": "module"
|
73
74
|
},
|
74
|
-
"nonSemVerExperiments": {
|
75
|
-
"configurableModuleFormat": true
|
76
|
-
},
|
77
75
|
"nodeArguments": [
|
78
76
|
"--loader=ts-node/esm"
|
79
77
|
]
|
@@ -83,6 +81,12 @@
|
|
83
81
|
"branch": "production"
|
84
82
|
},
|
85
83
|
"eslintConfig": {
|
84
|
+
"ignorePatterns": [
|
85
|
+
"node_modules",
|
86
|
+
"dist",
|
87
|
+
"scripts",
|
88
|
+
"test"
|
89
|
+
],
|
86
90
|
"root": true,
|
87
91
|
"parser": "@typescript-eslint/parser",
|
88
92
|
"plugins": [
|
@@ -96,10 +100,11 @@
|
|
96
100
|
"prettier"
|
97
101
|
],
|
98
102
|
"rules": {
|
103
|
+
"@typescript-eslint/no-empty-function": "off",
|
99
104
|
"@typescript-eslint/no-explicit-any": "off",
|
100
105
|
"@typescript-eslint/ban-ts-ignore": "off",
|
101
106
|
"tree-shaking/no-side-effects-in-initialization": "error",
|
102
|
-
"@typescript-eslint/
|
107
|
+
"@typescript-eslint/ban-ts-comment": "off"
|
103
108
|
}
|
104
109
|
}
|
105
110
|
}
|
package/.babelrc
DELETED
package/.eslintignore
DELETED
package/.github/FUNDING.yml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# These are supported funding model platforms
|
2
|
-
|
3
|
-
github: mesqueeb
|
4
|
-
patreon: # Replace with a single Patreon username
|
5
|
-
open_collective: # Replace with a single Open Collective username
|
6
|
-
ko_fi: # Replace with a single Ko-fi username
|
7
|
-
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
8
|
-
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
9
|
-
liberapay: # Replace with a single Liberapay username
|
10
|
-
issuehunt: # Replace with a single IssueHunt username
|
11
|
-
otechie: # Replace with a single Otechie username
|
12
|
-
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
package/.prettierrc
DELETED
package/.vscode/settings.json
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"editor.formatOnSave": true,
|
3
|
-
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
4
|
-
"editor.tabSize": 2, // make sure this is the same as .prettierrc
|
5
|
-
"editor.insertSpaces": true,
|
6
|
-
"files.insertFinalNewline": true,
|
7
|
-
"files.trimFinalNewlines": true,
|
8
|
-
"files.trimTrailingWhitespace": true
|
9
|
-
}
|
package/build.js
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
/* eslint-disable */
|
2
|
-
|
3
|
-
// npm i -D rollup rollup-plugin-typescript2 typescript
|
4
|
-
import typescript from 'rollup-plugin-typescript2'
|
5
|
-
|
6
|
-
// ------------------------------------------------------------------------------------------
|
7
|
-
// formats
|
8
|
-
// ------------------------------------------------------------------------------------------
|
9
|
-
// amd – Asynchronous Module Definition, used with module loaders like RequireJS
|
10
|
-
// cjs – CommonJS, suitable for Node and Browserify/Webpack
|
11
|
-
// esm – Keep the bundle as an ES module file
|
12
|
-
// iife – A self-executing function, suitable for inclusion as a <script> tag. (If you want to create a bundle for your application, you probably want to use this, because it leads to smaller file sizes.)
|
13
|
-
// umd – Universal Module Definition, works as amd, cjs and iife all in one
|
14
|
-
// system – Native format of the SystemJS loader
|
15
|
-
|
16
|
-
// ------------------------------------------------------------------------------------------
|
17
|
-
// setup
|
18
|
-
// ------------------------------------------------------------------------------------------
|
19
|
-
const pkg = require('./package.json')
|
20
|
-
const name = pkg.name
|
21
|
-
const className = name.replace(/(^\w|-\w)/g, (c) => c.replace('-', '').toUpperCase())
|
22
|
-
|
23
|
-
export default [
|
24
|
-
{
|
25
|
-
input: 'src/index.ts',
|
26
|
-
output: [
|
27
|
-
{
|
28
|
-
file: 'dist/index.js',
|
29
|
-
format: 'esm',
|
30
|
-
sourcemap: false,
|
31
|
-
name: className,
|
32
|
-
exports: 'named',
|
33
|
-
},
|
34
|
-
],
|
35
|
-
plugins: [
|
36
|
-
typescript({ useTsconfigDeclarationDir: true, tsconfigOverride: { exclude: ['test/**/*'] } }),
|
37
|
-
],
|
38
|
-
external: Object.keys(pkg.dependencies || []),
|
39
|
-
},
|
40
|
-
]
|