is-what 3.14.0 → 4.1.1

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 CHANGED
@@ -1,6 +1,9 @@
1
1
  # is What? 🙉
2
2
 
3
- Very simple & small JS type check functions. It's fully TypeScript supported!
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
+
6
+ Very simple & small JS type check functions. It's fully TypeScript supported!
4
7
 
5
8
  ```
6
9
  npm i is-what
@@ -13,6 +16,7 @@ Or for deno available at: `"deno.land/x/is_what"`
13
16
  I built is-what because the existing solutions were all too complex or too poorly built.
14
17
 
15
18
  I was looking for:
19
+
16
20
  - A simple way to check any kind of type (including non-primitives)
17
21
  - Be able to check if an object is a plain object `{}` or a special object (like a class instance) ‼️
18
22
  - Let TypeScript automatically know what type a value is when checking
@@ -35,6 +39,12 @@ import { isString, isDate, isPlainObject } from 'is-what'
35
39
  ### Simple type check functions
36
40
 
37
41
  ```js
42
+ // basics
43
+ isBoolean(true) // true
44
+ isBoolean(false) // true
45
+ isUndefined(undefined) // true
46
+ isNull(null) // true
47
+
38
48
  // strings
39
49
  isString('') // true
40
50
  isEmptyString('') // true
@@ -42,38 +52,86 @@ isFullString('') // false
42
52
 
43
53
  // numbers
44
54
  isNumber(0) // true
45
- isNumber(NaN) // false
55
+ isNumber('0') // false
56
+ isNumber(NaN) // false *
57
+ isPositiveNumber(1) // true
58
+ isNegativeNumber(-1) // true
59
+ // * see below for special NaN use cases!
60
+
61
+ // arrays
62
+ isArray([]) // true
63
+ isEmptyArray([]) // true
64
+ isFullArray([1]) // true
65
+
66
+ // objects
67
+ isPlainObject({}) // true *
68
+ isEmptyObject({}) // true
69
+ isFullObject({ a: 1 }) // true
70
+ // * see below for special object (& class instance) use cases!
71
+
72
+ // functions
73
+ isFunction(function () {}) // true
74
+ isFunction(() => {}) // true
46
75
 
47
76
  // dates
48
77
  isDate(new Date()) // true
49
78
  isDate(new Date('invalid date')) // false
50
79
 
80
+ // maps & sets
81
+ isMap(new Map()) // true
82
+ isSet(new Set()) // true
83
+ isWeakMap(new WeakMap()) // true
84
+ isWeakSet(new WeakSet()) // true
85
+
51
86
  // others
52
- isBoolean(false) // true
53
- isFunction(function () {}) // true
54
- isArray([]) // true
55
- isUndefined(undefined) // true
56
- isNull(null) // true
57
87
  isRegExp(/\s/gi) // true
58
88
  isSymbol(Symbol()) // true
59
89
  isBlob(new Blob()) // true
60
90
  isFile(new File([''], '', { type: 'text/html' })) // true
91
+ isError(new Error('')) // true
92
+ isPromise(new Promise((resolve) => {})) // true
61
93
 
62
94
  // primitives
63
95
  isPrimitive('') // true
64
96
  // true for any of: boolean, null, undefined, number, string, symbol
65
97
  ```
66
98
 
67
- ### Getting and checking for specific types
99
+ ### Let's talk about NaN
68
100
 
69
- You can check for specific types with `getType` and `isType`:
101
+ `isNaN` is a built-in JS Function but it really makes no sense:
70
102
 
71
103
  ```js
72
- import { getType, isType } from 'is-what'
104
+ // 1)
105
+ typeof NaN === 'number' // true
106
+ // 🤔 ("not a number" is a "number"...)
73
107
 
