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 CHANGED
@@ -1,46 +1,41 @@
1
- # Shelving: toolkit for using data in JavaScript
1
+ # Shelving
2
2
 
3
- [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat)](https://github.com/semantic-release/semantic-release) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![GitHub Actions](https://github.com/dhoulb/shelving/workflows/CI/badge.svg?branch=main)](https://github.com/dhoulb/shelving/actions) [![npm](https://img.shields.io/npm/dm/shelving.svg)](https://www.npmjs.com/package/shelving)
3
+ [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) [![GitHub Actions](https://github.com/dhoulb/shelving/workflows/CI/badge.svg?branch=main)](https://github.com/dhoulb/shelving/actions) [![npm](https://img.shields.io/npm/dm/shelving.svg)](https://www.npmjs.com/package/shelving)
4
4
 
5
- **Shelving** is a toolkit for using data in JavaScript and TypeScript, including:
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: The `1.x` branch of Shelving is in active development and is not observing semver for breaking changes (from `2.x` onward semver will be followed).
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 Skypack CDN (the `?dts` enables TypeScript types in Deno):
15
+ Shelving is an ES module. Import from the main package or from individual module subpaths:
26
16
 
27
- ```js
28
- import { Database } from "https://cdn.skypack.dev/shelving";
29
- import { Database } from "https://cdn.skypack.dev/shelving?dts";
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
- Shelving is created from small individual modules which can be imported individually (using e.g. `import { addProp } from "shelving/util/object`). Modules marked with `✅` are also re-exported from the main `"shelving"` module.
41
-
42
- @todo Write these docs!
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shelving",
3
- "version": "1.182.0",
3
+ "version": "1.182.1",
4
4
  "author": "Dave Houlbrooke <dave@shax.com>",
5
5
  "repository": {
6
6
  "type": "git",
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 (!this.loading)
104
- yield this.value;
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 {