@tb-dev/utils 2.0.3 → 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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Andrew Ferreira
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Andrew Ferreira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs CHANGED
@@ -18,7 +18,7 @@ function isEmpty(value) {
18
18
  return false;
19
19
  }
20
20
  function isNullish(value) {
21
- return value === null || value === void 0;
21
+ return value === void 0 || value === null;
22
22
  }
23
23
  const noop = () => {
24
24
  };
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ function isEmpty(value) {
16
16
  return false;
17
17
  }
18
18
  function isNullish(value) {
19
- return value === null || value === void 0;
19
+ return value === void 0 || value === null;
20
20
  }
21
21
  const noop = () => {
22
22
  };
package/dist/panic.cjs CHANGED
@@ -1,19 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  function panic(...args) {
4
- throw new Error(args[0]);
4
+ throw new Error(args.join(" "));
5
5
  }
6
6
  function todo(...args) {
7
- const message = typeof args[0] === "string" ? args[0] : "todo";
8
- panic(message);
7
+ panic(format("TODO", args));
9
8
  }
10
9
  function unimplemented(...args) {
11
- const message = typeof args[0] === "string" ? args[0] : "not implemented";
12
- panic(message);
10
+ panic(format("not implemented", args));
13
11
  }
14
12
  function unreachable(...args) {
15
- const message = typeof args[0] === "string" ? args[0] : "unreachable";
16
- panic(message);
13
+ panic(format("unreachable", args));
14
+ }
15
+ function format(base, args) {
16
+ let message = base;
17
+ if (args.length > 0) {
18
+ message = `${message}: ${args.join(" ")}`;
19
+ }
20
+ return message;
17
21
  }
18
22
  exports.panic = panic;
19
23
  exports.todo = todo;
package/dist/panic.js CHANGED
@@ -1,17 +1,21 @@
1
1
  function panic(...args) {
2
- throw new Error(args[0]);
2
+ throw new Error(args.join(" "));
3
3
  }
4
4
  function todo(...args) {
5
- const message = typeof args[0] === "string" ? args[0] : "todo";
6
- panic(message);
5
+ panic(format("TODO", args));
7
6
  }
8
7
  function unimplemented(...args) {
9
- const message = typeof args[0] === "string" ? args[0] : "not implemented";
10
- panic(message);
8
+ panic(format("not implemented", args));
11
9
  }
12
10
  function unreachable(...args) {
13
- const message = typeof args[0] === "string" ? args[0] : "unreachable";
14
- panic(message);
11
+ panic(format("unreachable", args));
12
+ }
13
+ function format(base, args) {
14
+ let message = base;
15
+ if (args.length > 0) {
16
+ message = `${message}: ${args.join(" ")}`;
17
+ }
18
+ return message;
15
19
  }
16
20
  export {
17
21
  panic,
package/dist/string.cjs CHANGED
@@ -4,7 +4,7 @@ const array = require("./array.cjs");
4
4
  function splitWhitespace(value) {
5
5
  if (!value) return [];
6
6
  if (Array.isArray(value)) {
7
- const array2 = value.map((i) => splitWhitespace(i));
7
+ const array2 = value.map((it) => splitWhitespace(it));
8
8
  return array2.flat(Number.POSITIVE_INFINITY);
9
9
  }
10
10
  value = value.trim().split(/\s/);
package/dist/string.js CHANGED
@@ -2,7 +2,7 @@ import { trimArray } from "./array.js";
2
2
  function splitWhitespace(value) {
3
3
  if (!value) return [];
4
4
  if (Array.isArray(value)) {
5
- const array = value.map((i) => splitWhitespace(i));
5
+ const array = value.map((it) => splitWhitespace(it));
6
6
  return array.flat(Number.POSITIVE_INFINITY);
7
7
  }
8
8
  value = value.trim().split(/\s/);
package/dist/types.d.ts CHANGED
@@ -11,6 +11,10 @@ export type MaybePromise<T> = T | PromiseLike<T>;
11
11
  export type MaybeSet<T> = T | Set<T>;
12
12
  /** Something may be nullish. */
13
13
  export type Nullish<T> = T | null | undefined;
14
+ /** Constructs a type where all properties of `T` may be null. */
15
+ export type PartialNull<T> = {
16
+ [P in keyof T]: T[P] | null;
17
+ };
14
18
  /** Constructs a type where all properties of `T` may be nullish. */
15
19
  export type PartialNullish<T> = {
16
20
  [P in keyof T]?: Nullish<T[P]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/utils",
3
- "version": "2.0.3",
3
+ "version": "2.1.1",
4
4
  "description": "TypeScript utils",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,17 +27,17 @@
27
27
  "*.{?(c|m)@(j|t)s,vue}": "pnpm run lint"
28
28
  },
29
29
  "devDependencies": {
30
- "@tb-dev/eslint-config": "^4.4.2",
31
- "@types/node": "^22.0.0",
32
- "eslint": "^8.57.0",
33
- "husky": "^9.1.3",
34
- "lint-staged": "^15.2.7",
30
+ "@tb-dev/eslint-config": "^5.2.0",
31
+ "@types/node": "^22.2.0",
32
+ "eslint": "^9.9.0",
33
+ "husky": "^9.1.4",
34
+ "lint-staged": "^15.2.8",
35
35
  "prettier": "^3.3.3",
36
36
  "tslib": "^2.6.3",
37
37
  "typedoc": "^0.26.5",
38
- "typedoc-plugin-mdn-links": "^3.2.6",
38
+ "typedoc-plugin-mdn-links": "^3.2.8",
39
39
  "typescript": "^5.5.4",
40
- "vite": "^5.3.5",
40
+ "vite": "^5.4.0",
41
41
  "vite-plugin-dts": "^3.9.1"
42
42
  },
43
43
  "files": [