74
- getType('') // returns 'String'
75
- // pass a Type as second param:
76
- isType('', String) // returns true
108
+ // 2)
109
+ isNaN('1') // false
110
+ // 🤔 the string '1' is not-"not a number"... so it's a number??
111
+
112
+ // 3)
113
+ isNaN('one') // true
114
+ // 🤔 'one' is NaN but `NaN === 'one'` is false...
115
+ ```
116
+
117
+ With is-what the way we treat NaN makes a little bit more sense:
118
+
119
+ ```js
120
+ import { isNumber, isNaNValue } from 'is-what'
121
+
122
+ // 1)
123
+ isNumber(NaN) // false!
124
+ // let's not treat NaN as a number
125
+
126
+ // 2)
127
+ isNaNValue('1') // false
128
+ // if it's not NaN, it's not NaN!!
129
+
130
+ // 3)
131
+ isNaNValue('one') // false
132
+ // if it's not NaN, it's not NaN!!
133
+
134
+ isNaNValue(NaN) // true
77
135
  ```
78
136
 
79
137
  ### isPlainObject vs isAnyObject
@@ -85,11 +143,11 @@ Checking for a JavaScript object can be really difficult. In JavaScript you can
85
143
 
86
144
  ```js
87
145
  // define a plain object
88
- const plainObject = {hello: 'I am a good old object.'}
146
+ const plainObject = { hello: 'I am a good old object.' }
89
147
 
90
148
  // define a special object
