@salespark/toolkit 2.1.0 → 2.1.1

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/index.cjs CHANGED
@@ -135,6 +135,33 @@ function flattenDepth(array, depth = 1, options) {
135
135
  return flattenDepthBase(array, depth, predicate, isStrict);
136
136
  }
137
137
 
138
+ // src/utils/bool.ts
139
+ var toBool = (value, def = false) => {
140
+ try {
141
+ if (value === null || value === void 0) return def;
142
+ if (typeof value === "boolean") return value;
143
+ if (typeof value === "number") return value === 1;
144
+ if (typeof value === "string") {
145
+ switch (value.toLowerCase().trim()) {
146
+ case "true":
147
+ case "yes":
148
+ case "1":
149
+ return true;
150
+ case "false":
151
+ case "no":
152
+ case "0":
153
+ return false;
154
+ default:
155
+ return def;
156
+ }
157
+ }
158
+ return def;
159
+ } catch {
160
+ return false;
161
+ }
162
+ };
163
+ var parseToBool = toBool;
164
+
138
165
  // src/utils/object.ts
139
166
  function pick(obj, keys) {
140
167
  const out = {};
@@ -1618,6 +1645,7 @@ exports.objectToString = objectToString;
1618
1645
  exports.omit = omit;
1619
1646
  exports.otp = otp;
1620
1647
  exports.parseName = parseName;
1648
+ exports.parseToBool = parseToBool;
1621
1649
  exports.parseToNumber = parseToNumber;
1622
1650
  exports.pick = pick;
1623
1651
  exports.pluck = pluck;
@@ -1634,6 +1662,7 @@ exports.sortBy = sortBy;
1634
1662
  exports.stringSimilarity = stringSimilarity;
1635
1663
  exports.symbolToCurrency = symbolToCurrency;
1636
1664
  exports.throttle = throttle;
1665
+ exports.toBool = toBool;
1637
1666
  exports.toInteger = toInteger;
1638
1667
  exports.toNumber = toNumber;
1639
1668
  exports.uniq = uniq;