@tb-dev/utils 4.0.0 → 4.0.2

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.
@@ -0,0 +1 @@
1
+ export * from './noop';
@@ -0,0 +1 @@
1
+ export declare const noop: () => void;
package/dist/index.cjs CHANGED
@@ -12,7 +12,7 @@ function isNil(value) {
12
12
  }
13
13
  const isNullish = isNil;
14
14
  function upsert(array, item, predicate) {
15
- const index = array.findIndex(predicate ?? ((it) => it === item));
15
+ const index = array.findIndex(predicate ?? ((value) => value === item));
16
16
  if (index === -1) {
17
17
  array.push(item);
18
18
  } else {
@@ -85,6 +85,8 @@ class PromiseSet {
85
85
  return set;
86
86
  }
87
87
  }
88
+ const noop = () => {
89
+ };
88
90
  function isEmpty(value) {
89
91
  if (isNullish(value)) {
90
92
  return true;
@@ -97,8 +99,6 @@ function isEmpty(value) {
97
99
  }
98
100
  return false;
99
101
  }
100
- const noop = () => {
101
- };
102
102
  function toPixel(value) {
103
103
  if (typeof value === "number" || typeof value === "string" && regex.float.test(value)) {
104
104
  return `${value}px`;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './regex';
5
5
  export * from './types';
6
6
  export * from './string';
7
7
  export * from './promise';
8
+ export * from './function';
8
9
  /**
9
10
  * Checks if a value is empty.
10
11
  *
@@ -15,6 +16,5 @@ export * from './promise';
15
16
  * Any other value is considered empty only if it is nullish.
16
17
  */
17
18
  export declare function isEmpty(value?: unknown): boolean;
18
- export declare const noop: () => void;
19
19
  /** Adds the pixel unit to a value. */
20
20
  export declare function toPixel(value: string | number): string;
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ function isNil(value) {
10
10
  }
11
11
  const isNullish = isNil;
12
12
  function upsert(array, item, predicate) {
13
- const index = array.findIndex(predicate ?? ((it) => it === item));
13
+ const index = array.findIndex(predicate ?? ((value) => value === item));
14
14
  if (index === -1) {
15
15
  array.push(item);
16
16
  } else {
@@ -83,6 +83,8 @@ class PromiseSet {
83
83
  return set;
84
84
  }
85
85
  }
86
+ const noop = () => {
87
+ };
86
88
  function isEmpty(value) {
87
89
  if (isNullish(value)) {
88
90
  return true;
@@ -95,8 +97,6 @@ function isEmpty(value) {
95
97
  }
96
98
  return false;
97
99
  }
98
- const noop = () => {
99
- };
100
100
  function toPixel(value) {
101
101
  if (typeof value === "number" || typeof value === "string" && regex.float.test(value)) {
102
102
  return `${value}px`;
@@ -1,2 +1,3 @@
1
- export declare function isNil(value: unknown): value is null | undefined;
1
+ import { Nil } from '../types';
2
+ export declare function isNil(value: unknown): value is Nil;
2
3
  export declare const isNullish: typeof isNil;
package/dist/types.d.ts CHANGED
@@ -9,8 +9,10 @@ export type MaybeArrayOrSet<T> = MaybeArray<T> | MaybeSet<T>;
9
9
  export type MaybePromise<T> = T | PromiseLike<T>;
10
10
  /** Something may be a Set. */
11
11
  export type MaybeSet<T> = T | Set<T>;
12
+ /** Null or undefined. */
13
+ export type Nil = null | undefined;
12
14
  /** Something may be nullish. */
13
- export type Nullish<T> = T | null | undefined;
15
+ export type Nullish<T> = T | Nil;
14
16
  /** Constructs a type where all properties of `T` may be null. */
15
17
  export type PartialNull<T> = {
16
18
  [P in keyof T]: T[P] | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/utils",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "TypeScript utils",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,24 +22,19 @@
22
22
  "utils",
23
23
  "typescript"
24
24
  ],
25
- "lint-staged": {
26
- "*.{?(c|m)@(j|t)s,css,vue,md,json}": "prettier --write"
27
- },
28
25
  "devDependencies": {
29
- "@tb-dev/eslint-config": "^5.3.4",
30
- "@types/node": "^22.7.4",
31
- "@vitest/ui": "^2.1.1",
32
- "eslint": "^9.11.1",
33
- "husky": "^9.1.6",
34
- "lint-staged": "^15.2.10",
26
+ "@tb-dev/eslint-config": "^5.4.8",
27
+ "@types/node": "^22.7.8",
28
+ "@vitest/ui": "^2.1.3",
29
+ "eslint": "^9.13.0",
35
30
  "prettier": "^3.3.3",
36
- "tslib": "^2.7.0",
37
- "typedoc": "^0.26.7",
38
- "typedoc-plugin-mdn-links": "^3.3.2",
39
- "typescript": "^5.6.2",
40
- "vite": "^5.4.8",
41
- "vite-plugin-dts": "^4.2.3",
42
- "vitest": "^2.1.1"
31
+ "tslib": "^2.8.0",
32
+ "typedoc": "^0.26.10",
33
+ "typedoc-plugin-mdn-links": "^3.3.4",
34
+ "typescript": "^5.6.3",
35
+ "vite": "^5.4.9",
36
+ "vite-plugin-dts": "^4.3.0",
37
+ "vitest": "^2.1.3"
43
38
  },
44
39
  "files": [
45
40
  "dist"
@@ -61,7 +56,7 @@
61
56
  "format-check": "prettier . --check",
62
57
  "lint": "eslint . --config eslint.config.js --cache",
63
58
  "lint-fix": "eslint . --config eslint.config.js --fix",
64
- "release": "pnpm run build && pnpm publish",
59
+ "release": "pnpm run test && pnpm run build && pnpm publish",
65
60
  "test": "vitest",
66
61
  "test:ui": "vitest --ui --watch",
67
62
  "type-check": "tsc --noEmit",