shelving 1.112.1 → 1.114.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.
- package/db/ItemStore.d.ts +2 -2
- package/db/ItemStore.js +4 -4
- package/db/QueryStore.d.ts +2 -2
- package/db/QueryStore.js +4 -4
- package/package.json +1 -1
- package/store/ArrayStore.d.ts +2 -1
- package/store/ArrayStore.js +2 -2
- package/store/BooleanStore.d.ts +2 -1
- package/store/BooleanStore.js +2 -2
- package/store/DictionaryStore.d.ts +2 -1
- package/store/DictionaryStore.js +2 -2
- package/store/PathStore.d.ts +14 -0
- package/store/PathStore.js +24 -0
- package/store/Store.d.ts +4 -1
- package/store/Store.js +17 -4
- package/store/index.d.ts +1 -1
- package/store/index.js +1 -1
- package/util/index.d.ts +2 -1
- package/util/index.js +2 -1
- package/util/path.d.ts +26 -0
- package/util/path.js +30 -0
- package/util/start.d.ts +5 -1
- package/util/start.js +4 -0
- package/util/string.d.ts +1 -1
- package/util/string.js +1 -1
- package/store/LazyStore.d.ts +0 -12
- package/store/LazyStore.js +0 -26
package/db/ItemStore.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import type { DataKey, Database } from "../util/data.js";
|
|
|
4
4
|
import type { Item, OptionalItem } from "../util/item.js";
|
|
5
5
|
import type { Stop } from "../util/start.js";
|
|
6
6
|
import { BooleanStore } from "../store/BooleanStore.js";
|
|
7
|
-
import {
|
|
7
|
+
import { Store } from "../store/Store.js";
|
|
8
8
|
/** Store a single item. */
|
|
9
|
-
export declare class ItemStore<T extends Database, K extends DataKey<T>> extends
|
|
9
|
+
export declare class ItemStore<T extends Database, K extends DataKey<T>> extends Store<OptionalItem<T[K]>> {
|
|
10
10
|
readonly provider: AbstractProvider<T>;
|
|
11
11
|
readonly collection: K;
|
|
12
12
|
readonly id: string;
|
package/db/ItemStore.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BooleanStore } from "../store/BooleanStore.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Store } from "../store/Store.js";
|
|
3
3
|
import { NONE } from "../util/constants.js";
|
|
4
4
|
import { getItem } from "../util/item.js";
|
|
5
5
|
import { getRequired } from "../util/optional.js";
|
|
6
6
|
import { runSequence } from "../util/sequence.js";
|
|
7
7
|
/** Store a single item. */
|
|
8
|
-
export class ItemStore extends
|
|
8
|
+
export class ItemStore extends Store {
|
|
9
9
|
provider;
|
|
10
10
|
collection;
|
|
11
11
|
id;
|
|
@@ -25,8 +25,8 @@ export class ItemStore extends LazyStore {
|
|
|
25
25
|
constructor(collection, id, provider, memory) {
|
|
26
26
|
const time = memory?.getItemTime(collection, id);
|
|
27
27
|
const item = memory?.getItem(collection, id);
|
|
28
|
-
super(
|
|
29
|
-
time);
|
|
28
|
+
super(typeof time === "number" || item ? item : NONE, // Use the cached value if it was definitely cached or is not undefined.
|
|
29
|
+
time, memory && (store => runSequence(store.through(memory.getCachedItemSequence(collection, id)))));
|
|
30
30
|
this.provider = provider;
|
|
31
31
|
this.collection = collection;
|
|
32
32
|
this.id = id;
|
package/db/QueryStore.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import type { DataKey, Database } from "../util/data.js";
|
|
|
4
4
|
import type { Item, ItemQuery, Items, OptionalItem } from "../util/item.js";
|
|
5
5
|
import type { Stop } from "../util/start.js";
|
|
6
6
|
import { BooleanStore } from "../store/BooleanStore.js";
|
|
7
|
-
import {
|
|
7
|
+
import { Store } from "../store/Store.js";
|
|
8
8
|
/** Store a set of multiple items. */
|
|
9
|
-
export declare class QueryStore<T extends Database, K extends DataKey<T>> extends
|
|
9
|
+
export declare class QueryStore<T extends Database, K extends DataKey<T>> extends Store<Items<T[K]>> implements Iterable<Item<T[K]>> {
|
|
10
10
|
readonly provider: AbstractProvider<T>;
|
|
11
11
|
readonly collection: K;
|
|
12
12
|
readonly query: ItemQuery<T[K]>;
|
package/db/QueryStore.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BooleanStore } from "../store/BooleanStore.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Store } from "../store/Store.js";
|
|
3
3
|
import { getFirstItem, getLastItem, getOptionalFirstItem, getOptionalLastItem } from "../util/array.js";
|
|
4
4
|
import { NONE } from "../util/constants.js";
|
|
5
5
|
import { getAfterQuery, getLimit } from "../util/query.js";
|
|
6
6
|
import { runSequence } from "../util/sequence.js";
|
|
7
7
|
/** Store a set of multiple items. */
|
|
8
|
-
export class QueryStore extends
|
|
8
|
+
export class QueryStore extends Store {
|
|
9
9
|
provider;
|
|
10
10
|
collection;
|
|
11
11
|
query;
|
|
@@ -43,8 +43,8 @@ export class QueryStore extends LazyStore {
|
|
|
43
43
|
constructor(collection, query, provider, memory) {
|
|
44
44
|
const time = memory?.getQueryTime(collection, query);
|
|
45
45
|
const items = memory?.getQuery(collection, query) || [];
|
|
46
|
-
super(
|
|
47
|
-
time);
|
|
46
|
+
super(typeof time === "number" || items.length ? items : NONE, // Use the value if it was definitely cached or is not empty.
|
|
47
|
+
time, memory && (store => runSequence(store.through(memory.getCachedQuerySequence(collection, query)))));
|
|
48
48
|
this.provider = provider;
|
|
49
49
|
this.collection = collection;
|
|
50
50
|
this.query = query;
|
package/package.json
CHANGED
package/store/ArrayStore.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ImmutableArray } from "../util/array.js";
|
|
2
|
+
import type { PossibleStarter } from "../util/start.js";
|
|
2
3
|
import { Store } from "./Store.js";
|
|
3
4
|
/** Store an array. */
|
|
4
5
|
export declare class ArrayStore<T> extends Store<ImmutableArray<T>> implements Iterable<T> {
|
|
5
|
-
constructor(value?: ImmutableArray<T>, time?: number);
|
|
6
|
+
constructor(value?: ImmutableArray<T>, time?: number, start?: PossibleStarter<[Store<ImmutableArray<T>>]>);
|
|
6
7
|
/** Get the length of the current value of this store. */
|
|
7
8
|
get count(): number;
|
|
8
9
|
/** Add items to this array. */
|
package/store/ArrayStore.js
CHANGED
|
@@ -2,8 +2,8 @@ import { omitArrayItems, toggleArrayItems, withArrayItems } from "../util/array.
|
|
|
2
2
|
import { Store } from "./Store.js";
|
|
3
3
|
/** Store an array. */
|
|
4
4
|
export class ArrayStore extends Store {
|
|
5
|
-
constructor(value = [], time) {
|
|
6
|
-
super(value, time);
|
|
5
|
+
constructor(value = [], time, start) {
|
|
6
|
+
super(value, time, start);
|
|
7
7
|
}
|
|
8
8
|
/** Get the length of the current value of this store. */
|
|
9
9
|
get count() {
|
package/store/BooleanStore.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { NONE } from "../util/constants.js";
|
|
2
|
+
import type { PossibleStarter } from "../util/start.js";
|
|
2
3
|
import { Store } from "./Store.js";
|
|
3
4
|
/** Store a boolean. */
|
|
4
5
|
export declare class BooleanStore extends Store<boolean> {
|
|
5
|
-
constructor(value?: boolean | typeof NONE, time?: number);
|
|
6
|
+
constructor(value?: boolean | typeof NONE, time?: number, start?: PossibleStarter<[Store<boolean>]>);
|
|
6
7
|
/** Toggle the current boolean value. */
|
|
7
8
|
toggle(): void;
|
|
8
9
|
}
|
package/store/BooleanStore.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Store } from "./Store.js";
|
|
2
2
|
/** Store a boolean. */
|
|
3
3
|
export class BooleanStore extends Store {
|
|
4
|
-
constructor(value = false, time) {
|
|
5
|
-
super(value, time);
|
|
4
|
+
constructor(value = false, time, start) {
|
|
5
|
+
super(value, time, start);
|
|
6
6
|
}
|
|
7
7
|
/** Toggle the current boolean value. */
|
|
8
8
|
toggle() {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { DictionaryItem, ImmutableDictionary } from "../util/dictionary.js";
|
|
2
|
+
import type { PossibleStarter } from "../util/start.js";
|
|
2
3
|
import type { Updates } from "../util/update.js";
|
|
3
4
|
import { Store } from "./Store.js";
|
|
4
5
|
/** Store a dictionary object. */
|
|
5
6
|
export declare class DictionaryStore<T> extends Store<ImmutableDictionary<T>> implements Iterable<DictionaryItem<T>> {
|
|
6
|
-
constructor(value?: ImmutableDictionary<T>, time?: number);
|
|
7
|
+
constructor(value?: ImmutableDictionary<T>, time?: number, start?: PossibleStarter<[Store<ImmutableDictionary<T>>]>);
|
|
7
8
|
/** Get the length of the current value of this store. */
|
|
8
9
|
get count(): number;
|
|
9
10
|
/** Set a named entry in this object with a different value. */
|
package/store/DictionaryStore.js
CHANGED
|
@@ -4,8 +4,8 @@ import { updateData } from "../util/update.js";
|
|
|
4
4
|
import { Store } from "./Store.js";
|
|
5
5
|
/** Store a dictionary object. */
|
|
6
6
|
export class DictionaryStore extends Store {
|
|
7
|
-
constructor(value = {}, time) {
|
|
8
|
-
super(value, time);
|
|
7
|
+
constructor(value = {}, time, start) {
|
|
8
|
+
super(value, time, start);
|
|
9
9
|
}
|
|
10
10
|
/** Get the length of the current value of this store. */
|
|
11
11
|
get count() {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AbsolutePath, Path } from "../util/path.js";
|
|
2
|
+
import type { PossibleStarter } from "../util/start.js";
|
|
3
|
+
import { Store } from "./Store.js";
|
|
4
|
+
/** Store an absolute path, e.g. `/a/b/c` */
|
|
5
|
+
export declare class PathStore extends Store<AbsolutePath> {
|
|
6
|
+
constructor(path?: AbsolutePath, time?: number, start?: PossibleStarter<[Store<AbsolutePath>]>);
|
|
7
|
+
/** Based on the current store path, is a path active? */
|
|
8
|
+
isActive(path: AbsolutePath): boolean;
|
|
9
|
+
/** Based on the current store path, is a path proud (i.e. a child of the current store path)? */
|
|
10
|
+
isProud(path: AbsolutePath): boolean;
|
|
11
|
+
/** Get an absolute path from a path relative to the current navigation path. */
|
|
12
|
+
getAbsolute(path: Path): AbsolutePath;
|
|
13
|
+
set(path: Path): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getAbsolutePath, isPathActive, isPathProud } from "../util/path.js";
|
|
2
|
+
import { Store } from "./Store.js";
|
|
3
|
+
/** Store an absolute path, e.g. `/a/b/c` */
|
|
4
|
+
export class PathStore extends Store {
|
|
5
|
+
constructor(path = window.location.pathname, time, start) {
|
|
6
|
+
super(path, time, start);
|
|
7
|
+
}
|
|
8
|
+
/** Based on the current store path, is a path active? */
|
|
9
|
+
isActive(path) {
|
|
10
|
+
return isPathActive(path, this.value);
|
|
11
|
+
}
|
|
12
|
+
/** Based on the current store path, is a path proud (i.e. a child of the current store path)? */
|
|
13
|
+
isProud(path) {
|
|
14
|
+
return isPathProud(path, this.value);
|
|
15
|
+
}
|
|
16
|
+
/** Get an absolute path from a path relative to the current navigation path. */
|
|
17
|
+
getAbsolute(path) {
|
|
18
|
+
return getAbsolutePath(path, this.value);
|
|
19
|
+
}
|
|
20
|
+
// Override to clean the path.
|
|
21
|
+
set(path) {
|
|
22
|
+
super.set(getAbsolutePath(path, this.value));
|
|
23
|
+
}
|
|
24
|
+
}
|
package/store/Store.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DeferredSequence } from "../sequence/DeferredSequence.js";
|
|
2
2
|
import { NONE } from "../util/constants.js";
|
|
3
|
+
import { type PossibleStarter } from "../util/start.js";
|
|
3
4
|
/** Any `Store` instance. */
|
|
4
5
|
export type AnyStore = Store<any>;
|
|
5
6
|
/**
|
|
@@ -30,11 +31,13 @@ export declare class Store<T> implements AsyncIterable<T> {
|
|
|
30
31
|
get reason(): unknown;
|
|
31
32
|
set reason(reason: unknown);
|
|
32
33
|
private _reason;
|
|
34
|
+
private _starter;
|
|
33
35
|
/** Store is initiated with an initial store. */
|
|
34
|
-
constructor(value: T | typeof NONE, time?: number);
|
|
36
|
+
constructor(value: T | typeof NONE, time?: number, start?: PossibleStarter<[Store<T>]>);
|
|
35
37
|
/** Set the value of the store. */
|
|
36
38
|
set(next: T): void;
|
|
37
39
|
/** Set the value of the store as values are pulled from a sequence. */
|
|
38
40
|
through(sequence: AsyncIterable<T>): AsyncIterable<T>;
|
|
39
41
|
[Symbol.asyncIterator](): AsyncGenerator<T, void, void>;
|
|
42
|
+
private _iterating;
|
|
40
43
|
}
|
package/store/Store.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DeferredSequence } from "../sequence/DeferredSequence.js";
|
|
2
2
|
import { NONE } from "../util/constants.js";
|
|
3
|
+
import { getStarter } from "../util/start.js";
|
|
3
4
|
/**
|
|
4
5
|
* Store that retains its most recent value and is async-iterable to allow values to be observed.
|
|
5
6
|
* - Current value can be read at `store.value` and `store.data`
|
|
@@ -55,10 +56,12 @@ export class Store {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
_reason = undefined;
|
|
59
|
+
_starter;
|
|
58
60
|
/** Store is initiated with an initial store. */
|
|
59
|
-
constructor(value, time = Date.now()) {
|
|
61
|
+
constructor(value, time = Date.now(), start) {
|
|
60
62
|
this._value = value;
|
|
61
63
|
this._time = time;
|
|
64
|
+
this._starter = start && getStarter(start);
|
|
62
65
|
}
|
|
63
66
|
/** Set the value of the store. */
|
|
64
67
|
set(next) {
|
|
@@ -75,8 +78,18 @@ export class Store {
|
|
|
75
78
|
// Issues the current value of the store first, then any subsequent values that are issued.
|
|
76
79
|
async *[Symbol.asyncIterator]() {
|
|
77
80
|
await Promise.resolve(); // Introduce a slight delay, i.e. don't immediately yield `this.value` in case it is changed synchronously.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
this._starter?.start(this);
|
|
82
|
+
this._iterating++;
|
|
83
|
+
try {
|
|
84
|
+
if (!this.loading)
|
|
85
|
+
yield this.value;
|
|
86
|
+
yield* this.next;
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
this._iterating--;
|
|
90
|
+
if (this._iterating < 1)
|
|
91
|
+
this._starter?.stop();
|
|
92
|
+
}
|
|
81
93
|
}
|
|
94
|
+
_iterating = 0;
|
|
82
95
|
}
|
package/store/index.d.ts
CHANGED
package/store/index.js
CHANGED
package/util/index.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ export * from "./equal.js";
|
|
|
18
18
|
export * from "./error.js";
|
|
19
19
|
export * from "./focus.js";
|
|
20
20
|
export * from "./function.js";
|
|
21
|
-
export * from "./start.js";
|
|
22
21
|
export * from "./hash.js";
|
|
23
22
|
export * from "./hydrate.js";
|
|
24
23
|
export * from "./item.js";
|
|
@@ -32,6 +31,7 @@ export * from "./null.js";
|
|
|
32
31
|
export * from "./number.js";
|
|
33
32
|
export * from "./object.js";
|
|
34
33
|
export * from "./optional.js";
|
|
34
|
+
export * from "./path.js";
|
|
35
35
|
export * from "./query.js";
|
|
36
36
|
export * from "./random.js";
|
|
37
37
|
export * from "./regexp.js";
|
|
@@ -39,6 +39,7 @@ export * from "./sequence.js";
|
|
|
39
39
|
export * from "./serialise.js";
|
|
40
40
|
export * from "./sort.js";
|
|
41
41
|
export * from "./source.js";
|
|
42
|
+
export * from "./start.js";
|
|
42
43
|
export * from "./string.js";
|
|
43
44
|
export * from "./template.js";
|
|
44
45
|
export * from "./time.js";
|
package/util/index.js
CHANGED
|
@@ -18,7 +18,6 @@ export * from "./equal.js";
|
|
|
18
18
|
export * from "./error.js";
|
|
19
19
|
export * from "./focus.js";
|
|
20
20
|
export * from "./function.js";
|
|
21
|
-
export * from "./start.js";
|
|
22
21
|
export * from "./hash.js";
|
|
23
22
|
export * from "./hydrate.js";
|
|
24
23
|
export * from "./item.js";
|
|
@@ -32,6 +31,7 @@ export * from "./null.js";
|
|
|
32
31
|
export * from "./number.js";
|
|
33
32
|
export * from "./object.js";
|
|
34
33
|
export * from "./optional.js";
|
|
34
|
+
export * from "./path.js";
|
|
35
35
|
export * from "./query.js";
|
|
36
36
|
export * from "./random.js";
|
|
37
37
|
export * from "./regexp.js";
|
|
@@ -39,6 +39,7 @@ export * from "./sequence.js";
|
|
|
39
39
|
export * from "./serialise.js";
|
|
40
40
|
export * from "./sort.js";
|
|
41
41
|
export * from "./source.js";
|
|
42
|
+
export * from "./start.js";
|
|
42
43
|
export * from "./string.js";
|
|
43
44
|
export * from "./template.js";
|
|
44
45
|
export * from "./time.js";
|
package/util/path.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Relative path starts with `./` or `../` */
|
|
2
|
+
export type RelativePath = `./${string}` | `../${string}`;
|
|
3
|
+
/** Absolute path starts with `/` slash. */
|
|
4
|
+
export type AbsolutePath = `/${string}`;
|
|
5
|
+
/** Path is either an absolute or relative path. */
|
|
6
|
+
export type Path = AbsolutePath | RelativePath;
|
|
7
|
+
/** Is a string path an absolute path? */
|
|
8
|
+
export declare const isAbsolutePath: (path: string) => path is `/${string}`;
|
|
9
|
+
/** Is a string path an absolute path? */
|
|
10
|
+
export declare const isRelativePath: (path: string) => path is RelativePath;
|
|
11
|
+
/**
|
|
12
|
+
* Clean a path.
|
|
13
|
+
* - Remove runs of more than one slash, e.g. `/a//b` becomes `/a/b`
|
|
14
|
+
* - Remove trailing slashes, e.g. `/a/b/` becomes `/a/b`
|
|
15
|
+
*/
|
|
16
|
+
export declare function cleanPath(path: AbsolutePath): AbsolutePath;
|
|
17
|
+
export declare function cleanPath(path: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Get an absolute path.
|
|
20
|
+
* @return Absolute path with a leading trailing slash, e.g. `/a/c/b`
|
|
21
|
+
*/
|
|
22
|
+
export declare function getAbsolutePath(path: Path, base?: AbsolutePath): AbsolutePath;
|
|
23
|
+
/** Is a target path active? */
|
|
24
|
+
export declare function isPathActive(target: AbsolutePath, current: AbsolutePath): boolean;
|
|
25
|
+
/** Is a target path proud (i.e. is the current path, or is a child of the current path)? */
|
|
26
|
+
export declare function isPathProud(target: AbsolutePath, current: AbsolutePath): boolean;
|
package/util/path.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AssertionError } from "../error/AssertionError.js";
|
|
2
|
+
/** Is a string path an absolute path? */
|
|
3
|
+
export const isAbsolutePath = (path) => path.startsWith("/");
|
|
4
|
+
/** Is a string path an absolute path? */
|
|
5
|
+
export const isRelativePath = (path) => path.startsWith("./") || path.startsWith("../");
|
|
6
|
+
export function cleanPath(path) {
|
|
7
|
+
return path
|
|
8
|
+
.replace(/\/{2,}/g, "/") // Normalise runs of two or more slashes.
|
|
9
|
+
.replace(/(?!^)\/+$/g, ""); // Trailing slashes.
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get an absolute path.
|
|
13
|
+
* @return Absolute path with a leading trailing slash, e.g. `/a/c/b`
|
|
14
|
+
*/
|
|
15
|
+
export function getAbsolutePath(path, base = "/") {
|
|
16
|
+
try {
|
|
17
|
+
return cleanPath(new URL(path, `http://j.com${base}/`).pathname);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new AssertionError("Invalid path", path);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Is a target path active? */
|
|
24
|
+
export function isPathActive(target, current) {
|
|
25
|
+
return target === current;
|
|
26
|
+
}
|
|
27
|
+
/** Is a target path proud (i.e. is the current path, or is a child of the current path)? */
|
|
28
|
+
export function isPathProud(target, current) {
|
|
29
|
+
return target === current || (target !== "/" && target.startsWith(`${current}/`));
|
|
30
|
+
}
|
package/util/start.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type Stop = () => void;
|
|
|
8
8
|
* Wrapper class to handle state on start/stop callback process.
|
|
9
9
|
* - If process has already started, `starter.start()` won't be called twice (including if `start()` didn't return a `stop()` callback).
|
|
10
10
|
*/
|
|
11
|
-
export declare class Starter<T extends Arguments
|
|
11
|
+
export declare class Starter<T extends Arguments> implements Disposable {
|
|
12
12
|
private readonly _start;
|
|
13
13
|
private _stop;
|
|
14
14
|
constructor(start: Start<T>);
|
|
@@ -16,3 +16,7 @@ export declare class Starter<T extends Arguments = []> implements Disposable {
|
|
|
16
16
|
stop(): void;
|
|
17
17
|
[Symbol.dispose](): void;
|
|
18
18
|
}
|
|
19
|
+
/** Something that can be made into a `Starter` */
|
|
20
|
+
export type PossibleStarter<T extends Arguments> = Start<T> | Starter<T>;
|
|
21
|
+
/** Get a `Starter` from a `PossibleStarter` */
|
|
22
|
+
export declare function getStarter<T extends Arguments>(start: Start<T> | Starter<T>): Starter<T>;
|
package/util/start.js
CHANGED
package/util/string.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export declare const sanitizeLines: (str: string) => string;
|
|
|
62
62
|
* Simplify a string by removing anything that isn't a number, letter, or space.
|
|
63
63
|
* - Used when you're running a query against a string entered by a user.
|
|
64
64
|
*
|
|
65
|
-
* @example
|
|
65
|
+
* @example simplifyString("Däve-is\nREALLY éxcitable—apparęntly!!! 😂"); // Returns "dave is really excitable apparently"
|
|
66
66
|
*
|
|
67
67
|
* @todo Convert letter-like characters (e.g. `ℝ`) to their ASCII equivalent (e.g. `R`).
|
|
68
68
|
*/
|
package/util/string.js
CHANGED
|
@@ -98,7 +98,7 @@ export const sanitizeLines = (str) => str
|
|
|
98
98
|
* Simplify a string by removing anything that isn't a number, letter, or space.
|
|
99
99
|
* - Used when you're running a query against a string entered by a user.
|
|
100
100
|
*
|
|
101
|
-
* @example
|
|
101
|
+
* @example simplifyString("Däve-is\nREALLY éxcitable—apparęntly!!! 😂"); // Returns "dave is really excitable apparently"
|
|
102
102
|
*
|
|
103
103
|
* @todo Convert letter-like characters (e.g. `ℝ`) to their ASCII equivalent (e.g. `R`).
|
|
104
104
|
*/
|
package/store/LazyStore.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import type { NONE } from "../util/constants.js";
|
|
3
|
-
import { type Start } from "../util/start.js";
|
|
4
|
-
import { Store } from "./Store.js";
|
|
5
|
-
/** Store that starts/stops a source subscription when things subscribe to it, and stops when everything has unsubscribed from it. */
|
|
6
|
-
export declare class LazyStore<T> extends Store<T> implements Disposable {
|
|
7
|
-
private _iterating;
|
|
8
|
-
private readonly _starter;
|
|
9
|
-
constructor(start: Start<[Store<T>]>, value: T | typeof NONE, time?: number);
|
|
10
|
-
[Symbol.asyncIterator](): AsyncGenerator<T, void, void>;
|
|
11
|
-
[Symbol.dispose](): void;
|
|
12
|
-
}
|
package/store/LazyStore.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Starter } from "../util/start.js";
|
|
2
|
-
import { Store } from "./Store.js";
|
|
3
|
-
/** Store that starts/stops a source subscription when things subscribe to it, and stops when everything has unsubscribed from it. */
|
|
4
|
-
export class LazyStore extends Store {
|
|
5
|
-
_iterating = 0;
|
|
6
|
-
_starter;
|
|
7
|
-
constructor(start, value, time) {
|
|
8
|
-
super(value, time);
|
|
9
|
-
this._starter = new Starter(start);
|
|
10
|
-
}
|
|
11
|
-
async *[Symbol.asyncIterator]() {
|
|
12
|
-
this._starter.start(this);
|
|
13
|
-
this._iterating++;
|
|
14
|
-
try {
|
|
15
|
-
yield* super[Symbol.asyncIterator]();
|
|
16
|
-
}
|
|
17
|
-
finally {
|
|
18
|
-
this._iterating--;
|
|
19
|
-
if (this._iterating < 1)
|
|
20
|
-
this._starter.stop();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
[Symbol.dispose]() {
|
|
24
|
-
this._starter[Symbol.dispose]();
|
|
25
|
-
}
|
|
26
|
-
}
|