@e280/stz 0.0.0-2 → 0.0.0-4
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/package.json +1 -1
- package/s/coalesce.ts +5 -0
- package/s/deadline.ts +7 -5
- package/s/drill.ts +22 -0
- package/s/index.ts +7 -0
- package/x/coalesce.d.ts +1 -0
- package/x/coalesce.js +4 -0
- package/x/coalesce.js.map +1 -0
- package/x/deadline.d.ts +3 -2
- package/x/deadline.js +8 -4
- package/x/deadline.js.map +1 -1
- package/x/drill.d.ts +6 -0
- package/x/drill.js +14 -0
- package/x/drill.js.map +1 -0
- package/x/index.d.ts +5 -0
- package/x/index.js +5 -0
- package/x/index.js.map +1 -1
package/package.json
CHANGED
package/s/coalesce.ts
ADDED
package/s/deadline.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
|
|
2
2
|
export class DeadlineError extends Error {
|
|
3
3
|
name = this.constructor.name
|
|
4
|
-
constructor(milliseconds: number) {
|
|
5
|
-
super(
|
|
4
|
+
constructor(public milliseconds: number, message: string) {
|
|
5
|
+
super(`${message}, timed out in ${(milliseconds / 1000).toFixed(1)} seconds`)
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/** set a deadline for a fn to do something, will reject with a `DeadlineError` if it takes too long */
|
|
10
|
-
export function deadline<R>(milliseconds: number, fn: () => Promise<R>) {
|
|
10
|
+
export function deadline<R>(milliseconds: number, message: string, fn: () => Promise<R>) {
|
|
11
|
+
if (milliseconds <= 0 || milliseconds === Infinity)
|
|
12
|
+
return fn()
|
|
13
|
+
|
|
11
14
|
return new Promise<R>((resolve, reject) => {
|
|
12
15
|
|
|
13
16
|
const id = setTimeout(
|
|
14
|
-
() => reject(new DeadlineError(milliseconds)),
|
|
17
|
+
() => reject(new DeadlineError(milliseconds, message)),
|
|
15
18
|
milliseconds,
|
|
16
19
|
)
|
|
17
20
|
|
|
@@ -21,4 +24,3 @@ export function deadline<R>(milliseconds: number, fn: () => Promise<R>) {
|
|
|
21
24
|
.finally(() => clearTimeout(id))
|
|
22
25
|
})
|
|
23
26
|
}
|
|
24
|
-
|
package/s/drill.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import {is} from "./is.js"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* return a value within an object tree, found at the given path.
|
|
6
|
+
*/
|
|
7
|
+
export function drill<xResult>(
|
|
8
|
+
object: {[key: string]: any},
|
|
9
|
+
path: string[],
|
|
10
|
+
): xResult {
|
|
11
|
+
|
|
12
|
+
let current: any = object
|
|
13
|
+
|
|
14
|
+
for (const key of path) {
|
|
15
|
+
current = current[key]
|
|
16
|
+
if (is.unavailable(current))
|
|
17
|
+
break
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return current
|
|
21
|
+
}
|
|
22
|
+
|
package/s/index.ts
CHANGED
|
@@ -7,10 +7,17 @@ export * from "./data/bytes.js"
|
|
|
7
7
|
export * from "./data/hex.js"
|
|
8
8
|
export * from "./data/txt.js"
|
|
9
9
|
|
|
10
|
+
export * from "./debounce/debounce.js"
|
|
11
|
+
export * from "./debounce/types.js"
|
|
12
|
+
|
|
13
|
+
export * from "./deep/deep.js"
|
|
14
|
+
|
|
15
|
+
export * from "./coalesce.js"
|
|
10
16
|
export * from "./concurrent.js"
|
|
11
17
|
export * from "./deadline.js"
|
|
12
18
|
export * from "./dedupe.js"
|
|
13
19
|
export * from "./defer-promise.js"
|
|
20
|
+
export * from "./drill.js"
|
|
14
21
|
export * from "./escape-regex.js"
|
|
15
22
|
export * from "./hat.js"
|
|
16
23
|
export * from "./is.js"
|
package/x/coalesce.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function coalesce<A extends any[] = []>(...fns: ((...a: A) => void)[]): (...a: A) => void;
|
package/x/coalesce.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coalesce.js","sourceRoot":"","sources":["../s/coalesce.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,QAAQ,CAAuB,GAAG,GAA0B;IAC3E,OAAO,CAAC,GAAG,CAAI,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAChD,CAAC"}
|
package/x/deadline.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare class DeadlineError extends Error {
|
|
2
|
+
milliseconds: number;
|
|
2
3
|
name: string;
|
|
3
|
-
constructor(milliseconds: number);
|
|
4
|
+
constructor(milliseconds: number, message: string);
|
|
4
5
|
}
|
|
5
6
|
/** set a deadline for a fn to do something, will reject with a `DeadlineError` if it takes too long */
|
|
6
|
-
export declare function deadline<R>(milliseconds: number, fn: () => Promise<R>): Promise<R>;
|
|
7
|
+
export declare function deadline<R>(milliseconds: number, message: string, fn: () => Promise<R>): Promise<R>;
|
package/x/deadline.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
export class DeadlineError extends Error {
|
|
2
|
+
milliseconds;
|
|
2
3
|
name = this.constructor.name;
|
|
3
|
-
constructor(milliseconds) {
|
|
4
|
-
super(
|
|
4
|
+
constructor(milliseconds, message) {
|
|
5
|
+
super(`${message}, timed out in ${(milliseconds / 1000).toFixed(1)} seconds`);
|
|
6
|
+
this.milliseconds = milliseconds;
|
|
5
7
|
}
|
|
6
8
|
}
|
|
7
9
|
/** set a deadline for a fn to do something, will reject with a `DeadlineError` if it takes too long */
|
|
8
|
-
export function deadline(milliseconds, fn) {
|
|
10
|
+
export function deadline(milliseconds, message, fn) {
|
|
11
|
+
if (milliseconds <= 0 || milliseconds === Infinity)
|
|
12
|
+
return fn();
|
|
9
13
|
return new Promise((resolve, reject) => {
|
|
10
|
-
const id = setTimeout(() => reject(new DeadlineError(milliseconds)), milliseconds);
|
|
14
|
+
const id = setTimeout(() => reject(new DeadlineError(milliseconds, message)), milliseconds);
|
|
11
15
|
fn()
|
|
12
16
|
.then(resolve)
|
|
13
17
|
.catch(reject)
|
package/x/deadline.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deadline.js","sourceRoot":"","sources":["../s/deadline.ts"],"names":[],"mappings":"AACA,MAAM,OAAO,aAAc,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"deadline.js","sourceRoot":"","sources":["../s/deadline.ts"],"names":[],"mappings":"AACA,MAAM,OAAO,aAAc,SAAQ,KAAK;IAEpB;IADnB,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;IAC5B,YAAmB,YAAoB,EAAE,OAAe;QACvD,KAAK,CAAC,GAAG,OAAO,kBAAkB,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;QAD3D,iBAAY,GAAZ,YAAY,CAAQ;IAEvC,CAAC;CACD;AAED,uGAAuG;AACvG,MAAM,UAAU,QAAQ,CAAI,YAAoB,EAAE,OAAe,EAAE,EAAoB;IACtF,IAAI,YAAY,IAAI,CAAC,IAAI,YAAY,KAAK,QAAQ;QACjD,OAAO,EAAE,EAAE,CAAA;IAEZ,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAEzC,MAAM,EAAE,GAAG,UAAU,CACpB,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,EACtD,YAAY,CACZ,CAAA;QAED,EAAE,EAAE;aACF,IAAI,CAAC,OAAO,CAAC;aACb,KAAK,CAAC,MAAM,CAAC;aACb,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;AACH,CAAC"}
|
package/x/drill.d.ts
ADDED
package/x/drill.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { is } from "./is.js";
|
|
2
|
+
/**
|
|
3
|
+
* return a value within an object tree, found at the given path.
|
|
4
|
+
*/
|
|
5
|
+
export function drill(object, path) {
|
|
6
|
+
let current = object;
|
|
7
|
+
for (const key of path) {
|
|
8
|
+
current = current[key];
|
|
9
|
+
if (is.unavailable(current))
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
return current;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=drill.js.map
|
package/x/drill.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drill.js","sourceRoot":"","sources":["../s/drill.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAC,MAAM,SAAS,CAAA;AAE1B;;GAEG;AACH,MAAM,UAAU,KAAK,CACnB,MAA4B,EAC5B,IAAc;IAGf,IAAI,OAAO,GAAQ,MAAM,CAAA;IAEzB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;QACtB,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;YAC1B,MAAK;IACP,CAAC;IAED,OAAO,OAAO,CAAA;AACf,CAAC"}
|
package/x/index.d.ts
CHANGED
|
@@ -5,10 +5,15 @@ export * from "./data/base64url.js";
|
|
|
5
5
|
export * from "./data/bytes.js";
|
|
6
6
|
export * from "./data/hex.js";
|
|
7
7
|
export * from "./data/txt.js";
|
|
8
|
+
export * from "./debounce/debounce.js";
|
|
9
|
+
export * from "./debounce/types.js";
|
|
10
|
+
export * from "./deep/deep.js";
|
|
11
|
+
export * from "./coalesce.js";
|
|
8
12
|
export * from "./concurrent.js";
|
|
9
13
|
export * from "./deadline.js";
|
|
10
14
|
export * from "./dedupe.js";
|
|
11
15
|
export * from "./defer-promise.js";
|
|
16
|
+
export * from "./drill.js";
|
|
12
17
|
export * from "./escape-regex.js";
|
|
13
18
|
export * from "./hat.js";
|
|
14
19
|
export * from "./is.js";
|
package/x/index.js
CHANGED
|
@@ -5,10 +5,15 @@ export * from "./data/base64url.js";
|
|
|
5
5
|
export * from "./data/bytes.js";
|
|
6
6
|
export * from "./data/hex.js";
|
|
7
7
|
export * from "./data/txt.js";
|
|
8
|
+
export * from "./debounce/debounce.js";
|
|
9
|
+
export * from "./debounce/types.js";
|
|
10
|
+
export * from "./deep/deep.js";
|
|
11
|
+
export * from "./coalesce.js";
|
|
8
12
|
export * from "./concurrent.js";
|
|
9
13
|
export * from "./deadline.js";
|
|
10
14
|
export * from "./dedupe.js";
|
|
11
15
|
export * from "./defer-promise.js";
|
|
16
|
+
export * from "./drill.js";
|
|
12
17
|
export * from "./escape-regex.js";
|
|
13
18
|
export * from "./hat.js";
|
|
14
19
|
export * from "./is.js";
|
package/x/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../s/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAA;AACvC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAE7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../s/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAA;AACvC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAE7B,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AAEnC,cAAc,gBAAgB,CAAA;AAE9B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|