@magic/types 0.1.19 → 0.1.22
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 +13 -1
- package/package.json +7 -7
- package/src/fns.mjs +4 -21
package/README.md
CHANGED
|
@@ -284,5 +284,17 @@ deep.equal now does return true for objects that have undefined property values
|
|
|
284
284
|
##### 0.1.19
|
|
285
285
|
update dependencies
|
|
286
286
|
|
|
287
|
-
##### 0.1.20
|
|
287
|
+
##### 0.1.20
|
|
288
|
+
update dependencies
|
|
289
|
+
|
|
290
|
+
##### 0.1.21
|
|
291
|
+
* isBuffer uses Buffer.isBuffer.
|
|
292
|
+
* update dependencies
|
|
293
|
+
* getLength does not use .length or .size property for unknown types. instead we test for is.array, is.string, is.map etc.
|
|
294
|
+
|
|
295
|
+
##### 0.1.22
|
|
296
|
+
* update getLength to correctly return the length of buffers (regressed in 0.1.21).
|
|
297
|
+
* add a test case for buffer length
|
|
298
|
+
|
|
299
|
+
##### 0.1.23 - unreleased
|
|
288
300
|
...
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magic/types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"author": "Wizards & Witches",
|
|
5
5
|
"homepage": "https://github.com/magic/types",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"src"
|
|
35
35
|
],
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@magic-modules/git-badges": "0.0.
|
|
38
|
-
"@magic-modules/light-switch": "0.0.
|
|
39
|
-
"@magic-modules/no-spy": "0.0.
|
|
37
|
+
"@magic-modules/git-badges": "0.0.12",
|
|
38
|
+
"@magic-modules/light-switch": "0.0.11",
|
|
39
|
+
"@magic-modules/no-spy": "0.0.7",
|
|
40
40
|
"@magic-modules/pre": "0.0.11",
|
|
41
41
|
"@magic-themes/docs": "0.0.14",
|
|
42
|
-
"@magic/core": "0.0.
|
|
43
|
-
"@magic/format": "0.0.
|
|
44
|
-
"@magic/test": "0.2.
|
|
42
|
+
"@magic/core": "0.0.141",
|
|
43
|
+
"@magic/format": "0.0.40",
|
|
44
|
+
"@magic/test": "0.2.11"
|
|
45
45
|
},
|
|
46
46
|
"keywords": [
|
|
47
47
|
"magic",
|
package/src/fns.mjs
CHANGED
|
@@ -79,14 +79,11 @@ export const isEmpty = e => {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export const getLength = arg => {
|
|
82
|
-
if (
|
|
82
|
+
if (isArray(arg) || isString(arg) || isBuffer(arg)) {
|
|
83
83
|
return arg.length
|
|
84
|
-
} else if (
|
|
84
|
+
} else if (isInteger(arg)) {
|
|
85
85
|
return arg
|
|
86
|
-
} else if (arg
|
|
87
|
-
// arrays, strings
|
|
88
|
-
return arg.length
|
|
89
|
-
} else if (arg && isNumber(arg.size)) {
|
|
86
|
+
} else if (isMap(arg) || isWeakMap(arg) || isSet(arg) || isWeakSet(arg)) {
|
|
90
87
|
// Set, Map, WeakMap etc
|
|
91
88
|
return arg.size
|
|
92
89
|
} else if (isRegExp(arg)) {
|
|
@@ -127,21 +124,7 @@ export const isNull = e => e === null
|
|
|
127
124
|
|
|
128
125
|
export const isUndefinedOrNull = e => isNull(e) || !isDefined(e)
|
|
129
126
|
|
|
130
|
-
export const isBuffer = e =>
|
|
131
|
-
if (!e) {
|
|
132
|
-
return false
|
|
133
|
-
} else if (isEmpty(e)) {
|
|
134
|
-
return false
|
|
135
|
-
} else if (!isObject(e)) {
|
|
136
|
-
return false
|
|
137
|
-
} else if (!isFunction(e.copy)) {
|
|
138
|
-
return false
|
|
139
|
-
} else if (!isNumber(e[0])) {
|
|
140
|
-
return false
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return true
|
|
144
|
-
}
|
|
127
|
+
export const isBuffer = e => Buffer.isBuffer(e)
|
|
145
128
|
|
|
146
129
|
export const isPromise = e => e && isFunction(e.then)
|
|
147
130
|
export const isThenable = isPromise
|