@reflexions/string-to-boolean 1.0.0 → 1.1.0
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/dist/cjs/StringToBoolean.d.ts +6 -0
- package/dist/cjs/StringToBoolean.d.ts.map +1 -0
- package/dist/cjs/StringToBoolean.js +14 -0
- package/dist/cjs/StringToBoolean.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/StringToBoolean.d.ts +6 -0
- package/dist/esm/StringToBoolean.d.ts.map +1 -0
- package/dist/esm/StringToBoolean.js +12 -0
- package/dist/esm/StringToBoolean.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/package.json +18 -4
- package/cjs/StringToBoolean.cjs +0 -15
- package/esm/StringToBoolean.mjs +0 -13
- package/publish.sh +0 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a string to a boolean, treating '0', 'false', 'FALSE', 'off' and falsy values like '' to false, the rest to true.
|
|
3
|
+
*/
|
|
4
|
+
declare const stringToBoolean: (value: string | boolean | number | null | undefined) => Boolean;
|
|
5
|
+
export default stringToBoolean;
|
|
6
|
+
//# sourceMappingURL=StringToBoolean.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StringToBoolean.d.ts","sourceRoot":"","sources":["../../src/StringToBoolean.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,eAAe,GAAI,OAAO,MAAM,GAAC,OAAO,GAAC,MAAM,GAAC,IAAI,GAAC,SAAS,KAAG,OAMrD,CAAC;AAEnB,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Converts a string to a boolean, treating '0', 'false', 'FALSE', 'off' and falsy values like '' to false, the rest to true.
|
|
5
|
+
*/
|
|
6
|
+
const stringToBoolean = (value) => (typeof value === 'boolean')
|
|
7
|
+
? value // param is already boolean
|
|
8
|
+
: (typeof value === 'string')
|
|
9
|
+
? ['0', 'false', 'off'].includes(value.toLowerCase())
|
|
10
|
+
? false
|
|
11
|
+
: Boolean(value) // returns false for ''; true for non-empty string
|
|
12
|
+
: Boolean(value); // returns false for null or undefined, true for objects
|
|
13
|
+
exports.default = stringToBoolean;
|
|
14
|
+
//# sourceMappingURL=StringToBoolean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StringToBoolean.js","sourceRoot":"","sources":["../../src/StringToBoolean.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,KAA2C,EAAW,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,SAAS,CAAC;IAC7G,CAAC,CAAC,KAAK,CAAC,2BAA2B;IACnC,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;QAC5B,CAAC,CAAC,CAAE,GAAG,EAAE,OAAO,EAAE,KAAK,CAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YACtD,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,kDAAkD;QACpE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,wDAAwD;AAE5E,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "commonjs"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a string to a boolean, treating '0', 'false', 'FALSE', 'off' and falsy values like '' to false, the rest to true.
|
|
3
|
+
*/
|
|
4
|
+
declare const stringToBoolean: (value: string | boolean | number | null | undefined) => Boolean;
|
|
5
|
+
export default stringToBoolean;
|
|
6
|
+
//# sourceMappingURL=StringToBoolean.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StringToBoolean.d.ts","sourceRoot":"","sources":["../../src/StringToBoolean.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,eAAe,GAAI,OAAO,MAAM,GAAC,OAAO,GAAC,MAAM,GAAC,IAAI,GAAC,SAAS,KAAG,OAMrD,CAAC;AAEnB,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a string to a boolean, treating '0', 'false', 'FALSE', 'off' and falsy values like '' to false, the rest to true.
|
|
3
|
+
*/
|
|
4
|
+
const stringToBoolean = (value) => (typeof value === 'boolean')
|
|
5
|
+
? value // param is already boolean
|
|
6
|
+
: (typeof value === 'string')
|
|
7
|
+
? ['0', 'false', 'off'].includes(value.toLowerCase())
|
|
8
|
+
? false
|
|
9
|
+
: Boolean(value) // returns false for ''; true for non-empty string
|
|
10
|
+
: Boolean(value); // returns false for null or undefined, true for objects
|
|
11
|
+
export default stringToBoolean;
|
|
12
|
+
//# sourceMappingURL=StringToBoolean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StringToBoolean.js","sourceRoot":"","sources":["../../src/StringToBoolean.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,KAA2C,EAAW,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,SAAS,CAAC;IAC7G,CAAC,CAAC,KAAK,CAAC,2BAA2B;IACnC,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;QAC5B,CAAC,CAAC,CAAE,GAAG,EAAE,OAAO,EAAE,KAAK,CAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YACtD,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,kDAAkD;QACpE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,wDAAwD;AAE5E,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "module"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reflexions/string-to-boolean",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
|
-
"require":
|
|
8
|
-
|
|
7
|
+
"require": {
|
|
8
|
+
"default": "./dist/cjs/StringToBoolean.js",
|
|
9
|
+
"types": "./dist/cjs/StringToBoolean.d.ts"
|
|
10
|
+
},
|
|
11
|
+
"import": {
|
|
12
|
+
"default": "./dist/esm/StringToBoolean.js",
|
|
13
|
+
"types": "./dist/esm/StringToBoolean.d.ts"
|
|
14
|
+
}
|
|
9
15
|
}
|
|
10
16
|
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.9.2"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/**/*"
|
|
22
|
+
],
|
|
11
23
|
"keywords": [],
|
|
24
|
+
"type": "module",
|
|
12
25
|
"author": "Reflexions Data, LLC",
|
|
13
|
-
"license": "ISC"
|
|
26
|
+
"license": "ISC",
|
|
27
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
14
28
|
}
|
package/cjs/StringToBoolean.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Converts a string to a boolean, treating '0', 'false', 'FALSE', 'off' and falsy values like '' to false, the rest to true.
|
|
5
|
-
* @param {string|boolean} value
|
|
6
|
-
*/
|
|
7
|
-
const stringToBoolean = (value) => typeof value === 'boolean'
|
|
8
|
-
? value // param is already boolean
|
|
9
|
-
: typeof value === 'string'
|
|
10
|
-
? [ '0', 'false', 'off' ].includes(value.toLowerCase())
|
|
11
|
-
? false
|
|
12
|
-
: Boolean(value) // returns false for ''; true for non-empty string
|
|
13
|
-
: Boolean(value); // returns false for null or undefined, true for objects
|
|
14
|
-
|
|
15
|
-
module.exports = stringToBoolean;
|
package/esm/StringToBoolean.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a string to a boolean, treating '0', 'false', 'FALSE', 'off' and falsy values like '' to false, the rest to true.
|
|
3
|
-
* @param {string|boolean} value
|
|
4
|
-
*/
|
|
5
|
-
const stringToBoolean = (value) => typeof value === 'boolean'
|
|
6
|
-
? value // param is already boolean
|
|
7
|
-
: typeof value === 'string'
|
|
8
|
-
? [ '0', 'false', 'off' ].includes(value.toLowerCase())
|
|
9
|
-
? false
|
|
10
|
-
: Boolean(value) // returns false for ''; true for non-empty string
|
|
11
|
-
: Boolean(value); // returns false for null or undefined, true for objects
|
|
12
|
-
|
|
13
|
-
export default stringToBoolean;
|
package/publish.sh
DELETED