@rcompat/is 0.3.0 → 0.3.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.
@@ -3,24 +3,36 @@ import newable from "#newable";
3
3
  import numeric from "#numeric";
4
4
  import object from "#object";
5
5
  import primitive from "#primitive";
6
- import type { Dict, Nullish } from "@rcompat/type";
6
+ import type { Dict, Nullish, UnknownFunction } from "@rcompat/type";
7
7
  declare function isArray(x: unknown): x is unknown[];
8
+ declare function isBigint(x: unknown): x is bigint;
9
+ declare function isBoolean(x: unknown): x is boolean;
8
10
  declare function isDate(x: unknown): x is Date;
9
11
  declare function isDefined(x: unknown): x is {} | null;
10
12
  declare function isDict(x: unknown): x is Dict;
11
13
  declare function isError(x: unknown): x is Error;
12
14
  declare function isFalsy(x: unknown): boolean;
15
+ declare function isFunction(x: unknown): x is UnknownFunction;
16
+ declare function isIterable(x: unknown): x is Iterable<unknown>;
17
+ declare function isMap(x: unknown): x is Map<unknown, unknown>;
18
+ declare function isNull(x: unknown): x is null;
13
19
  declare function isNullish(x: unknown): x is Nullish;
20
+ declare function isNumber(x: unknown): x is number;
14
21
  declare function isPromise(x: unknown): x is Promise<unknown>;
15
22
  declare function isRegExp(x: unknown): x is RegExp;
23
+ declare function isSet(x: unknown): x is Set<unknown>;
24
+ declare function isString(x: unknown): x is string;
25
+ declare function isSymbol(x: unknown): x is symbol;
16
26
  declare function isTruthy(x: unknown): boolean;
27
+ declare function isTypedArray(x: unknown): x is ArrayBufferView;
28
+ declare function isUndefined(x: unknown): x is undefined;
17
29
  declare function isURL(x: unknown): x is URL;
18
- declare function isMap(x: unknown): x is Map<unknown, unknown>;
19
- declare function isSet(x: unknown): x is Set<unknown>;
20
30
  declare const _default: {
21
31
  array: typeof isArray;
32
+ bigint: typeof isBigint;
22
33
  blank: (x: unknown) => x is string;
23
34
  boolish: (x: unknown) => x is import("@rcompat/type").Boolish;
35
+ boolean: typeof isBoolean;
24
36
  date: typeof isDate;
25
37
  defined: typeof isDefined;
26
38
  dict: typeof isDict;
@@ -28,12 +40,16 @@ declare const _default: {
28
40
  error: typeof isError;
29
41
  falsy: typeof isFalsy;
30
42
  finite: (x: unknown) => x is bigint | number;
43
+ function: typeof isFunction;
31
44
  int: (x: unknown) => x is bigint | number;
45
+ iterable: typeof isIterable;
32
46
  map: typeof isMap;
33
47
  nan: (x: unknown) => x is number;
34
- nonempty: (x: unknown) => boolean;
35
48
  newable: typeof newable;
49
+ nonempty: (x: unknown) => boolean;
50
+ null: typeof isNull;
36
51
  nullish: typeof isNullish;
52
+ number: typeof isNumber;
37
53
  numeric: typeof numeric;
38
54
  object: typeof object;
39
55
  primitive: typeof primitive;
@@ -41,8 +57,12 @@ declare const _default: {
41
57
  regexp: typeof isRegExp;
42
58
  safeint: (x: unknown) => x is number;
43
59
  set: typeof isSet;
60
+ string: typeof isString;
61
+ symbol: typeof isSymbol;
44
62
  truthy: typeof isTruthy;
63
+ typedarray: typeof isTypedArray;
45
64
  uint: (x: unknown) => x is bigint | number;
65
+ undefined: typeof isUndefined;
46
66
  url: typeof isURL;
47
67
  };
48
68
  export default _default;
@@ -8,6 +8,12 @@ import strings from "#strings";
8
8
  function isArray(x) {
9
9
  return Array.isArray(x);
10
10
  }
11
+ function isBigint(x) {
12
+ return typeof x === "bigint";
13
+ }
14
+ function isBoolean(x) {
15
+ return typeof x === "boolean";
16
+ }
11
17
  function isDate(x) {
12
18
  return x instanceof Date;
13
19
  }
@@ -26,31 +32,57 @@ function isError(x) {
26
32
  function isFalsy(x) {
27
33
  return !x;
28
34
  }
35
+ function isFunction(x) {
36
+ return typeof x === "function";
37
+ }
38
+ function isIterable(x) {
39
+ return typeof x?.[Symbol.iterator] === "function";
40
+ }
41
+ function isMap(x) {
42
+ return x instanceof Map;
43
+ }
44
+ function isNull(x) {
45
+ return x === null;
46
+ }
29
47
  function isNullish(x) {
30
48
  return x === null || x === undefined;
31
49
  }
50
+ function isNumber(x) {
51
+ return typeof x === "number";
52
+ }
32
53
  function isPromise(x) {
33
54
  return x instanceof Promise;
34
55
  }
35
56
  function isRegExp(x) {
36
57
  return x instanceof RegExp;
37
58
  }
59
+ function isSet(x) {
60
+ return x instanceof Set;
61
+ }
62
+ function isString(x) {
63
+ return typeof x === "string";
64
+ }
65
+ function isSymbol(x) {
66
+ return typeof x === "symbol";
67
+ }
38
68
  function isTruthy(x) {
39
69
  return !!x;
40
70
  }
41
- function isURL(x) {
42
- return x instanceof URL;
71
+ function isTypedArray(x) {
72
+ return ArrayBuffer.isView(x);
43
73
  }
44
- function isMap(x) {
45
- return x instanceof Map;
74
+ function isUndefined(x) {
75
+ return x === undefined;
46
76
  }
47
- function isSet(x) {
48
- return x instanceof Set;
77
+ function isURL(x) {
78
+ return x instanceof URL;
49
79
  }
50
80
  export default {
51
81
  array: isArray,
82
+ bigint: isBigint,
52
83
  blank: strings.isBlank,
53
84
  boolish: strings.isBoolish,
85
+ boolean: isBoolean,
54
86
  date: isDate,
55
87
  defined: isDefined,
56
88
  dict: isDict,
@@ -58,12 +90,16 @@ export default {
58
90
  error: isError,
59
91
  falsy: isFalsy,
60
92
  finite: numbers.isFinite,
93
+ function: isFunction,
61
94
  int: numbers.isInt,
95
+ iterable: isIterable,
62
96
  map: isMap,
63
97
  nan: numbers.isNaN,
64
- nonempty: (x) => !empty(x),
65
98
  newable,
99
+ nonempty: (x) => !empty(x),
100
+ null: isNull,
66
101
  nullish: isNullish,
102
+ number: isNumber,
67
103
  numeric,
68
104
  object,
69
105
  primitive,
@@ -71,8 +107,12 @@ export default {
71
107
  regexp: isRegExp,
72
108
  safeint: numbers.isSafeint,
73
109
  set: isSet,
110
+ string: isString,
111
+ symbol: isSymbol,
74
112
  truthy: isTruthy,
113
+ typedarray: isTypedArray,
75
114
  uint: numbers.isUint,
115
+ undefined: isUndefined,
76
116
  url: isURL,
77
117
  };
78
118
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcompat/is",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Standard library identity checks",
5
5
  "bugs": "https://github.com/rcompat/rcompat/issues",
6
6
  "license": "MIT",