what-are-you 0.1.2 → 0.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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-basic.js","sourceRoot":"","sources":["../../src/is-basic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAI,KAAQ;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,CAAA;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAA;AACtC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAmB,EAAE;IACpD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAA;AACpC,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAmB,EAAE;IACpD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAA;AACpC,CAAC,CAAA;AACD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAU,EAAwB,EAAE;IAC9D,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAA;AAChE,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAU,EAA6B,EAAE;IAC/D,OAAO,KAAK,IAAI,IAAI,CAAA;AACxB,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAc,IAAa,EAA0B,EAAE;IAC7E,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,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C,KAAU,EAAE,EAAE,CAAC,KAAK,YAAY,KAAK,CAAA;AAC7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAA"}
@@ -1,39 +0,0 @@
1
- /**
2
- * Checks if the given value is array-like. It must be an object and have an integer `length`
3
- * property.
4
- *
5
- * @template T - Allows asserting the element type. Not part of the check.
6
- * @param value - The value to check.
7
- */
8
- export declare function isArrayLike<T>(value: any): value is ArrayLike<T>;
9
- /**
10
- * Checks if the given value is an object
11
- *
12
- * @param value - The value to check.
13
- */
14
- export declare function isIterable<T>(value: any): value is Iterable<T>;
15
- /**
16
- * Checks if the given value is an iterable or async iterable.
17
- *
18
- * @template T - Allows asserting the element type. Not part of the check.
19
- * @param value - The value to check.
20
- */
21
- export declare function isAnyIterable<T = unknown>(value: any): value is Iterable<T>;
22
- /**
23
- * Checks if the given value is an async iterable.
24
- *
25
- * @template T - Allows asserting the element type. Not part of the check.
26
- * @param value - The value to check.
27
- */
28
- export declare function isAsyncIterable<T>(value: any): value is AsyncIterable<T>;
29
- export declare function isNextable<T>(value: any): value is Iterator<T> | AsyncIterator<T>;
30
- /**
31
- * Checks if the given value is a Doddle object.
32
- *
33
- * @param value - The value to check.
34
- * @returns True if the value is a Doddle object, false otherwise.
35
- */
36
- export declare function isDoddle<T>(value: any): value is {
37
- pull(): T;
38
- };
39
- //# sourceMappingURL=is-special.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-special.d.ts","sourceRoot":"","sources":["../../src/is-special.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAE9D;AACD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAE3E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,CAExE;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAGjF;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI;IAC9C,IAAI,IAAI,CAAC,CAAA;CACZ,CAEA"}
@@ -1,51 +0,0 @@
1
- import { isFunction, isInt, isObject } from "./is-basic.js";
2
- /**
3
- * Checks if the given value is array-like. It must be an object and have an integer `length`
4
- * property.
5
- *
6
- * @template T - Allows asserting the element type. Not part of the check.
7
- * @param value - The value to check.
8
- */
9
- export function isArrayLike(value) {
10
- return isObject(value) && !isFunction(value) && isInt(value.length);
11
- }
12
- /**
13
- * Checks if the given value is an object
14
- *
15
- * @param value - The value to check.
16
- */
17
- export function isIterable(value) {
18
- return isObject(value) && isFunction(value[Symbol.iterator]);
19
- }
20
- /**
21
- * Checks if the given value is an iterable or async iterable.
22
- *
23
- * @template T - Allows asserting the element type. Not part of the check.
24
- * @param value - The value to check.
25
- */
26
- export function isAnyIterable(value) {
27
- return isIterable(value) || isAsyncIterable(value);
28
- }
29
- /**
30
- * Checks if the given value is an async iterable.
31
- *
32
- * @template T - Allows asserting the element type. Not part of the check.
33
- * @param value - The value to check.
34
- */
35
- export function isAsyncIterable(value) {
36
- return isObject(value) && isFunction(value[Symbol.asyncIterator]);
37
- }
38
- export function isNextable(value) {
39
- // Checks if value is an iterator
40
- return isObject(value) && isFunction(value.next);
41
- }
42
- /**
43
- * Checks if the given value is a Doddle object.
44
- *
45
- * @param value - The value to check.
46
- * @returns True if the value is a Doddle object, false otherwise.
47
- */
48
- export function isDoddle(value) {
49
- return isObject(value) && typeof value.pull === "function" && typeof value.map === "function";
50
- }
51
- //# sourceMappingURL=is-special.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-special.js","sourceRoot":"","sources":["../../src/is-special.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE3D;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAI,KAAU;IACrC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AACvE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAI,KAAU;IACpC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAA;AAChE,CAAC;AACD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAc,KAAU;IACjD,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,CAAA;AACtD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAI,KAAU;IACzC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAA;AACrE,CAAC;AAED,MAAM,UAAU,UAAU,CAAI,KAAU;IACpC,iCAAiC;IACjC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAI,KAAU;IAGlC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,UAAU,CAAA;AACjG,CAAC"}
package/src/get-text.ts DELETED
@@ -1,115 +0,0 @@
1
- import {
2
- isBigInt,
3
- isFunction,
4
- isNullish,
5
- isObject,
6
- isString,
7
- isSymbol,
8
- isThenable
9
- } from "./is-basic.js"
10
- import { isAsyncIterable, isDoddle, isIterable, isNextable } from "./is-special.js"
11
-
12
- /**
13
- * Gets a short value type name, which can be used in a message.
14
- *
15
- * @param value - The value to check.
16
- */
17
- export function getNiceTypeOf(value: any) {
18
- return value === null ? "null" : typeof value
19
- }
20
- /**
21
- * Describes an object's class, type, or constructor name to be used in a message.
22
- *
23
- * - 📦 For an object, returns the name of its constructor or similar string.
24
- * - ⚙️ For a function (or class), returns the function's name.
25
- * - 🔠 For other values, returns the `typeof` string via {@link getNiceTypeOf}.
26
- *
27
- * @param something - The value whose class name or type is to be determined.
28
- */
29
- export function getNiceClassName(something: any) {
30
- if (isFunction(something)) {
31
- return getFunctionName(something)
32
- }
33
- if (!isObject(something)) {
34
- return getNiceTypeOf(something)
35
- }
36
- if (something === null) {
37
- return "null"
38
- }
39
-
40
- let name: string | undefined
41
- if (something.constructor) {
42
- name = getFunctionName(something.constructor)
43
- }
44
- return name && name !== "Object" ? name : (getObjectStringTag(something) ?? "Object")
45
- }
46
-
47
- export function getObjectStringTag(object: any) {
48
- return object[Symbol.toStringTag]
49
- }
50
- /**
51
- * Gets the description of a symbol.
52
- *
53
- * @param symbol - The symbol to get the description of.
54
- */
55
- export function getSymbolDescription(symbol: symbol) {
56
- return `${symbol.description}`
57
- }
58
-
59
- function _getShortObjectString(object: any) {
60
- if (isDoddle(object)) {
61
- return object.toString()
62
- }
63
- if (isIterable(object)) {
64
- return `iterable ${getNiceClassName(object)}`
65
- } else if (isAsyncIterable(object)) {
66
- return `async iterable ${getNiceClassName(object)}`
67
- } else if (isNextable(object)) {
68
- return `iterator ${getNiceClassName(object)}`
69
- } else if (isDoddle(object)) {
70
- return object.toString()
71
- } else if (isThenable(object)) {
72
- return `a Promise`
73
- } else {
74
- return `object ${getNiceClassName(object)}`
75
- }
76
- }
77
-
78
- /**
79
- * Gets a short string describing a value, to be used in a message.
80
- *
81
- * @param value - The value to describe.
82
- */
83
- export function getNiceValueName(value: any) {
84
- if (isNullish(value)) {
85
- return `${value}`
86
- }
87
- if (isFunction(value)) {
88
- return `function ${getFunctionName(value) || "<anonymous>"}`
89
- }
90
- if (isBigInt(value)) {
91
- return `${value}n`
92
- }
93
- if (isSymbol(value)) {
94
- return `Symbol(${getSymbolDescription(value)})`
95
- }
96
- if (isString(value)) {
97
- if (value.length > 30) {
98
- value = value.slice(0, 30) + "⋯"
99
- }
100
- return `"${value}"`
101
- }
102
- if (isObject(value)) {
103
- return _getShortObjectString(value)
104
- }
105
- return `${value}`
106
- }
107
-
108
- /**
109
- * Gets the name of a function, or null if it has no name.
110
- *
111
- * @param func - The function to get the name of.
112
- */
113
- export function getFunctionName(func: Function) {
114
- return func.name || undefined
115
- }
package/src/is-basic.ts DELETED
@@ -1,143 +0,0 @@
1
- /**
2
- * Checks if the given value is an object.
3
- *
4
- * @template T - The type of the value to check.
5
- * @param value - The value to test.
6
- */
7
- export function isObject<T>(value: T): value is T & {} {
8
- return typeof value === "object" && value != null
9
- }
10
-
11
- /**
12
- * Checks if the given value is a function.
13
- *
14
- * @param value - The value to check.
15
- */
16
- export function isFunction(value: unknown): value is Function {
17
- return typeof value === "function"
18
- }
19
-
20
- /**
21
- * Checks if the given value is a BigInt.
22
- *
23
- * @param value - The value to check.
24
- */
25
- export const isBigInt = (value: any): value is bigint => {
26
- return typeof value === "bigint"
27
- }
28
-
29
- /**
30
- * Checks if the given value is a string.
31
- *
32
- * @param value - The value to check.
33
- */
34
- export const isString = (value: any): value is string => {
35
- return typeof value === "string"
36
- }
37
- /**
38
- * Checks if the given value is acceptable as the key of a property.
39
- *
40
- * That is, whether it's a string, a number, or a symbol.
41
- *
42
- * @param value - The value to check.
43
- */
44
- export const isPropertyKey = (value: any): value is PropertyKey => {
45
- return isString(value) || isSymbol(value) || isNumber(value)
46
- }
47
-
48
- /**
49
- * Checks if the given value is null or undefined.
50
- *
51
- * @param value - The value to check.
52
- */
53
- export const isNullish = (value: any): value is null | undefined => {
54
- return value == null
55
- }
56
-
57
- /**
58
- * Checks if the given value is an array.
59
- *
60
- * @param value - The value to check.
61
- */
62
- export const isArray = Array.isArray
63
-
64
- /**
65
- * Checks if the given value is a thenable (i.e., a Promise or similar).
66
- *
67
- * @template T - Allows asserting the type of the resolved value. Not part of the check.
68
- * @param what - The value to check.
69
- */
70
- export const isThenable = <T = unknown>(what: unknown): what is PromiseLike<T> => {
71
- return isObject(what) && isFunction((what as any).then)
72
- }
73
-
74
- /**
75
- * Checks if the given value is a number.
76
- *
77
- * @param v - The value to check.
78
- */
79
- export const isNumber = (v: number) => +v === v
80
- /**
81
- * Checks if the given value is a number and can be represented exactly in JavaScript.
82
- *
83
- * That is, if it's a number in the range (-2⁵³, 2⁵³).
84
- *
85
- * @param v - The value to check.
86
- */
87
- export const isInt = Number.isSafeInteger
88
- /**
89
- * Checks if the given value is either a {@link isInt safe integer} or Infinity.
90
- *
91
- * @param v - The value to check.
92
- */
93
- export const isIntOrInfinity = (v: number) => isInt(v) || v === Infinity
94
-
95
- /**
96
- * Checks if the given value is a {@link isInt safe integer} and non-negative.
97
- *
98
- * @param v - The value to check.
99
- * @see {@link isInt}
100
- */
101
- export const isNat = (v: number) => isInt(v) && v >= 0
102
- /**
103
- * Checks if the given value is either a non-negative {@link isInt safe integer} or Infinity.
104
- *
105
- * @param v - The value to check.
106
- */
107
- export const isNatOrInfinity = (v: number) => isIntOrInfinity(v) && v >= 0
108
- /**
109
- * Checks if the given value is a boolean.
110
- *
111
- * @param value - The value to check.
112
- */
113
- export const isBool = (value: boolean) => !!value === value
114
- /**
115
- * Checks if the given value is not null or undefined.
116
- *
117
- * @param value - The value to check.
118
- */
119
- export const isNotNullish = (value: any) => !isNullish(value)
120
- /**
121
- * Checks if the given value is an array of two elements.
122
- *
123
- * @param value - The value to check.
124
- */
125
- export const isPair = (value: any) => isArray(value) && value.length === 2
126
- /**
127
- * Checks if the given value is a {@link isInt safe integer} and positive.
128
- *
129
- * @param value - The value to check.
130
- */
131
- export const isPosInt = (value: number) => isInt(value) && value > 0
132
- /**
133
- * Checks if the given value is an Error object.
134
- *
135
- * @param value - The value to check.
136
- */
137
- export const isError = (value: any) => value instanceof Error
138
- /**
139
- * Checks if the given value is a symbol.
140
- *
141
- * @param value - The value to check.
142
- */
143
- export const isSymbol = (value: any) => typeof value === "symbol"
package/src/is-special.ts DELETED
@@ -1,57 +0,0 @@
1
- import { isFunction, isInt, isObject } from "./is-basic.js"
2
-
3
- /**
4
- * Checks if the given value is array-like. It must be an object and have an integer `length`
5
- * property.
6
- *
7
- * @template T - Allows asserting the element type. Not part of the check.
8
- * @param value - The value to check.
9
- */
10
- export function isArrayLike<T>(value: any): value is ArrayLike<T> {
11
- return isObject(value) && !isFunction(value) && isInt(value.length)
12
- }
13
-
14
- /**
15
- * Checks if the given value is an object
16
- *
17
- * @param value - The value to check.
18
- */
19
- export function isIterable<T>(value: any): value is Iterable<T> {
20
- return isObject(value) && isFunction(value[Symbol.iterator])
21
- }
22
- /**
23
- * Checks if the given value is an iterable or async iterable.
24
- *
25
- * @template T - Allows asserting the element type. Not part of the check.
26
- * @param value - The value to check.
27
- */
28
- export function isAnyIterable<T = unknown>(value: any): value is Iterable<T> {
29
- return isIterable(value) || isAsyncIterable(value)
30
- }
31
-
32
- /**
33
- * Checks if the given value is an async iterable.
34
- *
35
- * @template T - Allows asserting the element type. Not part of the check.
36
- * @param value - The value to check.
37
- */
38
- export function isAsyncIterable<T>(value: any): value is AsyncIterable<T> {
39
- return isObject(value) && isFunction(value[Symbol.asyncIterator])
40
- }
41
-
42
- export function isNextable<T>(value: any): value is Iterator<T> | AsyncIterator<T> {
43
- // Checks if value is an iterator
44
- return isObject(value) && isFunction(value.next)
45
- }
46
-
47
- /**
48
- * Checks if the given value is a Doddle object.
49
- *
50
- * @param value - The value to check.
51
- * @returns True if the value is a Doddle object, false otherwise.
52
- */
53
- export function isDoddle<T>(value: any): value is {
54
- pull(): T
55
- } {
56
- return isObject(value) && typeof value.pull === "function" && typeof value.map === "function"
57
- }