@snipl/official-registry 1.0.0 → 1.0.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.
@@ -1,4 +1,13 @@
1
- export declare function sleep(ms: number, options?: {
2
- signal?: AbortSignal;
3
- }): Promise<void>;
1
+ /**
2
+ * Pause execution for a given number of milliseconds.
3
+ * Uses setTimeout, so precision is limited by the event loop.
4
+ *
5
+ * @param ms - Milliseconds to sleep (defaults to 1000).
6
+ * @param signal - Optional AbortSignal to cancel the sleep.
7
+ */
8
+ export declare function sleep(ms?: number, signal?: AbortSignal): Promise<void>;
9
+ /**
10
+ * New in v1.1: sleep without creating a micro-task gap.
11
+ */
12
+ export declare function sleepSync(ms: number): void;
4
13
  //# sourceMappingURL=sleep.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../src/items/sleep.ts"],"names":[],"mappings":"AAAA,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAczF"}
1
+ {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../src/items/sleep.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,KAAK,CAAC,EAAE,GAAE,MAAa,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAalF;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAE1C"}
@@ -1,17 +1,28 @@
1
- export async function sleep(ms, options) {
1
+ /**
2
+ * Pause execution for a given number of milliseconds.
3
+ * Uses setTimeout, so precision is limited by the event loop.
4
+ *
5
+ * @param ms - Milliseconds to sleep (defaults to 1000).
6
+ * @param signal - Optional AbortSignal to cancel the sleep.
7
+ */
8
+ export async function sleep(ms = 1000, signal) {
2
9
  return new Promise((resolve, reject) => {
3
- if (ms < 0)
4
- ms = 0;
5
- if (options?.signal?.aborted) {
6
- reject(new Error('The operation was aborted'));
10
+ if (signal?.aborted) {
11
+ reject(new DOMException('Aborted', 'AbortError'));
7
12
  return;
8
13
  }
9
14
  const timer = setTimeout(resolve, ms);
10
15
  const onAbort = () => {
11
16
  clearTimeout(timer);
12
- reject(new Error('The operation was aborted'));
17
+ reject(new DOMException('Aborted', 'AbortError'));
13
18
  };
14
- options?.signal?.addEventListener('abort', onAbort, { once: true });
19
+ signal?.addEventListener('abort', onAbort, { once: true });
15
20
  });
16
21
  }
22
+ /**
23
+ * New in v1.1: sleep without creating a micro-task gap.
24
+ */
25
+ export function sleepSync(ms) {
26
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
27
+ }
17
28
  //# sourceMappingURL=sleep.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../../src/items/sleep.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,EAAU,EAAE,OAAkC;IACxE,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,IAAI,EAAE,GAAG,CAAC;YAAE,EAAE,GAAG,CAAC,CAAC;QACnB,IAAI,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;YAC/C,OAAO;QACT,CAAC;QACD,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACtC,MAAM,OAAO,GAAG,GAAS,EAAE;YACzB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;QACjD,CAAC,CAAC;QACF,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../../src/items/sleep.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,KAAa,IAAI,EAAE,MAAoB;IACjE,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,CAAC,IAAI,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;YAClD,OAAO;QACT,CAAC;QACD,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACtC,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,IAAI,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;QACpD,CAAC,CAAC;QACF,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,EAAU;IAClC,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AACnE,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,26 @@
1
1
  {
2
2
  "name": "@snipl/official-registry",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
7
+ "description": "Official built-in snippet registry for snipl — TypeScript utility modules including sleep, retry, debounce, throttle, memoize, deep-clone, clamp, and slugify.",
8
+ "keywords": [
9
+ "snippet",
10
+ "snippets",
11
+ "typescript",
12
+ "utility",
13
+ "sleep",
14
+ "retry",
15
+ "debounce",
16
+ "throttle",
17
+ "memoize",
18
+ "deep-clone",
19
+ "clamp",
20
+ "slugify",
21
+ "registry",
22
+ "source-code"
23
+ ],
7
24
  "repository": {
8
25
  "type": "git",
9
26
  "url": "git+https://github.com/ysr-hameed/snipl.git"
@@ -24,7 +41,7 @@
24
41
  "!dist/src/**/*.tsbuildinfo"
25
42
  ],
26
43
  "dependencies": {
27
- "@snipl/registry-schema": "1.0.0"
44
+ "@snipl/registry-schema": "1.0.1"
28
45
  },
29
46
  "devDependencies": {
30
47
  "typescript": "^5.7.0",