shelving 1.128.3 → 1.129.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.
@@ -1,8 +1,7 @@
1
1
  /** Abstract generator designed to be extended that implements the full generator protocol. */
2
- export declare abstract class AbstractGenerator<T, R, N> implements Generator<T, R, N> {
3
- readonly [Symbol.toStringTag] = "Generator";
2
+ export declare abstract class AbstractIterator<T, R, N> implements Iterator<T, R, N>, Iterable<T, R, N> {
4
3
  abstract next(value: N): IteratorResult<T, R>;
5
4
  throw(thrown: unknown): IteratorResult<T, R>;
6
5
  return(value: R): IteratorResult<T, R>;
7
- [Symbol.iterator](): Generator<T, R, N>;
6
+ [Symbol.iterator](): Iterator<T, R, N>;
8
7
  }
@@ -1,6 +1,5 @@
1
1
  /** Abstract generator designed to be extended that implements the full generator protocol. */
2
- export class AbstractGenerator {
3
- [Symbol.toStringTag] = "Generator";
2
+ export class AbstractIterator {
4
3
  throw(thrown) {
5
4
  // Default behaviour for a generator is to throw the error back out of the iterator and not continue.
6
5
  throw thrown;
@@ -1,15 +1,15 @@
1
- import { ThroughGenerator } from "./ThroughGenerator.js";
1
+ import { ThroughIterator } from "./ThroughIterator.js";
2
2
  /**
3
3
  * Iterable that inspects a source iterable as it iterates.
4
4
  * - Stores: first/last yielded value, returned value, whether iteration is done, the number of items that were iterated.
5
5
  *
6
6
  * @example
7
- * const watch = new WatchIterator(iterable);
7
+ * const watch = new InspectIterator(iterable);
8
8
  * for (const next of capture) console.log("YIELDED", next);
9
9
  * console.log("FIRST", watch.first);
10
10
  * console.log("RETURNED", watch.returned);
11
11
  */
12
- export declare class InspectGenerator<T, R, N> extends ThroughGenerator<T, R, N> {
12
+ export declare class InspectIterator<T, R, N> extends ThroughIterator<T, R, N> implements Iterator<T, R, N>, Iterable<T, R, N> {
13
13
  /** Get the number of results received by this iterator so far. */
14
14
  readonly count = 0;
15
15
  /** Is the iteration done? */
@@ -1,5 +1,5 @@
1
1
  import { StateError } from "../error/StateError.js";
2
- import { ThroughGenerator } from "./ThroughGenerator.js";
2
+ import { ThroughIterator } from "./ThroughIterator.js";
3
3
  /** Used when the sequence hasn't inspected anything yet. */
4
4
  const _NOVALUE = Symbol("shelving/InspectGenerator.NOVALUE");
5
5
  /**
@@ -7,12 +7,12 @@ const _NOVALUE = Symbol("shelving/InspectGenerator.NOVALUE");
7
7
  * - Stores: first/last yielded value, returned value, whether iteration is done, the number of items that were iterated.
8
8
  *
9
9
  * @example
10
- * const watch = new WatchIterator(iterable);
10
+ * const watch = new InspectIterator(iterable);
11
11
  * for (const next of capture) console.log("YIELDED", next);
12
12
  * console.log("FIRST", watch.first);
13
13
  * console.log("RETURNED", watch.returned);
14
14
  */
15
- export class InspectGenerator extends ThroughGenerator {
15
+ export class InspectIterator extends ThroughIterator {
16
16
  /** Get the number of results received by this iterator so far. */
17
17
  count = 0;
18
18
  /** Is the iteration done? */
@@ -1,6 +1,6 @@
1
- import { AbstractGenerator } from "./AbstractGenerator.js";
1
+ import { AbstractIterator } from "./AbstractIterator.js";
2
2
  /** Iterable that pulls values from a source iterable. */
3
- export declare class ThroughGenerator<T, R, N> extends AbstractGenerator<T, R, N> {
3
+ export declare class ThroughIterator<T, R, N> extends AbstractIterator<T, R, N> implements Iterator<T, R, N>, Iterable<T, R, N> {
4
4
  private readonly _source;
5
5
  constructor(iterator: Iterator<T, R, N>);
6
6
  next(value: N): IteratorResult<T, R>;
@@ -1,12 +1,12 @@
1
- import { AbstractGenerator } from "./AbstractGenerator.js";
1
+ import { AbstractIterator } from "./AbstractIterator.js";
2
2
  /** Iterable that pulls values from a source iterable. */
3
- export class ThroughGenerator extends AbstractGenerator {
3
+ export class ThroughIterator extends AbstractIterator {
4
4
  _source;
5
5
  constructor(iterator) {
6
6
  super();
7
7
  this._source = iterator;
8
8
  }
9
- // Implement `AbstractGenerator`
9
+ // Implement `AbstractIterator`
10
10
  next(value) {
11
11
  return this._source.next(value);
12
12
  }
@@ -1,3 +1,3 @@
1
- export * from "./AbstractGenerator.js";
2
- export * from "./ThroughGenerator.js";
3
- export * from "./InspectGenerator.js";
1
+ export * from "./AbstractIterator.js";
2
+ export * from "./ThroughIterator.js";
3
+ export * from "./InspectIterator.js";
package/iterate/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./AbstractGenerator.js";
2
- export * from "./ThroughGenerator.js";
3
- export * from "./InspectGenerator.js";
1
+ export * from "./AbstractIterator.js";
2
+ export * from "./ThroughIterator.js";
3
+ export * from "./InspectIterator.js";
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.128.3",
14
+ "version": "1.129.0",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -48,7 +48,7 @@
48
48
  "test:types": "tsc --noEmit",
49
49
  "test:unit": "bun test",
50
50
  "fix": "bun run fix:biome",
51
- "fix:biome": "biome check --apply .",
51
+ "fix:biome": "biome check --write .",
52
52
  "build": "bun run build:setup && bun run build:copy && bun run build:emit && bun run build:test:syntax && bun run build:test:unit",
53
53
  "build:setup": "rm -rf ./dist && mkdir -p ./dist",
54
54
  "build:copy": "cp package.json dist/package.json && cp LICENSE.md dist/LICENSE.md && cp README.md dist/README.md && cp .npmignore dist/.npmignore",
@@ -57,15 +57,15 @@
57
57
  "build:test:unit": "bun test ./dist/**/*.test.js --bail"
58
58
  },
59
59
  "devDependencies": {
60
- "@biomejs/biome": "^1.7.3",
61
- "@google-cloud/firestore": "^7.7.0",
62
- "@types/bun": "^1.1.3",
60
+ "@biomejs/biome": "^1.8.3",
61
+ "@google-cloud/firestore": "^7.9.0",
62
+ "@types/bun": "^1.1.6",
63
63
  "@types/react": "^18.3.3",
64
64
  "@types/react-dom": "^18.3.0",
65
- "firebase": "^10.12.2",
65
+ "firebase": "^10.12.5",
66
66
  "react": "^18.3.1",
67
67
  "react-dom": "^18.3.1",
68
- "typescript": "^5.4.5"
68
+ "typescript": "^5.8.2"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@google-cloud/firestore": ">=4.0.0",
@@ -1,8 +1,8 @@
1
1
  /** Sequence of values designed to be extended that implements the full async generator protocol. */
2
- export declare abstract class AbstractSequence<T, R, N> implements AsyncGenerator<T, R, N> {
2
+ export declare abstract class AbstractSequence<T, R, N> implements AsyncIterator<T, R, N>, AsyncIterable<T, R, N> {
3
3
  readonly [Symbol.toStringTag] = "Sequence";
4
4
  abstract next(value: N): Promise<IteratorResult<T, R>>;
5
5
  return(returnValue: R | PromiseLike<R>): Promise<IteratorResult<T, R>>;
6
6
  throw(reason: unknown): Promise<IteratorResult<T, R>>;
7
- [Symbol.asyncIterator](): AsyncGenerator<T, R>;
7
+ [Symbol.asyncIterator](): AsyncIterator<T, R, N>;
8
8
  }
@@ -27,5 +27,5 @@ export declare class DeferredSequence<T = void> extends AbstractSequence<T, void
27
27
  catch<Y>(onError: (r: unknown) => Y | PromiseLike<Y>): Promise<T | Y>;
28
28
  finally(onFinally: () => void): Promise<T>;
29
29
  /** Resolve the current deferred from a sequence of values. */
30
- through(sequence: AsyncIterable<T>): AsyncIterable<T>;
30
+ through(sequence: AsyncIterable<T>): AsyncIterator<T>;
31
31
  }
@@ -4,12 +4,12 @@ import { ThroughSequence } from "./ThroughSequence.js";
4
4
  * - Stores: first/last yielded value, returned value, whether iteration is done, the number of items that were iterated.
5
5
  *
6
6
  * @example
7
- * const watch = new WatchIterator(iterable);
8
- * for (const next of capture) console.log("YIELDED", next);
7
+ * const watch = new InspectSequence(iterable);
8
+ * for await (const next of capture) console.log("YIELDED", next);
9
9
  * console.log("FIRST", watch.first);
10
10
  * console.log("RETURNED", watch.returned);
11
11
  */
12
- export declare class InspectSequence<T, R, N> extends ThroughSequence<T, R, N> {
12
+ export declare class InspectSequence<T, R, N> extends ThroughSequence<T, R, N> implements AsyncIterator<T, R, N>, AsyncIterable<T, R, N> {
13
13
  /** Get the number of results received by this iterator so far. */
14
14
  readonly count = 0;
15
15
  /** Is the iteration done? */
@@ -7,8 +7,8 @@ const _NOVALUE = Symbol("shelving/InspectSequence.NOVALUE");
7
7
  * - Stores: first/last yielded value, returned value, whether iteration is done, the number of items that were iterated.
8
8
  *
9
9
  * @example
10
- * const watch = new WatchIterator(iterable);
11
- * for (const next of capture) console.log("YIELDED", next);
10
+ * const watch = new InspectSequence(iterable);
11
+ * for await (const next of capture) console.log("YIELDED", next);
12
12
  * console.log("FIRST", watch.first);
13
13
  * console.log("RETURNED", watch.returned);
14
14
  */
@@ -5,6 +5,6 @@ export declare class LazyDeferredSequence<T = void> extends DeferredSequence<T>
5
5
  private _iterating;
6
6
  private _starter;
7
7
  constructor(start: Start<[DeferredSequence<T>]>);
8
- [Symbol.asyncIterator](): AsyncGenerator<T, void, void>;
8
+ [Symbol.asyncIterator](): AsyncIterator<T, void, void>;
9
9
  [Symbol.dispose](): void;
10
10
  }
@@ -1,6 +1,6 @@
1
1
  import { AbstractSequence } from "./AbstractSequence.js";
2
2
  /** Async iterable that pulls values from a source async iterable. */
3
- export declare class ThroughSequence<T, R, N> extends AbstractSequence<T, R, N> {
3
+ export declare class ThroughSequence<T, R, N> extends AbstractSequence<T, R, N> implements AsyncIterator<T, R, N>, AsyncIterable<T, R, N> {
4
4
  private readonly _source;
5
5
  constructor(source: AsyncIterator<T, R, N>);
6
6
  next(next: N): Promise<IteratorResult<T, R>>;
package/test/basics.d.ts CHANGED
@@ -8,10 +8,10 @@ export declare const BASIC_SCHEMA: import("../schema/DataSchema.js").DataSchema<
8
8
  odd: boolean;
9
9
  even: boolean;
10
10
  sub: {
11
- str: any;
12
- num: any;
13
- odd: any;
14
- even: any;
11
+ str: /*elided*/ any;
12
+ num: /*elided*/ any;
13
+ odd: /*elided*/ any;
14
+ even: /*elided*/ any;
15
15
  };
16
16
  }>;
17
17
  export type BasicData = ValidatorType<typeof BASIC_SCHEMA>;
package/test/index.d.ts CHANGED
@@ -11,16 +11,16 @@ export declare const TEST_COLLECTIONS: {
11
11
  odd: boolean;
12
12
  even: boolean;
13
13
  sub: {
14
- str: any;
15
- num: any;
16
- odd: any;
17
- even: any;
14
+ str: /*elided*/ any;
15
+ num: /*elided*/ any;
16
+ odd: /*elided*/ any;
17
+ even: /*elided*/ any;
18
18
  };
19
19
  }>;
20
20
  people: import("../index.js").DataSchema<{
21
21
  name: {
22
- first: any;
23
- last: any;
22
+ first: /*elided*/ any;
23
+ last: /*elided*/ any;
24
24
  };
25
25
  birthday: string | null;
26
26
  }>;
package/test/people.d.ts CHANGED
@@ -2,8 +2,8 @@ import type { Item } from "../util/item.js";
2
2
  import type { ValidatorType } from "../util/validate.js";
3
3
  export declare const PERSON_SCHEMA: import("../schema/DataSchema.js").DataSchema<{
4
4
  name: {
5
- first: any;
6
- last: any;
5
+ first: /*elided*/ any;
6
+ last: /*elided*/ any;
7
7
  };
8
8
  birthday: string | null;
9
9
  }>;
package/util/object.d.ts CHANGED
@@ -24,7 +24,7 @@ export declare function isPlainObject(value: unknown): value is ImmutableObject;
24
24
  /** Assert that an unknown value is a plain object */
25
25
  export declare function assertPlainObject(value: unknown): asserts value is ImmutableObject;
26
26
  /** Is an unknown value the key for an own prop of an object. */
27
- export declare const isProp: <T extends ImmutableObject<PropertyKey, unknown>>(obj: T, key: PropertyKey) => key is keyof T;
27
+ export declare const isProp: <T extends ImmutableObject>(obj: T, key: PropertyKey) => key is keyof T;
28
28
  /** Assert that an unknown value is the key for an own prop of an object. */
29
29
  export declare function assertProp<T extends ImmutableObject>(obj: T, key: PropertyKey): asserts key is keyof T;
30
30
  /** Turn a possible object into an object. */
package/util/units.d.ts CHANGED
@@ -20,9 +20,9 @@ type UnitProps<T extends string> = {
20
20
  };
21
21
  /** Represent a unit. */
22
22
  export declare class Unit<K extends string> {
23
+ private readonly _to;
23
24
  /** `UnitList` this unit belongs to. */
24
25
  readonly list: UnitList<K>;
25
- private readonly _to;
26
26
  /** String key for this unit, e.g. `kilometer` */
27
27
  readonly key: K;
28
28
  /** Short abbreviation for this unit, e.g. `km` (defaults to first letter of `id`). */
package/util/units.js CHANGED
@@ -10,8 +10,9 @@ function _convert(amount, conversion) {
10
10
  }
11
11
  /** Represent a unit. */
12
12
  export class Unit {
13
- list;
14
13
  _to;
14
+ /** `UnitList` this unit belongs to. */
15
+ list;
15
16
  /** String key for this unit, e.g. `kilometer` */
16
17
  key;
17
18
  /** Short abbreviation for this unit, e.g. `km` (defaults to first letter of `id`). */