shelving 1.182.0 → 1.182.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.
- package/README.md +23 -28
- package/package.json +1 -1
- package/store/Store.d.ts +1 -1
- package/store/Store.js +5 -3
package/README.md
CHANGED
|
@@ -1,46 +1,41 @@
|
|
|
1
|
-
# Shelving
|
|
1
|
+
# Shelving
|
|
2
2
|
|
|
3
|
-
[](https://conventionalcommits.org) [](https://github.com/dhoulb/shelving/actions) [](https://www.npmjs.com/package/shelving)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Shelving is a TypeScript toolkit for working with typed data. At its core it is a schema validation library — every schema has a `validate()` method that returns a typed value or throws a human-readable error. On top of that it provides a database provider abstraction, an API provider abstraction, observable state stores, React integration, and a large set of typed utility functions.
|
|
6
6
|
|
|
7
|
-
> Note:
|
|
8
|
-
|
|
9
|
-
- Schemas (validation)
|
|
10
|
-
- Databases (via providers including in-memory, Firestore, IndexedDB)
|
|
11
|
-
- Querying (sorting, filtering, slicing)
|
|
12
|
-
- Store (events and state)
|
|
13
|
-
- React (hooks and state)
|
|
14
|
-
- Helpers (errors, arrays, objects, strings, dates, equality, merging, diffing, cloning, debug)
|
|
7
|
+
> Note: Shelving is in active development and does not yet follow semver.
|
|
15
8
|
|
|
16
9
|
## Installation
|
|
17
10
|
|
|
18
|
-
Install via `npm` or `yarn`:
|
|
19
|
-
|
|
20
11
|
```sh
|
|
21
12
|
npm install shelving
|
|
22
|
-
yarn add shelving
|
|
23
13
|
```
|
|
24
14
|
|
|
25
|
-
Import from
|
|
15
|
+
Shelving is an ES module. Import from the main package or from individual module subpaths:
|
|
26
16
|
|
|
27
|
-
```
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
17
|
+
```ts
|
|
18
|
+
import { STRING, DataSchema } from "shelving"
|
|
19
|
+
import { MemoryDBProvider } from "shelving/db"
|
|
30
20
|
```
|
|
31
21
|
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
Shelving is an [ES module](https://nodejs.org/api/esm.html) supporting `import { Query } from "shelving";` syntax and can be used natively in systems/browsers that support that (e.g. Chrome 61+, Deno, Node 12+).
|
|
35
|
-
|
|
36
|
-
Shelving does not include code for CommonJS `require()` imports, so using it in older projects will require transpiling.
|
|
37
|
-
|
|
38
22
|
## Modules
|
|
39
23
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
| Module | Description |
|
|
25
|
+
|---|---|
|
|
26
|
+
| [schema](modules/schema/README.md) | Schema validation — the foundation of everything |
|
|
27
|
+
| [db](modules/db/README.md) | Database provider abstraction (Collections, providers, queries) |
|
|
28
|
+
| [api](modules/api/README.md) | API provider abstraction (Endpoints, providers, caching) |
|
|
29
|
+
| [store](modules/store/README.md) | Observable state containers, Suspense-compatible |
|
|
30
|
+
| [sequence](modules/sequence/README.md) | Async-iterable utilities (`DeferredSequence`) |
|
|
31
|
+
| [react](modules/react/README.md) | React hooks for stores and sequences |
|
|
32
|
+
| [error](modules/error/README.md) | Typed error classes |
|
|
33
|
+
| [util](modules/util/README.md) | Typed helpers for arrays, objects, strings, data, queries, updates |
|
|
34
|
+
| [markup](modules/markup/README.md) | Markdown renderer for user-facing content |
|
|
35
|
+
| [cloudflare](modules/cloudflare/README.md) | Cloudflare Workers providers (KV, D1) |
|
|
36
|
+
| [firestore](modules/firestore/README.md) | Firestore providers (client, lite, server) |
|
|
37
|
+
| [bun](modules/bun/README.md) | Bun PostgreSQL provider |
|
|
43
38
|
|
|
44
39
|
## Changelog
|
|
45
40
|
|
|
46
|
-
See [Releases](https://github.com/dhoulb/shelving/releases)
|
|
41
|
+
See [Releases](https://github.com/dhoulb/shelving/releases).
|
package/package.json
CHANGED
package/store/Store.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type AnyStore = Store<any>;
|
|
|
12
12
|
* @param initial The initial value for the store, a `Promise` that resolves to the initial value, a source `Subscribable` to subscribe to, or another `Store` instance to take the initial value from and subscribe to.
|
|
13
13
|
* - To set the store to be loading, use the `NONE` constant or a `Promise` value.
|
|
14
14
|
* - To set the store to an explicit value, use that value or another `Store` instance with a value.
|
|
15
|
-
|
|
15
|
+
*/
|
|
16
16
|
export declare class Store<T> implements AsyncIterable<T> {
|
|
17
17
|
/** Deferred sequence this store uses to issue values as they change. */
|
|
18
18
|
readonly next: DeferredSequence<T>;
|
package/store/Store.js
CHANGED
|
@@ -11,7 +11,7 @@ import { getStarter } from "../util/start.js";
|
|
|
11
11
|
* @param initial The initial value for the store, a `Promise` that resolves to the initial value, a source `Subscribable` to subscribe to, or another `Store` instance to take the initial value from and subscribe to.
|
|
12
12
|
* - To set the store to be loading, use the `NONE` constant or a `Promise` value.
|
|
13
13
|
* - To set the store to an explicit value, use that value or another `Store` instance with a value.
|
|
14
|
-
|
|
14
|
+
*/
|
|
15
15
|
export class Store {
|
|
16
16
|
/** Deferred sequence this store uses to issue values as they change. */
|
|
17
17
|
next = new DeferredSequence();
|
|
@@ -100,8 +100,10 @@ export class Store {
|
|
|
100
100
|
this._starter?.start(this);
|
|
101
101
|
this._iterating++;
|
|
102
102
|
try {
|
|
103
|
-
if (
|
|
104
|
-
|
|
103
|
+
if (this._reason !== undefined)
|
|
104
|
+
throw this._reason;
|
|
105
|
+
if (this._value !== NONE)
|
|
106
|
+
yield this._value;
|
|
105
107
|
yield* this.next;
|
|
106
108
|
}
|
|
107
109
|
finally {
|