91
149
  class SpecialObject {
92
- constructor (somethingSpecial) {
150
+ constructor(somethingSpecial) {
93
151
  this.speciality = somethingSpecial
94
152
  }
95
153
  }
@@ -108,18 +166,30 @@ getType(specialObject) // returns 'Object'
108
166
 
109
167
  > Please note that `isPlainObject` will only return `true` for normal plain JavaScript objects.
110
168
 
169
+ ### Getting and checking for specific types
170
+
171
+ You can check for specific types with `getType` and `isType`:
172
+
173
+ ```js
174
+ import { getType, isType } from 'is-what'
175
+
176
+ getType('') // returns 'String'
177
+ // pass a Type as second param:
178
+ isType('', String) // returns true
179
+ ```
180
+
111
181
  ## TypeScript
112
182
 
113
183
  is-what makes TypeScript know the type during if statements. This means that a check returns the type of the payload for TypeScript users.
114
184
 
115
185
  ```ts
116
- function isNumber (payload: any): payload is number {
186
+ function isNumber(payload: any): payload is number {
117
187
  // return boolean
118
188
  }
119
189
  // As you can see above, all functions return a boolean for JavaScript, but pass the payload type to TypeScript.
120
190
 
121
191
  // usage example:
122
- function fn (payload: string | number): number {
192
+ function fn(payload: string | number): number {
123
193
  if (isNumber(payload)) {
124
194
  // ↑ TypeScript already knows payload is a number here!
125
195
  return payload
@@ -131,8 +201,8 @@ function fn (payload: string | number): number {
131
201
  `isPlainObject` and `isAnyObject` with TypeScript will declare the payload to be an object type with any props:
132
202
 
133
203
  ```ts
134
- function isPlainObject (payload: any): payload is {[key: string]: any}
135
- function isAnyObject (payload: any): payload is {[key: string]: any}
204
+ function isPlainObject(payload: any): payload is { [key: string]: any }
205
+ function isAnyObject(payload: any): payload is { [key: string]: any }
136
206
  // The reason to return `{[key: string]: any}` is to be able to do
137
207
  if (isPlainObject(payload) && payload.id) return payload.id
138
208
  // if isPlainObject() would return `payload is object` then it would give an error at `payload.id`
@@ -140,20 +210,34 @@ if (isPlainObject(payload) && payload.id) return payload.id
140
210
 
141
211
  ### isObjectLike
142
212
 
143
- If you want more control over which kind of objects are allowed you can use `isObjectLike<T>`:
213
+ If you want more control over what kind of interface/type is casted when checking for objects.
214
+
215
+ To cast to a specific type while checking for `isAnyObject`, can use `isObjectLike<T>`:
144
216
 
145
217
  ```ts
146
218
  import { isObjectLike } from 'is-what'
147
- // usage examples:
148
- isObjectLike<{specificKey: string}>(payload)
149
- isObjectLike<object>(payload)
150
- // you can pass a specific type for TS to check on.
219
+
220
+ const payload = { name: 'Mesqueeb' } // current type: `{ name: string }`
221
+
222
+ // Without casting:
223
+ if (isAnyObject(payload)) {
224
+ // in here `payload` is casted to: `Record<string | number | symbol, any>`
225
+ // WE LOOSE THE TYPE!
226
+ }
227
+
228
+ // With casting:
229
+ // you can pass a specific type for TS that will be casted when the function returns
230
+ if (isObjectLike<{ name: string }>(payload)) {
231
+ // in here `payload` is casted to: `{ name: string }`
232
+ }
151
233
  ```
152
234
 
235
+ Please note: this library will not actually check the shape of the object, you need to do that yourself.
236
+
153
237
  `isObjectLike<T>` works like this under the hood:
154
238
 
155
239
  ```ts
156
- function isObjectLike<T extends object> (payload: any): payload is T {
240
+ function isObjectLike<T extends object>(payload: any): payload is T {
157
241
  return isAnyObject(payload)
158
242
  }
159
243
  ```
@@ -173,16 +257,16 @@ function isObjectLike<T extends object> (payload: any): payload is T {
173
257
  It's litterally just these functions:
174
258
 
175
259
  ```js
176
- function getType (payload) {
260
+ function getType(payload) {
177
261
  return Object.prototype.toString.call(payload).slice(8, -1)
178
262
  }
179
- function isUndefined (payload) {
263
+ function isUndefined(payload) {
180
264
  return getType(payload) === 'Undefined'
181
265
  }
182
- function isString (payload) {
266
+ function isString(payload) {
183
267
  return getType(payload) === 'String'
184
268
  }
185
- function isAnyObject (payload) {
269
+ function isAnyObject(payload) {
186
270
  return getType(payload) === 'Object'
187
271
  }
188
272
  // etc...
@@ -33,7 +33,7 @@ function isNull(payload) {
33
33
  * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
34
34
  *
35
35
  * @param {*} payload
36
- * @returns {payload is Record<string, any>}
36
+ * @returns {payload is PlainObject}
37
37
  */
38
38
  function isPlainObject(payload) {
39
39
  if (getType(payload) !== 'Object')
@@ -44,7 +44,7 @@ function isPlainObject(payload) {
44
44
  * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
45
45
  *
46
46
  * @param {*} payload
47
- * @returns {payload is Record<string, any>}
47
+ * @returns {payload is PlainObject}
48
48
  */
49
49
  function isObject(payload) {
50
50
  return isPlainObject(payload);
@@ -58,11 +58,20 @@ function isObject(payload) {
58
58
  function isEmptyObject(payload) {
59
59
  return isPlainObject(payload) && Object.keys(payload).length === 0;
60
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
+ }
61
70
  /**
62
71
  * Returns whether the payload is an any kind of object (including special classes or objects with different prototypes)
63
72
  *
64
73
  * @param {*} payload
65
- * @returns {payload is Record<string, any>}
74
+ * @returns {payload is PlainObject}
66
75
  */
67
76
  function isAnyObject(payload) {
68
77
  return getType(payload) === 'Object';
@@ -153,6 +162,24 @@ function isEmptyString(payload) {
153
162
  function isNumber(payload) {
154
163
  return getType(payload) === 'Number' && !isNaN(payload);
155
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
+ }
156
183
  /**
157
184
  * Returns whether the payload is a boolean
158
185
  *
@@ -290,11 +317,9 @@ function isPrimitive(payload) {
290
317
  * @param {*} payload
291
318
  * @returns {(payload is null | undefined)}
292
319
  */
293
- var isNullOrUndefined = isOneOf(isNull, isUndefined);
320
+ const isNullOrUndefined = isOneOf(isNull, isUndefined);
294
321
  function isOneOf(a, b, c, d, e) {
295
- return function (value) {
296
- return a(value) || b(value) || (!!c && c(value)) || (!!d && d(value)) || (!!e && e(value));
297
- };
322
+ return (value) => a(value) || b(value) || (!!c && c(value)) || (!!d && d(value)) || (!!e && e(value));
298
323
  }
299
324
  /**
300
325
  * Does a generic check to check that the given payload is of a given type.
@@ -315,7 +340,7 @@ function isType(payload, type) {
315
340
  throw new TypeError('Type is not a class');
316
341
  }
317
342
  // Classes usually have names (as functions usually have names)
318
- var name = type.name;
343
+ const name = type.name;
319
344
  return getType(payload) === name || Boolean(payload && payload.constructor === type);
320
345
  }
321
346
 
@@ -331,10 +356,12 @@ exports.isEmptyString = isEmptyString;
331
356
  exports.isError = isError;
332
357
  exports.isFile = isFile;
333
358
  exports.isFullArray = isFullArray;
359
+ exports.isFullObject = isFullObject;
334
360
  exports.isFullString = isFullString;
335
361
  exports.isFunction = isFunction;
336
362
  exports.isMap = isMap;
337
363
  exports.isNaNValue = isNaNValue;
364
+ exports.isNegativeNumber = isNegativeNumber;
338
365
  exports.isNull = isNull;
339
366
  exports.isNullOrUndefined = isNullOrUndefined;
340
367
  exports.isNumber = isNumber;
@@ -342,6 +369,7 @@ exports.isObject = isObject;
342
369
  exports.isObjectLike = isObjectLike;
343
370
  exports.isOneOf = isOneOf;
344
371
  exports.isPlainObject = isPlainObject;
372
+ exports.isPositiveNumber = isPositiveNumber;
345
373
  exports.isPrimitive = isPrimitive;
346
374
  exports.isPromise = isPromise;
347
375
  exports.isRegExp = isRegExp;
@@ -29,7 +29,7 @@ function isNull(payload) {
29
29
  * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
30
30
  *
31
31
  * @param {*} payload
32
- * @returns {payload is Record<string, any>}
32
+ * @returns {payload is PlainObject}
33
33
  */
34
34
  function isPlainObject(payload) {
35
35
  if (getType(payload) !== 'Object')
@@ -40,7 +40,7 @@ function isPlainObject(payload) {
40
40
  * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
41
41
  *
42
42
  * @param {*} payload
43
- * @returns {payload is Record<string, any>}
43
+ * @returns {payload is PlainObject}
44
44
  */
45
45
  function isObject(payload) {
46
46
  return isPlainObject(payload);
@@ -54,11 +54,20 @@ function isObject(payload) {
54
54
  function isEmptyObject(payload) {
55
55
  return isPlainObject(payload) && Object.keys(payload).length === 0;
56
56
  }
57
+ /**
58
+ * Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
59
+ *
60
+ * @param {*} payload
61
+ * @returns {payload is PlainObject}
62
+ */
63
+ function isFullObject(payload) {
64
+ return isPlainObject(payload) && Object.keys(payload).length > 0;
65
+ }
57
66
  /**
58
67
  * Returns whether the payload is an any kind of object (including special classes or objects with different prototypes)
59
68
  *
60
69
  * @param {*} payload
61
- * @returns {payload is Record<string, any>}
70
+ * @returns {payload is PlainObject}
62
71
  */
63
72
  function isAnyObject(payload) {
64
73
  return getType(payload) === 'Object';
@@ -149,6 +158,24 @@ function isEmptyString(payload) {
149
158
  function isNumber(payload) {
150
159
  return getType(payload) === 'Number' && !isNaN(payload);
151
160
  }
161
+ /**
162
+ * Returns whether the payload is a positive number (but not 0)
163
+ *
164
+ * @param {*} payload
165
+ * @returns {payload is number}
166
+ */
167
+ function isPositiveNumber(payload) {
168
+ return isNumber(payload) && payload > 0;
169
+ }
170
+ /**
171
+ * Returns whether the payload is a negative number (but not 0)
172
+ *
173
+ * @param {*} payload
174
+ * @returns {payload is number}
175
+ */
176
+ function isNegativeNumber(payload) {
177
+ return isNumber(payload) && payload < 0;
178
+ }
152
179
  /**
153
180
  * Returns whether the payload is a boolean
154
181
  *
@@ -286,11 +313,9 @@ function isPrimitive(payload) {
286
313
  * @param {*} payload
287
314
  * @returns {(payload is null | undefined)}
288
315
  */
289
- var isNullOrUndefined = isOneOf(isNull, isUndefined);
316
+ const isNullOrUndefined = isOneOf(isNull, isUndefined);
290
317
  function isOneOf(a, b, c, d, e) {
291
- return function (value) {
292
- return a(value) || b(value) || (!!c && c(value)) || (!!d && d(value)) || (!!e && e(value));
293
- };
318
+ return (value) => a(value) || b(value) || (!!c && c(value)) || (!!d && d(value)) || (!!e && e(value));
294
319
  }
295
320
  /**
296
321
  * Does a generic check to check that the given payload is of a given type.
@@ -311,8 +336,8 @@ function isType(payload, type) {
311
336
  throw new TypeError('Type is not a class');
312
337
  }
313
338
  // Classes usually have names (as functions usually have names)
314
- var name = type.name;
339
+ const name = type.name;
315
340
  return getType(payload) === name || Boolean(payload && payload.constructor === type);
316
341
  }
317
342
 
318
- export { getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyArray, isEmptyObject, isEmptyString, isError, isFile, isFullArray, isFullString, isFunction, isMap, isNaNValue, isNull, isNullOrUndefined, isNumber, isObject, isObjectLike, isOneOf, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isType, isUndefined, isWeakMap, isWeakSet };
343
+ export { getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyArray, isEmptyObject, isEmptyString, isError, isFile, isFullArray, isFullObject, isFullString, isFunction, isMap, isNaNValue, isNegativeNumber, isNull, isNullOrUndefined, isNumber, isObject, isObjectLike, isOneOf, isPlainObject, isPositiveNumber, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isType, isUndefined, isWeakMap, isWeakSet };
@@ -1,6 +1,7 @@
1
1
  export declare type AnyFunction = (...args: any[]) => any;
2
2
  export declare type AnyAsyncFunction = (...args: any[]) => Promise<any>;
3
3
  export declare type AnyClass = new (...args: any[]) => any;
4
+ export declare type PlainObject = Record<string | number | symbol, any>;
4
5
  declare type TypeGuard<A, B extends A> = (payload: A) => payload is B;
5
6
  /**
6
7
  * Returns the object type of the given payload
@@ -27,16 +28,16 @@ export declare function isNull(payload: any): payload is null;
27
28
  * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
28
29
  *
29
30
  * @param {*} payload
30
- * @returns {payload is Record<string, any>}
31
+ * @returns {payload is PlainObject}
31
32
  */
32
- export declare function isPlainObject(payload: any): payload is Record<string, any>;
33
+ export declare function isPlainObject(payload: any): payload is PlainObject;
33
34
  /**
34
35
  * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)
35
36
  *
36
37
  * @param {*} payload
37
- * @returns {payload is Record<string, any>}
38
+ * @returns {payload is PlainObject}
38
39
  */
39
- export declare function isObject(payload: any): payload is Record<string, any>;
40
+ export declare function isObject(payload: any): payload is PlainObject;
40
41
  /**
41
42
  * Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
42
43
  *
@@ -46,13 +47,20 @@ export declare function isObject(payload: any): payload is Record<string, any>;
46
47
  export declare function isEmptyObject(payload: any): payload is {
47
48
  [K in any]: never;
48
49
  };
50
+ /**
51
+ * Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
52
+ *
53
+ * @param {*} payload
54
+ * @returns {payload is PlainObject}
55
+ */
56
+ export declare function isFullObject(payload: any): payload is PlainObject;
49
57
  /**
50
58
  * Returns whether the payload is an any kind of object (including special classes or objects with different prototypes)
51
59
  *
52
60
  * @param {*} payload
53
- * @returns {payload is Record<string, any>}
61
+ * @returns {payload is PlainObject}
54
62
  */
55
- export declare function isAnyObject(payload: any): payload is Record<string, any>;
63
+ export declare function isAnyObject(payload: any): payload is PlainObject;
56
64
  /**
57
65
  * Returns whether the payload is an object like a type passed in < >
58
66
  *
@@ -62,7 +70,7 @@ export declare function isAnyObject(payload: any): payload is Record<string, any
62
70
  * @param {*} payload
63
71
  * @returns {payload is T}
64
72
  */
65
- export declare function isObjectLike<T extends Record<string, any>>(payload: any): payload is T;
73
+ export declare function isObjectLike<T extends PlainObject>(payload: any): payload is T;
66
74
  /**
67
75
  * Returns whether the payload is a function (regular or async)
68
76
  *
@@ -121,6 +129,20 @@ export declare function isEmptyString(payload: any): payload is string;
121
129
  * @returns {payload is number}
122
130
  */
123
131
  export declare function isNumber(payload: any): payload is number;
132
+ /**
133
+ * Returns whether the payload is a positive number (but not 0)
134
+ *
135
+ * @param {*} payload
136
+ * @returns {payload is number}
137
+ */
138
+ export declare function isPositiveNumber(payload: any): payload is number;
139
+ /**
140
+ * Returns whether the payload is a negative number (but not 0)
141
+ *
142
+ * @param {*} payload
143
+ * @returns {payload is number}
144
+ */
145
+ export declare function isNegativeNumber(payload: any): payload is number;
124
146
  /**
125
147
  * Returns whether the payload is a boolean
126
148
  *
package/package.json CHANGED
@@ -1,18 +1,32 @@
1
1
  {
2
2
  "name": "is-what",
3
3
  "sideEffects": false,
4
- "version": "3.14.0",
4
+ "type": "module",
5
+ "version": "4.1.1",
5
6
  "description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.",
6
- "main": "dist/index.cjs.js",
7
- "module": "dist/index.esm.js",
8
- "typings": "types/index.d.ts",
7
+ "module": "./dist/index.es.js",
8
+ "main": "./dist/index.cjs",
9
+ "types": "./dist/types/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.es.js",
13
+ "require": "./dist/index.cjs",
14
+ "types": "./dist/types/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "engines": {
21
+ "node": ">=12.13",
22
+ "npm": ">=7"
23
+ },
9
24
  "scripts": {
10
- "test": "ava",
11
- "jest": "jest",
12
- "jest-w": "jest --watchAll",
25
+ "test": "vitest run",
13
26
  "lint": "tsc --noEmit src/index.ts && eslint . --ext .js,.jsx,.ts,.tsx",
14
27
  "rollup": "rollup -c ./build.js",
15
- "build": "rimraf types && rimraf dist && npm run lint && npm run rollup && npm run test && npm run jest"
28
+ "build": "rimraf dist && npm run lint && npm run rollup && npm run test",
29
+ "release": "npm run build && np"
16
30
  },
17
31
  "repository": {
18
32
  "type": "git",
@@ -40,41 +54,57 @@
40
54
  "is-plain-object"
41
55
  ],
42
56
  "author": "Luca Ban - Mesqueeb",
57
+ "funding": "https://github.com/sponsors/mesqueeb",
43
58
  "license": "MIT",
44
59
  "bugs": {
45
60
  "url": "https://github.com/mesqueeb/is-what/issues"
46
61
  },
47
62
  "homepage": "https://github.com/mesqueeb/is-what#readme",
48
63
  "devDependencies": {
49
- "@babel/core": "^7.12.17",
50
- "@types/babel-core": "^6.25.6",
51
- "@types/jest": "^26.0.20",
52
- "@typescript-eslint/eslint-plugin": "^4.15.1",
53
- "@typescript-eslint/parser": "^4.15.1",
54
- "ava": "^3.15.0",
55
- "babel-core": "^7.0.0-bridge.0",
56
- "babel-jest": "^26.6.3",
57
- "babel-preset-env": "^1.7.0",
58
- "eslint": "^7.20.0",
59
- "eslint-config-prettier": "^7.2.0",
60
- "eslint-plugin-tree-shaking": "^1.8.0",
61
- "jest": "^26.6.3",
62
- "prettier": "^2.2.1",
63
- "regenerator-runtime": "^0.13.7",
64
+ "@typescript-eslint/eslint-plugin": "^5.10.0",
65
+ "@typescript-eslint/parser": "^5.10.0",
66
+ "eslint": "^8.7.0",
67
+ "eslint-config-prettier": "^8.3.0",
68
+ "eslint-plugin-tree-shaking": "^1.10.0",
69
+ "np": "^7.6.0",
70
+ "prettier": "^2.5.1",
64
71
  "rimraf": "^3.0.2",
65
- "rollup": "^2.39.0",
66
- "rollup-plugin-typescript2": "^0.30.0",
67
- "ts-node": "^9.1.1",
68
- "tsconfig-paths": "^3.9.0",
69
- "typescript": "^4.1.5"
72
+ "rollup": "^2.66.0",
73
+ "rollup-plugin-typescript2": "^0.31.1",
74
+ "typescript": "^4.5.5",
75
+ "vitest": "^0.2.1"
70
76
  },
71
77
  "ava": {
72
- "extensions": [
73
- "ts"
74
- ],
75
- "require": [
76
- "tsconfig-paths/register",
77
- "ts-node/register"
78
+ "extensions": {
79
+ "ts": "module"
80
+ },
81
+ "nodeArguments": [
82
+ "--loader=ts-node/esm"
78
83
  ]
84
+ },
85
+ "np": {
86
+ "yarn": false,
87
+ "branch": "production"
88
+ },
89
+ "eslintConfig": {
90
+ "root": true,
91
+ "parser": "@typescript-eslint/parser",
92
+ "plugins": [
93
+ "@typescript-eslint",
94
+ "tree-shaking"
95
+ ],
96
+ "extends": [
97
+ "eslint:recommended",
98
+ "plugin:@typescript-eslint/eslint-recommended",
99
+ "plugin:@typescript-eslint/recommended",
100
+ "prettier"
101
+ ],
102
+ "rules": {
103
+ "@typescript-eslint/no-empty-function": "off",
104
+ "@typescript-eslint/no-explicit-any": "off",
105
+ "@typescript-eslint/ban-ts-ignore": "off",
106
+ "tree-shaking/no-side-effects-in-initialization": "error",
107
+ "@typescript-eslint/explicit-module-boundary-types": "off"
108
+ }
79
109
  }
80
110
  }
package/.babelrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "presets": ["env"]
3
- }
package/.eslintignore DELETED
@@ -1,9 +0,0 @@
1
- # don't ever lint node_modules
2
- node_modules
3
- # don't lint build output (make sure it's set to your correct build folder name)
4
- dist
5
- # don't lint nyc coverage output
6
- coverage
7
-
8
- test
9
- .eslintrc.js