@esmalley/ts-utils 6.4.5 → 7.0.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,14 @@
1
1
  export declare class Textor {
2
+ /**
3
+ * Convert camelCase or PascalCase to kebab-case.
4
+ *
5
+ * Used to turn CSS-in-JS property names into real CSS properties, but it is
6
+ * general purpose.
7
+ *
8
+ * @example
9
+ * Textor.toKebabCase('backgroundColor'); // 'background-color'
10
+ */
11
+ static toKebabCase(str: string): string;
2
12
  static levenshtein(a: string, b: string): number;
3
13
  static toSentenceCase(str: string): string;
4
14
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Textor.d.ts","sourceRoot":"","sources":["../../src/Textor.ts"],"names":[],"mappings":"AAcA,qBAAa,MAAM;WACH,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;WAgCzC,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAYjD;;OAEG;WACW,kBAAkB,CAC9B,UAAU,SAAI,EACd,qBAAqB,SAAI,EACzB,cAAc,UAAO,GACpB,MAAM;CA+DV"}
1
+ {"version":3,"file":"Textor.d.ts","sourceRoot":"","sources":["../../src/Textor.ts"],"names":[],"mappings":"AAcA,qBAAa,MAAM;IACjB;;;;;;;;OAQG;WACW,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;WAIhC,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;WAqCzC,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAYjD;;OAEG;WACW,kBAAkB,CAC9B,UAAU,SAAI,EACd,qBAAqB,SAAI,EACzB,cAAc,UAAO,GACpB,MAAM;CA+DV"}
@@ -8,10 +8,35 @@ export type ToastListener = (toasts: ToastItem[]) => void;
8
8
  export declare class Toaster {
9
9
  private listeners;
10
10
  private toasts;
11
+ private nextId;
12
+ static readonly EXIT_ANIMATION_MS = 500;
13
+ static readonly AUTO_DISMISS_MS = 4000;
14
+ /**
15
+ * The current toasts.
16
+ *
17
+ * Returns a copy, so callers cannot mutate the internal list.
18
+ */
19
+ getToasts(): ToastItem[];
11
20
  subscribe(listener: ToastListener): () => void;
12
21
  notify(): void;
22
+ /**
23
+ * Start a toast's exit: flag it so the UI can animate, then drop it once the
24
+ * animation has had time to play.
25
+ *
26
+ * Calling this twice for the same toast does not schedule a second removal.
27
+ */
13
28
  requestClose(id: number): void;
14
- add(message: string, type?: string): void;
29
+ /**
30
+ * Add a toast and return its id, so callers can dismiss it early.
31
+ */
32
+ add(message: string, type?: string): number;
33
+ /**
34
+ * Remove a toast immediately, without waiting for an exit animation.
35
+ *
36
+ * Removing an id that is not present is silent: it broadcasts nothing, so a
37
+ * consumer that has already removed the toast itself does not get a
38
+ * redundant re-render from the safety-net removal in `requestClose`.
39
+ */
15
40
  remove(id: number): void;
16
41
  }
17
42
  export declare const toaster: Toaster;
@@ -1 +1 @@
1
- {"version":3,"file":"Toaster.d.ts","sourceRoot":"","sources":["../../src/Toaster.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAGD,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;AAE1D,qBAAa,OAAO;IAClB,OAAO,CAAC,SAAS,CAAuB;IAExC,OAAO,CAAC,MAAM,CAAmB;IAGjC,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI;IAO9C,MAAM,IAAI,IAAI;IAId,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAU9B,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAS,GAAG,IAAI;IAWzC,MAAM,CAAC,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AG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAKhC,CAAC"}
@@ -4,16 +4,23 @@
4
4
  declare class UuidService {
5
5
  private lastTimestamp;
6
6
  private seqCounter;
7
+ /**
8
+ * Whether a string is a well-formed UUID, dashed or bare.
9
+ *
10
+ * @example
11
+ * uuidService.isValid('01234567-89ab-7cde-8f01-23456789abcd'); // true
12
+ */
13
+ isValid(uuid: string): boolean;
7
14
  private getRandomBytes;
8
15
  generateUUIDv7Bytes(): Uint8Array;
9
16
  /**
10
17
  * Convert a UUID string to binary Uint8Array
11
18
  */
12
- static uuidToBin(uuid: string): Uint8Array;
19
+ uuidToBin(uuid: string): Uint8Array;
13
20
  /**
14
21
  * Convert binary Uint8Array/Buffer to formatted UUID string
15
22
  */
16
- static binToUuid(buffer: Uint8Array): string;
23
+ binToUuid(buffer: Uint8Array): string;
17
24
  }
18
25
  export declare const uuidService: UuidService;
19
26
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"UuidService.d.ts","sourceRoot":"","sources":["../../src/UuidService.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,cAAM,WAAW;IACf,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,UAAU,CAAK;IAEvB,OAAO,CAAC,cAAc;IAUf,mBAAmB,IAAI,UAAU;IAiDxC;;OAEG;WACW,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAWjD;;OAEG;WACW,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;CAQpD;AAED,eAAO,MAAM,WAAW,aAAoB,CAAC"}
1
+ {"version":3,"file":"UuidService.d.ts","sourceRoot":"","sources":["../../src/UuidService.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,cAAM,WAAW;IACf,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,UAAU,CAAK;IAEvB;;;;;OAKG;IACI,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIrC,OAAO,CAAC,cAAc;IAUf,mBAAmB,IAAI,UAAU;IAiDxC;;OAEG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAkB1C;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;CAW7C;AAED,eAAO,MAAM,WAAW,EAAE,WAA+B,CAAC"}
@@ -6,9 +6,11 @@ export * from './Dates.js';
6
6
  export * from './Kontororu/Socket.js';
7
7
  export * from './Kontororu/Store.js';
8
8
  export * from './Kontororu.js';
9
+ export * from './Numbers.js';
9
10
  export * from './Objector.js';
10
11
  export * from './Sorter.js';
11
12
  export * from './Style.js';
13
+ export * from './Tasker.js';
12
14
  export * from './Textor.js';
13
15
  export * from './Theme.js';
14
16
  export * from './Timezones.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esmalley/ts-utils",
3
- "version": "6.4.5",
3
+ "version": "7.0.0",
4
4
  "description": "A modular collection of TypeScript utilities for modern web development.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -10,13 +10,17 @@
10
10
  "dist"
11
11
  ],
12
12
  "scripts": {
13
- "clean": "rm -rf dist",
13
+ "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
14
14
  "prebuild": "node scripts/generate-tz.js && node scripts/generate-exports.js",
15
15
  "build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist/types",
16
16
  "build:js": "node build.mjs",
17
17
  "build": "npm run clean && npm run build:types && npm run build:js && npm run fix:cjs",
18
18
  "fix:cjs": "node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'}))\"",
19
+ "typecheck": "tsc --noEmit",
20
+ "pretest": "npm run typecheck",
19
21
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
22
+ "bench": "node bench/run.js",
23
+ "bench:save": "node bench/run.js --save",
20
24
  "prepublishOnly": "npm run build",
21
25
  "publish:jsr": "node scripts/jsr-config.js && npx jsr publish --allow-dirty"
22
26
  },
@@ -64,6 +68,7 @@
64
68
  "eslint-plugin-react": "^7.37.3",
65
69
  "eslint-plugin-react-hooks": "^5.1.0",
66
70
  "globals": "^16.0.0",
71
+ "tinybench": "^6.2.0",
67
72
  "ts-jest": "^29.4.6",
68
73
  "ts-node": "^10.9.2",
69
74
  "typescript": "^5.5.3",