@salespark/toolkit 2.1.16 → 2.1.17

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 CHANGED
@@ -544,6 +544,22 @@ isNilOrEmpty(undefined);
544
544
  // Result: true
545
545
  ```
546
546
 
547
+ **`isNilEmptyOrEmptyObject(value: unknown): boolean`** — Checks if value is nil, empty string, or an empty plain object (no own keys).
548
+
549
+ ```javascript
550
+ isNilEmptyOrEmptyObject(null);
551
+ // Result: true
552
+
553
+ isNilEmptyOrEmptyObject("");
554
+ // Result: true
555
+
556
+ isNilEmptyOrEmptyObject({});
557
+ // Result: true
558
+
559
+ isNilEmptyOrEmptyObject({ a: 1 });
560
+ // Result: false
561
+ ```
562
+
547
563
  **`hasNilOrEmpty(array: unknown): boolean`** — Checks if any element in array is nil or empty.
548
564
 
549
565
  ```javascript
@@ -836,17 +852,17 @@ assessSecurityRisks([]);
836
852
  // Result: { score: 0, level: "safe", recommendations: ["Content appears safe to use"] }
837
853
  ```
838
854
 
839
- **`scrambleString(value: string, secret: string): SalesParkContract<object>`** — Scrambles a string using a repeating secret (XOR) and Base64. Reversible obfuscation only (not crypto).
855
+ **`encodeString(input: string, secret: string): SalesParkContract<any>`** — Base64-encodes a string and scrambles it with the provided secret (obfuscation only).
840
856
 
841
857
  ```javascript
842
- const scrambled = scrambleString("Hello", "secret");
858
+ const encoded = encodeString("Hello", "secret");
843
859
  // Result: { status: true, data: "..." }
844
860
 
845
- const original = descrambleString(scrambled.data, "secret");
861
+ const decoded = decodeString(encoded.data, "secret");
846
862
  // Result: { status: true, data: "Hello" }
847
863
  ```
848
864
 
849
- **`descrambleString(value: string, secret: string): SalesParkContract<object>`** — Reverses `scrambleString` using the same secret.
865
+ **`decodeString(encoded: string, secret: string): SalesParkContract<any>`** — Reverses `encodeString` using the same secret.
850
866
 
851
867
  **`encodeObject(input: object, secret: string): SalesParkContract<object>`** — JSON-stringifies an object, Base64-encodes it, and scrambles the result (obfuscation only).
852
868
 
@@ -993,5 +1009,5 @@ MIT © [SalesPark](https://salespark.io)
993
1009
 
994
1010
  ---
995
1011
 
996
- _Document version: 13_
997
- _Last update: 09-01-2026_
1012
+ _Document version: 14_
1013
+ _Last update: 06-02-2026_
package/dist/index.cjs CHANGED
@@ -506,6 +506,17 @@ var isNilOrEmpty = (value) => {
506
506
  return true;
507
507
  }
508
508
  };
509
+ var isNilEmptyOrEmptyObject = (value) => {
510
+ try {
511
+ if (isNilOrEmpty(value)) return true;
512
+ if (typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0) {
513
+ return true;
514
+ }
515
+ return false;
516
+ } catch {
517
+ return true;
518
+ }
519
+ };
509
520
  var hasNilOrEmpty = (array) => {
510
521
  try {
511
522
  if (!Array.isArray(array)) return true;
@@ -1881,6 +1892,24 @@ var encodeObject = (input, secret) => {
1881
1892
  return { status: false, data: error };
1882
1893
  }
1883
1894
  };
1895
+ var encodeString = (input, secret) => {
1896
+ try {
1897
+ if (typeof input !== "string") {
1898
+ return { status: false, data: "Input must be a string" };
1899
+ }
1900
+ if (!secret || typeof secret !== "string") {
1901
+ return { status: false, data: "Secret must be a non-empty string" };
1902
+ }
1903
+ const base64 = toBase64(input);
1904
+ const scrambledResponse = scrambleString(base64, secret);
1905
+ if (!scrambledResponse.status) {
1906
+ return { status: false, data: "Scrambling failed" };
1907
+ }
1908
+ return { status: true, data: scrambledResponse.data };
1909
+ } catch (error) {
1910
+ return { status: false, data: error };
1911
+ }
1912
+ };
1884
1913
  var decodeObject = (encoded, secret) => {
1885
1914
  try {
1886
1915
  if (typeof encoded !== "string") {
@@ -1899,6 +1928,24 @@ var decodeObject = (encoded, secret) => {
1899
1928
  return { status: false, data: error };
1900
1929
  }
1901
1930
  };
1931
+ var decodeString = (encoded, secret) => {
1932
+ try {
1933
+ if (typeof encoded !== "string") {
1934
+ return { status: false, data: "Encoded value must be a string" };
1935
+ }
1936
+ if (!secret || typeof secret !== "string") {
1937
+ return { status: false, data: "Secret must be a non-empty string" };
1938
+ }
1939
+ const descrambledResponse = descrambleString(encoded, secret);
1940
+ if (!descrambledResponse.status) {
1941
+ return { status: false, data: "Descrambling failed" };
1942
+ }
1943
+ const value = fromBase64(descrambledResponse.data);
1944
+ return { status: true, data: value };
1945
+ } catch (error) {
1946
+ return { status: false, data: error };
1947
+ }
1948
+ };
1902
1949
 
1903
1950
  // src/utils/defer.ts
1904
1951
  var swallow = (p) => p.catch(() => {
@@ -2005,14 +2052,15 @@ exports.currencyToSymbol = currencyToSymbol;
2005
2052
  exports.debounce = debounce;
2006
2053
  exports.deburr = deburr;
2007
2054
  exports.decodeObject = decodeObject;
2055
+ exports.decodeString = decodeString;
2008
2056
  exports.deferAfterResponse = deferAfterResponse;
2009
2057
  exports.deferAfterResponseNonCritical = deferAfterResponseNonCritical;
2010
2058
  exports.deferNonCritical = deferNonCritical;
2011
2059
  exports.deferPostReturn = deferPostReturn;
2012
2060
  exports.delay = delay;
2013
- exports.descrambleString = descrambleString;
2014
2061
  exports.difference = difference;
2015
2062
  exports.encodeObject = encodeObject;
2063
+ exports.encodeString = encodeString;
2016
2064
  exports.fill = fill;
2017
2065
  exports.flatten = flatten;
2018
2066
  exports.flattenDepth = flattenDepth;
@@ -2030,6 +2078,7 @@ exports.intersection = intersection;
2030
2078
  exports.isBrowser = isBrowser;
2031
2079
  exports.isFlattenable = isFlattenable;
2032
2080
  exports.isNil = isNil;
2081
+ exports.isNilEmptyOrEmptyObject = isNilEmptyOrEmptyObject;
2033
2082
  exports.isNilEmptyOrZeroLen = isNilEmptyOrZeroLen;
2034
2083
  exports.isNilEmptyOrZeroLength = isNilEmptyOrZeroLength;
2035
2084
  exports.isNilOrEmpty = isNilOrEmpty;
@@ -2072,7 +2121,6 @@ exports.safeParseInt = safeParseInt;
2072
2121
  exports.safeSubtract = safeSubtract;
2073
2122
  exports.sanitize = sanitize;
2074
2123
  exports.sanitizeMarkdown = sanitizeMarkdown;
2075
- exports.scrambleString = scrambleString;
2076
2124
  exports.sentenceCase = sentenceCase;
2077
2125
  exports.shuffle = shuffle;
2078
2126
  exports.slugify = slugify;