@magic/types 0.1.20 → 0.1.21
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 +6 -1
- package/package.json +4 -4
- package/src/fns.mjs +4 -21
package/README.md
CHANGED
|
@@ -287,5 +287,10 @@ update dependencies
|
|
|
287
287
|
##### 0.1.20
|
|
288
288
|
update dependencies
|
|
289
289
|
|
|
290
|
-
##### 0.1.21
|
|
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 - unreleased
|
|
291
296
|
...
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magic/types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"author": "Wizards & Witches",
|
|
5
5
|
"homepage": "https://github.com/magic/types",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
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)) {
|
|
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
|