bare-script 2.2.14 → 2.2.15
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/lib/library.js +22 -0
- package/package.json +1 -1
package/lib/library.js
CHANGED
|
@@ -995,6 +995,28 @@ export const scriptFunctions = {
|
|
|
995
995
|
// $return: The new function called with "args"
|
|
996
996
|
'systemPartial': ([func, ...args]) => (argsExtra, options) => func([...args, ...argsExtra], options),
|
|
997
997
|
|
|
998
|
+
// $function: systemType
|
|
999
|
+
// $group: System
|
|
1000
|
+
// $doc: Get a value's type string
|
|
1001
|
+
// $arg value: The value
|
|
1002
|
+
// $return: The type string of the value.
|
|
1003
|
+
// $return: Valid values are: 'array', 'boolean', 'datetime', 'function', 'null', 'number', 'object', 'regex', 'string'.
|
|
1004
|
+
'systemType': ([value]) => {
|
|
1005
|
+
const type = typeof value;
|
|
1006
|
+
if (type === 'object') {
|
|
1007
|
+
if (value === null) {
|
|
1008
|
+
return 'null';
|
|
1009
|
+
} else if (Array.isArray(value)) {
|
|
1010
|
+
return 'array';
|
|
1011
|
+
} else if (value instanceof Date) {
|
|
1012
|
+
return 'datetime';
|
|
1013
|
+
} else if (value instanceof RegExp) {
|
|
1014
|
+
return 'regex';
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
return type;
|
|
1018
|
+
},
|
|
1019
|
+
|
|
998
1020
|
|
|
999
1021
|
//
|
|
1000
1022
|
// URL functions
|