is 3.2.1 → 3.3.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.
- package/CHANGELOG.md +7 -0
- package/README.md +3 -1
- package/index.js +53 -35
- package/package.json +6 -6
- package/test/index.js +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
3.3.0 / 2018-12-14
|
|
2
|
+
==================
|
|
3
|
+
* [New] add `is.bigint` (#36)
|
|
4
|
+
* [Docs] change jsdoc comments "Mixed" to wildcards (#34)
|
|
5
|
+
* [Tests] up to `node` `v11.4`, `v10.14`, `v9.11`, `v8.14`, `v7.10`, `v6.15`, `v4.9`; use `nvm install-latest-npm`
|
|
6
|
+
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `tape`
|
|
7
|
+
|
|
1
8
|
3.2.1 / 2017-02-27
|
|
2
9
|
==================
|
|
3
10
|
* [Fix] `is.fn`: recognize generator and async functions too (#28)
|
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -17,6 +17,10 @@ var symbolValueOf;
|
|
|
17
17
|
if (typeof Symbol === 'function') {
|
|
18
18
|
symbolValueOf = Symbol.prototype.valueOf;
|
|
19
19
|
}
|
|
20
|
+
var bigIntValueOf;
|
|
21
|
+
if (typeof BigInt === 'function') {
|
|
22
|
+
bigIntValueOf = BigInt.prototype.valueOf;
|
|
23
|
+
}
|
|
20
24
|
var isActualNaN = function (value) {
|
|
21
25
|
return value !== value;
|
|
22
26
|
};
|
|
@@ -44,7 +48,7 @@ var is = {};
|
|
|
44
48
|
* is.type
|
|
45
49
|
* Test if `value` is a type of `type`.
|
|
46
50
|
*
|
|
47
|
-
* @param {
|
|
51
|
+
* @param {*} value value to test
|
|
48
52
|
* @param {String} type type
|
|
49
53
|
* @return {Boolean} true if `value` is a type of `type`, false otherwise
|
|
50
54
|
* @api public
|
|
@@ -58,7 +62,7 @@ is.a = is.type = function (value, type) {
|
|
|
58
62
|
* is.defined
|
|
59
63
|
* Test if `value` is defined.
|
|
60
64
|
*
|
|
61
|
-
* @param {
|
|
65
|
+
* @param {*} value value to test
|
|
62
66
|
* @return {Boolean} true if 'value' is defined, false otherwise
|
|
63
67
|
* @api public
|
|
64
68
|
*/
|
|
@@ -71,7 +75,7 @@ is.defined = function (value) {
|
|
|
71
75
|
* is.empty
|
|
72
76
|
* Test if `value` is empty.
|
|
73
77
|
*
|
|
74
|
-
* @param {
|
|
78
|
+
* @param {*} value value to test
|
|
75
79
|
* @return {Boolean} true if `value` is empty, false otherwise
|
|
76
80
|
* @api public
|
|
77
81
|
*/
|
|
@@ -100,8 +104,8 @@ is.empty = function (value) {
|
|
|
100
104
|
* is.equal
|
|
101
105
|
* Test if `value` is equal to `other`.
|
|
102
106
|
*
|
|
103
|
-
* @param {
|
|
104
|
-
* @param {
|
|
107
|
+
* @param {*} value value to test
|
|
108
|
+
* @param {*} other value to compare with
|
|
105
109
|
* @return {Boolean} true if `value` is equal to `other`, false otherwise
|
|
106
110
|
*/
|
|
107
111
|
|
|
@@ -159,8 +163,8 @@ is.equal = function equal(value, other) {
|
|
|
159
163
|
* is.hosted
|
|
160
164
|
* Test if `value` is hosted by `host`.
|
|
161
165
|
*
|
|
162
|
-
* @param {
|
|
163
|
-
* @param {
|
|
166
|
+
* @param {*} value to test
|
|
167
|
+
* @param {*} host host to test with
|
|
164
168
|
* @return {Boolean} true if `value` is hosted by `host`, false otherwise
|
|
165
169
|
* @api public
|
|
166
170
|
*/
|
|
@@ -174,7 +178,7 @@ is.hosted = function (value, host) {
|
|
|
174
178
|
* is.instance
|
|
175
179
|
* Test if `value` is an instance of `constructor`.
|
|
176
180
|
*
|
|
177
|
-
* @param {
|
|
181
|
+
* @param {*} value value to test
|
|
178
182
|
* @return {Boolean} true if `value` is an instance of `constructor`
|
|
179
183
|
* @api public
|
|
180
184
|
*/
|
|
@@ -187,7 +191,7 @@ is.instance = is['instanceof'] = function (value, constructor) {
|
|
|
187
191
|
* is.nil / is.null
|
|
188
192
|
* Test if `value` is null.
|
|
189
193
|
*
|
|
190
|
-
* @param {
|
|
194
|
+
* @param {*} value value to test
|
|
191
195
|
* @return {Boolean} true if `value` is null, false otherwise
|
|
192
196
|
* @api public
|
|
193
197
|
*/
|
|
@@ -200,7 +204,7 @@ is.nil = is['null'] = function (value) {
|
|
|
200
204
|
* is.undef / is.undefined
|
|
201
205
|
* Test if `value` is undefined.
|
|
202
206
|
*
|
|
203
|
-
* @param {
|
|
207
|
+
* @param {*} value value to test
|
|
204
208
|
* @return {Boolean} true if `value` is undefined, false otherwise
|
|
205
209
|
* @api public
|
|
206
210
|
*/
|
|
@@ -217,7 +221,7 @@ is.undef = is.undefined = function (value) {
|
|
|
217
221
|
* is.args
|
|
218
222
|
* Test if `value` is an arguments object.
|
|
219
223
|
*
|
|
220
|
-
* @param {
|
|
224
|
+
* @param {*} value value to test
|
|
221
225
|
* @return {Boolean} true if `value` is an arguments object, false otherwise
|
|
222
226
|
* @api public
|
|
223
227
|
*/
|
|
@@ -236,7 +240,7 @@ is.args = is.arguments = function (value) {
|
|
|
236
240
|
* is.array
|
|
237
241
|
* Test if 'value' is an array.
|
|
238
242
|
*
|
|
239
|
-
* @param {
|
|
243
|
+
* @param {*} value value to test
|
|
240
244
|
* @return {Boolean} true if `value` is an array, false otherwise
|
|
241
245
|
* @api public
|
|
242
246
|
*/
|
|
@@ -249,7 +253,7 @@ is.array = Array.isArray || function (value) {
|
|
|
249
253
|
* is.arguments.empty
|
|
250
254
|
* Test if `value` is an empty arguments object.
|
|
251
255
|
*
|
|
252
|
-
* @param {
|
|
256
|
+
* @param {*} value value to test
|
|
253
257
|
* @return {Boolean} true if `value` is an empty arguments object, false otherwise
|
|
254
258
|
* @api public
|
|
255
259
|
*/
|
|
@@ -261,7 +265,7 @@ is.args.empty = function (value) {
|
|
|
261
265
|
* is.array.empty
|
|
262
266
|
* Test if `value` is an empty array.
|
|
263
267
|
*
|
|
264
|
-
* @param {
|
|
268
|
+
* @param {*} value value to test
|
|
265
269
|
* @return {Boolean} true if `value` is an empty array, false otherwise
|
|
266
270
|
* @api public
|
|
267
271
|
*/
|
|
@@ -273,7 +277,7 @@ is.array.empty = function (value) {
|
|
|
273
277
|
* is.arraylike
|
|
274
278
|
* Test if `value` is an arraylike object.
|
|
275
279
|
*
|
|
276
|
-
* @param {
|
|
280
|
+
* @param {*} value value to test
|
|
277
281
|
* @return {Boolean} true if `value` is an arguments object, false otherwise
|
|
278
282
|
* @api public
|
|
279
283
|
*/
|
|
@@ -294,7 +298,7 @@ is.arraylike = function (value) {
|
|
|
294
298
|
* is.bool
|
|
295
299
|
* Test if `value` is a boolean.
|
|
296
300
|
*
|
|
297
|
-
* @param {
|
|
301
|
+
* @param {*} value value to test
|
|
298
302
|
* @return {Boolean} true if `value` is a boolean, false otherwise
|
|
299
303
|
* @api public
|
|
300
304
|
*/
|
|
@@ -307,7 +311,7 @@ is.bool = is['boolean'] = function (value) {
|
|
|
307
311
|
* is.false
|
|
308
312
|
* Test if `value` is false.
|
|
309
313
|
*
|
|
310
|
-
* @param {
|
|
314
|
+
* @param {*} value value to test
|
|
311
315
|
* @return {Boolean} true if `value` is false, false otherwise
|
|
312
316
|
* @api public
|
|
313
317
|
*/
|
|
@@ -320,7 +324,7 @@ is['false'] = function (value) {
|
|
|
320
324
|
* is.true
|
|
321
325
|
* Test if `value` is true.
|
|
322
326
|
*
|
|
323
|
-
* @param {
|
|
327
|
+
* @param {*} value value to test
|
|
324
328
|
* @return {Boolean} true if `value` is true, false otherwise
|
|
325
329
|
* @api public
|
|
326
330
|
*/
|
|
@@ -337,7 +341,7 @@ is['true'] = function (value) {
|
|
|
337
341
|
* is.date
|
|
338
342
|
* Test if `value` is a date.
|
|
339
343
|
*
|
|
340
|
-
* @param {
|
|
344
|
+
* @param {*} value value to test
|
|
341
345
|
* @return {Boolean} true if `value` is a date, false otherwise
|
|
342
346
|
* @api public
|
|
343
347
|
*/
|
|
@@ -350,7 +354,7 @@ is.date = function (value) {
|
|
|
350
354
|
* is.date.valid
|
|
351
355
|
* Test if `value` is a valid date.
|
|
352
356
|
*
|
|
353
|
-
* @param {
|
|
357
|
+
* @param {*} value value to test
|
|
354
358
|
* @returns {Boolean} true if `value` is a valid date, false otherwise
|
|
355
359
|
*/
|
|
356
360
|
is.date.valid = function (value) {
|
|
@@ -365,7 +369,7 @@ is.date.valid = function (value) {
|
|
|
365
369
|
* is.element
|
|
366
370
|
* Test if `value` is an html element.
|
|
367
371
|
*
|
|
368
|
-
* @param {
|
|
372
|
+
* @param {*} value value to test
|
|
369
373
|
* @return {Boolean} true if `value` is an HTML Element, false otherwise
|
|
370
374
|
* @api public
|
|
371
375
|
*/
|
|
@@ -385,7 +389,7 @@ is.element = function (value) {
|
|
|
385
389
|
* is.error
|
|
386
390
|
* Test if `value` is an error object.
|
|
387
391
|
*
|
|
388
|
-
* @param {
|
|
392
|
+
* @param {*} value value to test
|
|
389
393
|
* @return {Boolean} true if `value` is an error object, false otherwise
|
|
390
394
|
* @api public
|
|
391
395
|
*/
|
|
@@ -402,7 +406,7 @@ is.error = function (value) {
|
|
|
402
406
|
* is.fn / is.function (deprecated)
|
|
403
407
|
* Test if `value` is a function.
|
|
404
408
|
*
|
|
405
|
-
* @param {
|
|
409
|
+
* @param {*} value value to test
|
|
406
410
|
* @return {Boolean} true if `value` is a function, false otherwise
|
|
407
411
|
* @api public
|
|
408
412
|
*/
|
|
@@ -424,7 +428,7 @@ is.fn = is['function'] = function (value) {
|
|
|
424
428
|
* is.number
|
|
425
429
|
* Test if `value` is a number.
|
|
426
430
|
*
|
|
427
|
-
* @param {
|
|
431
|
+
* @param {*} value value to test
|
|
428
432
|
* @return {Boolean} true if `value` is a number, false otherwise
|
|
429
433
|
* @api public
|
|
430
434
|
*/
|
|
@@ -437,7 +441,7 @@ is.number = function (value) {
|
|
|
437
441
|
* is.infinite
|
|
438
442
|
* Test if `value` is positive or negative infinity.
|
|
439
443
|
*
|
|
440
|
-
* @param {
|
|
444
|
+
* @param {*} value value to test
|
|
441
445
|
* @return {Boolean} true if `value` is positive or negative Infinity, false otherwise
|
|
442
446
|
* @api public
|
|
443
447
|
*/
|
|
@@ -449,7 +453,7 @@ is.infinite = function (value) {
|
|
|
449
453
|
* is.decimal
|
|
450
454
|
* Test if `value` is a decimal number.
|
|
451
455
|
*
|
|
452
|
-
* @param {
|
|
456
|
+
* @param {*} value value to test
|
|
453
457
|
* @return {Boolean} true if `value` is a decimal number, false otherwise
|
|
454
458
|
* @api public
|
|
455
459
|
*/
|
|
@@ -546,7 +550,7 @@ is.minimum = function (value, others) {
|
|
|
546
550
|
* is.nan
|
|
547
551
|
* Test if `value` is not a number.
|
|
548
552
|
*
|
|
549
|
-
* @param {
|
|
553
|
+
* @param {*} value value to test
|
|
550
554
|
* @return {Boolean} true if `value` is not a number, false otherwise
|
|
551
555
|
* @api public
|
|
552
556
|
*/
|
|
@@ -677,7 +681,7 @@ is.within = function (value, start, finish) {
|
|
|
677
681
|
* is.object
|
|
678
682
|
* Test if `value` is an object.
|
|
679
683
|
*
|
|
680
|
-
* @param {
|
|
684
|
+
* @param {*} value value to test
|
|
681
685
|
* @return {Boolean} true if `value` is an object, false otherwise
|
|
682
686
|
* @api public
|
|
683
687
|
*/
|
|
@@ -689,7 +693,7 @@ is.object = function (value) {
|
|
|
689
693
|
* is.primitive
|
|
690
694
|
* Test if `value` is a primitive.
|
|
691
695
|
*
|
|
692
|
-
* @param {
|
|
696
|
+
* @param {*} value value to test
|
|
693
697
|
* @return {Boolean} true if `value` is a primitive, false otherwise
|
|
694
698
|
* @api public
|
|
695
699
|
*/
|
|
@@ -707,7 +711,7 @@ is.primitive = function isPrimitive(value) {
|
|
|
707
711
|
* is.hash
|
|
708
712
|
* Test if `value` is a hash - a plain object literal.
|
|
709
713
|
*
|
|
710
|
-
* @param {
|
|
714
|
+
* @param {*} value value to test
|
|
711
715
|
* @return {Boolean} true if `value` is a hash, false otherwise
|
|
712
716
|
* @api public
|
|
713
717
|
*/
|
|
@@ -724,7 +728,7 @@ is.hash = function (value) {
|
|
|
724
728
|
* is.regexp
|
|
725
729
|
* Test if `value` is a regular expression.
|
|
726
730
|
*
|
|
727
|
-
* @param {
|
|
731
|
+
* @param {*} value value to test
|
|
728
732
|
* @return {Boolean} true if `value` is a regexp, false otherwise
|
|
729
733
|
* @api public
|
|
730
734
|
*/
|
|
@@ -741,7 +745,7 @@ is.regexp = function (value) {
|
|
|
741
745
|
* is.string
|
|
742
746
|
* Test if `value` is a string.
|
|
743
747
|
*
|
|
744
|
-
* @param {
|
|
748
|
+
* @param {*} value value to test
|
|
745
749
|
* @return {Boolean} true if 'value' is a string, false otherwise
|
|
746
750
|
* @api public
|
|
747
751
|
*/
|
|
@@ -758,7 +762,7 @@ is.string = function (value) {
|
|
|
758
762
|
* is.base64
|
|
759
763
|
* Test if `value` is a valid base64 encoded string.
|
|
760
764
|
*
|
|
761
|
-
* @param {
|
|
765
|
+
* @param {*} value value to test
|
|
762
766
|
* @return {Boolean} true if 'value' is a base64 encoded string, false otherwise
|
|
763
767
|
* @api public
|
|
764
768
|
*/
|
|
@@ -775,7 +779,7 @@ is.base64 = function (value) {
|
|
|
775
779
|
* is.hex
|
|
776
780
|
* Test if `value` is a valid hex encoded string.
|
|
777
781
|
*
|
|
778
|
-
* @param {
|
|
782
|
+
* @param {*} value value to test
|
|
779
783
|
* @return {Boolean} true if 'value' is a hex encoded string, false otherwise
|
|
780
784
|
* @api public
|
|
781
785
|
*/
|
|
@@ -788,7 +792,7 @@ is.hex = function (value) {
|
|
|
788
792
|
* is.symbol
|
|
789
793
|
* Test if `value` is an ES6 Symbol
|
|
790
794
|
*
|
|
791
|
-
* @param {
|
|
795
|
+
* @param {*} value value to test
|
|
792
796
|
* @return {Boolean} true if `value` is a Symbol, false otherise
|
|
793
797
|
* @api public
|
|
794
798
|
*/
|
|
@@ -797,4 +801,18 @@ is.symbol = function (value) {
|
|
|
797
801
|
return typeof Symbol === 'function' && toStr.call(value) === '[object Symbol]' && typeof symbolValueOf.call(value) === 'symbol';
|
|
798
802
|
};
|
|
799
803
|
|
|
804
|
+
/**
|
|
805
|
+
* is.bigint
|
|
806
|
+
* Test if `value` is an ES-proposed BigInt
|
|
807
|
+
*
|
|
808
|
+
* @param {*} value value to test
|
|
809
|
+
* @return {Boolean} true if `value` is a BigInt, false otherise
|
|
810
|
+
* @api public
|
|
811
|
+
*/
|
|
812
|
+
|
|
813
|
+
is.bigint = function (value) {
|
|
814
|
+
// eslint-disable-next-line valid-typeof
|
|
815
|
+
return typeof BigInt === 'function' && toStr.call(value) === '[object BigInt]' && typeof bigIntValueOf.call(value) === 'bigint';
|
|
816
|
+
};
|
|
817
|
+
|
|
800
818
|
module.exports = is;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "is",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublish": "safe-publish-latest",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"coverage-quiet": "covert test/index.js --quiet",
|
|
12
12
|
"lint": "npm run jscs && npm run eslint",
|
|
13
13
|
"jscs": "jscs *.js */*.js",
|
|
14
|
-
"eslint": "eslint
|
|
14
|
+
"eslint": "eslint ."
|
|
15
15
|
},
|
|
16
16
|
"author": {
|
|
17
17
|
"name": "Enrico Marino",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@ljharb/eslint-config": "^
|
|
40
|
+
"@ljharb/eslint-config": "^13.0.0",
|
|
41
41
|
"covert": "^1.1.0",
|
|
42
|
-
"eslint": "^
|
|
42
|
+
"eslint": "^5.10.0",
|
|
43
43
|
"foreach": "^2.0.5",
|
|
44
44
|
"jscs": "^3.0.7",
|
|
45
45
|
"make-generator-function": "^1.1.0",
|
|
46
|
-
"safe-publish-latest": "^1.1.
|
|
47
|
-
"tape": "^4.
|
|
46
|
+
"safe-publish-latest": "^1.1.2",
|
|
47
|
+
"tape": "^4.9.1"
|
|
48
48
|
},
|
|
49
49
|
"testling": {
|
|
50
50
|
"files": "test/index.js",
|
package/test/index.js
CHANGED
|
@@ -702,3 +702,28 @@ test('is.symbol', function (t) {
|
|
|
702
702
|
|
|
703
703
|
t.end();
|
|
704
704
|
});
|
|
705
|
+
|
|
706
|
+
test('is.bigint', function (t) {
|
|
707
|
+
t.test('not bigints', function (st) {
|
|
708
|
+
var notBigints = [true, false, null, undefined, {}, [], function () {}, 42, NaN, Infinity, /a/g, '', 0, -0, new Error('error')];
|
|
709
|
+
forEach(notBigints, function (notBigint) {
|
|
710
|
+
st.notOk(is.bigint(notBigint), notBigint + ' is not bigint');
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
st.end();
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
t.test('bigints', { skip: typeof BigInt !== 'function' }, function (st) {
|
|
717
|
+
var bigInts = [
|
|
718
|
+
Function('return 42n')(), // eslint-disable-line no-new-func
|
|
719
|
+
BigInt(42)
|
|
720
|
+
];
|
|
721
|
+
forEach(bigInts, function (bigInt) {
|
|
722
|
+
st.ok(is.bigint(bigInt), bigInt + ' is bigint');
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
st.end();
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
t.end();
|
|
729
|
+
});
|