@tb-dev/utils 3.0.3 → 3.2.0

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.
@@ -1,4 +1,3 @@
1
1
  import { MaybeArray, Nullish } from '../types';
2
-
3
2
  /** Converts the item to an array if it isn't already. */
4
3
  export declare function toArray<T>(item?: Nullish<MaybeArray<T>>): T[];
package/dist/index.cjs CHANGED
@@ -69,6 +69,13 @@ class PromiseSet {
69
69
  await Promise.all(this.promises);
70
70
  this.promises.clear();
71
71
  }
72
+ static from(promises) {
73
+ const set = new PromiseSet();
74
+ for (const promise of promises) {
75
+ set.promises.add(promise);
76
+ }
77
+ return set;
78
+ }
72
79
  }
73
80
  function flushPromises() {
74
81
  return new Promise((resolve) => void setTimeout(resolve, 0));
package/dist/index.js CHANGED
@@ -67,6 +67,13 @@ class PromiseSet {
67
67
  await Promise.all(this.promises);
68
68
  this.promises.clear();
69
69
  }
70
+ static from(promises) {
71
+ const set = new PromiseSet();
72
+ for (const promise of promises) {
73
+ set.promises.add(promise);
74
+ }
75
+ return set;
76
+ }
70
77
  }
71
78
  function flushPromises() {
72
79
  return new Promise((resolve) => void setTimeout(resolve, 0));
@@ -2,4 +2,5 @@ export declare class PromiseSet {
2
2
  private readonly promises;
3
3
  and(promise: Promise<any>): this;
4
4
  join(): Promise<void>;
5
+ static from(promises: Iterable<Promise<any>>): PromiseSet;
5
6
  }
@@ -1,5 +1,4 @@
1
1
  import { Nullish } from '../types';
2
-
3
2
  /**
4
3
  * Splits a string or an array of strings (recursively) by whitespace.
5
4
  *
package/dist/types.d.ts CHANGED
@@ -27,6 +27,9 @@ export type PickByValue<T, V> = {
27
27
  export type PickPartial<T, K extends keyof T> = Pick<Partial<T>, K>;
28
28
  /** Constructs a type by picking the set of properties `K` from a required version of `T`. */
29
29
  export type PickRequired<T, K extends keyof T> = Pick<Required<T>, K>;
30
+ export type Writeable<T> = {
31
+ -readonly [P in keyof T]: T[P];
32
+ };
30
33
  /** Constructs a type consisting of some properties of T set to partial. */
31
34
  export type WithPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
32
35
  /** Constructs a type consisting of some properties of T set to partial. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/utils",
3
- "version": "3.0.3",
3
+ "version": "3.2.0",
4
4
  "description": "TypeScript utils",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,18 +27,18 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@tb-dev/eslint-config": "^5.2.0",
30
- "@types/node": "^22.2.0",
30
+ "@types/node": "^22.3.0",
31
31
  "@vitest/ui": "^2.0.5",
32
32
  "eslint": "^9.9.0",
33
33
  "husky": "^9.1.4",
34
- "lint-staged": "^15.2.8",
34
+ "lint-staged": "^15.2.9",
35
35
  "prettier": "^3.3.3",
36
36
  "tslib": "^2.6.3",
37
37
  "typedoc": "^0.26.5",
38
38
  "typedoc-plugin-mdn-links": "^3.2.8",
39
39
  "typescript": "^5.5.4",
40
40
  "vite": "^5.4.0",
41
- "vite-plugin-dts": "^3.9.1",
41
+ "vite-plugin-dts": "^4.0.3",
42
42
  "vitest": "^2.0.5"
43
43
  },
44
44
  "files": [