@jeniex/utils 1.1.3 → 1.1.4

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/browser/index.cjs CHANGED
@@ -54,6 +54,11 @@ function asserted(object) {
54
54
  }
55
55
  return object;
56
56
  }
57
+ function stringOrThrow(value) {
58
+ if (!isString(value)) {
59
+ throw new Error('Expected a string.');
60
+ }
61
+ }
57
62
  function isTruthy(object) {
58
63
  return Boolean(object) === true;
59
64
  }
@@ -505,5 +510,6 @@ exports.saveFile = saveFile;
505
510
  exports.scriptName = scriptName;
506
511
  exports.setSearchParam = setSearchParam;
507
512
  exports.sleep = sleep;
513
+ exports.stringOrThrow = stringOrThrow;
508
514
  exports.tabURL = tabURL;
509
515
  exports.toString = toString;
@@ -17,6 +17,7 @@ declare function noop(): void;
17
17
  declare function toString(object: unknown): string;
18
18
 
19
19
  declare function asserted<T>(object: T | null | undefined): T;
20
+ declare function stringOrThrow(value: unknown): asserts value is string;
20
21
  declare function isTruthy<T>(object: T): object is Exclude<T, '' | 0 | false | null | undefined>;
21
22
  declare function isFalsy(object: unknown): object is '' | 0 | false | null | undefined;
22
23
  declare function isNullish(object: unknown): object is null | undefined;
@@ -167,4 +168,4 @@ interface CustomizedConsole {
167
168
 
168
169
  declare function customizeConsole(debug?: boolean): CustomizedConsole;
169
170
 
170
- export { $, $$, Flag, Fn, Nullable, Prettify, addStyle, alert, asserted, capitalize, checkVPN, checkVPNRandomly, confirm, customizeConsole, fish, fishResponse, fishX, fishXResponse, getOptions, getSearchParam, imageLoad, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, noop, padZeros, pageLoad, prompt, remove, removeSearchParams, saveFile, scriptName, setSearchParam, sleep, tabURL, toString };
171
+ export { $, $$, Flag, Fn, Nullable, Prettify, addStyle, alert, asserted, capitalize, checkVPN, checkVPNRandomly, confirm, customizeConsole, fish, fishResponse, fishX, fishXResponse, getOptions, getSearchParam, imageLoad, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, noop, padZeros, pageLoad, prompt, remove, removeSearchParams, saveFile, scriptName, setSearchParam, sleep, stringOrThrow, tabURL, toString };
package/browser/index.js CHANGED
@@ -52,6 +52,11 @@ function asserted(object) {
52
52
  }
53
53
  return object;
54
54
  }
55
+ function stringOrThrow(value) {
56
+ if (!isString(value)) {
57
+ throw new Error('Expected a string.');
58
+ }
59
+ }
55
60
  function isTruthy(object) {
56
61
  return Boolean(object) === true;
57
62
  }
@@ -466,4 +471,4 @@ function customizeConsole(debug = false) {
466
471
  };
467
472
  }
468
473
 
469
- export { $, $$, addStyle, alert, asserted, capitalize, checkVPN, checkVPNRandomly, confirm, customizeConsole, fish, fishResponse, fishX, fishXResponse, getOptions, getSearchParam, imageLoad, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, noop, padZeros, pageLoad, prompt, remove, removeSearchParams, saveFile, scriptName, setSearchParam, sleep, tabURL, toString };
474
+ export { $, $$, addStyle, alert, asserted, capitalize, checkVPN, checkVPNRandomly, confirm, customizeConsole, fish, fishResponse, fishX, fishXResponse, getOptions, getSearchParam, imageLoad, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, noop, padZeros, pageLoad, prompt, remove, removeSearchParams, saveFile, scriptName, setSearchParam, sleep, stringOrThrow, tabURL, toString };
package/node/index.cjs CHANGED
@@ -58,6 +58,11 @@ function asserted(object) {
58
58
  }
59
59
  return object;
60
60
  }
61
+ function stringOrThrow(value) {
62
+ if (!isString(value)) {
63
+ throw new Error('Expected a string.');
64
+ }
65
+ }
61
66
  function isTruthy(object) {
62
67
  return Boolean(object) === true;
63
68
  }
@@ -260,4 +265,5 @@ exports.readJSON = readJSON;
260
265
  exports.remove = remove;
261
266
  exports.removeFiles = removeFiles;
262
267
  exports.sleep = sleep;
268
+ exports.stringOrThrow = stringOrThrow;
263
269
  exports.toString = toString;
package/node/index.d.ts CHANGED
@@ -17,6 +17,7 @@ declare function noop(): void;
17
17
  declare function toString(object: unknown): string;
18
18
 
19
19
  declare function asserted<T>(object: T | null | undefined): T;
20
+ declare function stringOrThrow(value: unknown): asserts value is string;
20
21
  declare function isTruthy<T>(object: T): object is Exclude<T, '' | 0 | false | null | undefined>;
21
22
  declare function isFalsy(object: unknown): object is '' | 0 | false | null | undefined;
22
23
  declare function isNullish(object: unknown): object is null | undefined;
@@ -109,4 +110,4 @@ declare function removeFiles({ folderPath, filter }: RemoveFilesOpt): Promise<vo
109
110
 
110
111
  declare function readJSON<T = object>(filePath: string, withComments?: boolean): Promise<T>;
111
112
 
112
- export { Fn, Nullable, Prettify, asserted, capitalize, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, listFiles, listFolders, listFoldersSync, noop, padZeros, readJSON, remove, removeFiles, sleep, toString };
113
+ export { Fn, Nullable, Prettify, asserted, capitalize, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, listFiles, listFolders, listFoldersSync, noop, padZeros, readJSON, remove, removeFiles, sleep, stringOrThrow, toString };
package/node/index.js CHANGED
@@ -56,6 +56,11 @@ function asserted(object) {
56
56
  }
57
57
  return object;
58
58
  }
59
+ function stringOrThrow(value) {
60
+ if (!isString(value)) {
61
+ throw new Error('Expected a string.');
62
+ }
63
+ }
59
64
  function isTruthy(object) {
60
65
  return Boolean(object) === true;
61
66
  }
@@ -237,4 +242,4 @@ async function readJSON(filePath, withComments = false) {
237
242
  return JSON.parse(stringJSON);
238
243
  }
239
244
 
240
- export { asserted, capitalize, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, listFiles, listFolders, listFoldersSync, noop, padZeros, readJSON, remove, removeFiles, sleep, toString };
245
+ export { asserted, capitalize, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, listFiles, listFolders, listFoldersSync, noop, padZeros, readJSON, remove, removeFiles, sleep, stringOrThrow, toString };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeniex/utils",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "author": "JenieX",
5
5
  "homepage": "https://github.com/JenieX/utils",
6
6
  "type": "module",