@centralping/ergo 0.1.0-beta.1 → 0.1.0-beta.3
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 +14 -15
- package/http/accepts.js +1 -2
- package/http/authorization.js +1 -2
- package/http/body.js +1 -2
- package/http/cache-control.js +1 -2
- package/http/compress.js +1 -2
- package/http/cookie.js +1 -2
- package/http/cors.js +1 -2
- package/http/csrf.js +1 -2
- package/http/handler.js +1 -2
- package/http/idempotency.js +110 -0
- package/http/index.js +37 -4
- package/http/json-api-query.js +1 -2
- package/http/logger.js +1 -2
- package/http/main.js +5 -3
- package/http/precondition.js +1 -2
- package/http/prefer.js +1 -2
- package/http/rate-limit.js +1 -2
- package/http/security-headers.js +1 -2
- package/http/send.js +1 -2
- package/http/timeout.js +1 -2
- package/http/url.js +1 -2
- package/http/validate.js +1 -2
- package/lib/accepts.js +1 -2
- package/lib/attach-instance.js +0 -1
- package/lib/authorization.js +1 -2
- package/lib/body/multiparse.js +1 -2
- package/lib/body/multipart/headers.js +1 -2
- package/lib/body/writer.js +1 -2
- package/lib/cookie/cookie.js +1 -2
- package/lib/cookie/index.js +0 -1
- package/lib/cookie/jar.js +16 -12
- package/lib/cookie/parse.js +1 -2
- package/lib/cors.js +1 -2
- package/lib/csrf.js +1 -2
- package/lib/from-connect.js +2 -3
- package/lib/idempotency.js +139 -0
- package/lib/json-api-query/index.js +0 -1
- package/lib/json-api-query/validate.js +1 -2
- package/lib/link.js +57 -5
- package/lib/prefer.js +1 -2
- package/lib/query.js +1 -2
- package/lib/rate-limit.js +1 -2
- package/lib/sanitize-quoted-string.js +0 -1
- package/lib/security-headers.js +1 -2
- package/lib/validate.js +1 -2
- package/lib/vary.js +0 -1
- package/package.json +2 -2
- package/types/http/idempotency.d.ts +20 -0
- package/types/http/main.d.ts +3 -1
- package/types/http/precondition.d.ts +1 -2
- package/types/lib/attach-instance.d.ts +0 -1
- package/types/lib/cookie/jar.d.ts +4 -0
- package/types/lib/from-connect.d.ts +2 -3
- package/types/lib/idempotency.d.ts +64 -0
- package/types/lib/link.d.ts +28 -0
- package/types/lib/prefer.d.ts +1 -2
- package/types/lib/rate-limit.d.ts +1 -2
- package/types/lib/sanitize-quoted-string.d.ts +0 -1
- package/types/lib/vary.d.ts +0 -1
- package/types/utils/compose.d.ts +1 -2
- package/types/utils/iterables/range.d.ts +1 -2
- package/utils/attempt.js +1 -2
- package/utils/buffers/index.js +0 -1
- package/utils/buffers/match.js +1 -2
- package/utils/buffers/split.js +1 -2
- package/utils/compose-with.js +1 -2
- package/utils/compose.js +1 -2
- package/utils/flat-array.js +1 -2
- package/utils/get.js +1 -2
- package/utils/http-errors.js +1 -2
- package/utils/iterables/buffer-split.js +1 -2
- package/utils/iterables/chain.js +1 -2
- package/utils/iterables/exec-all.js +1 -2
- package/utils/iterables/filter.js +1 -2
- package/utils/iterables/for-each.js +1 -2
- package/utils/iterables/from-stream.js +1 -2
- package/utils/iterables/index.js +0 -1
- package/utils/iterables/map.js +1 -2
- package/utils/iterables/range.js +1 -2
- package/utils/iterables/reduce.js +1 -2
- package/utils/iterables/take.js +1 -2
- package/utils/observables/buffer-split.js +0 -1
- package/utils/observables/chain.js +0 -1
- package/utils/observables/index.js +0 -1
- package/utils/observables/map.js +0 -1
- package/utils/observables/take.js +0 -1
- package/utils/pick.js +1 -2
- package/utils/set.js +1 -2
- package/utils/streams/index.js +0 -1
- package/utils/streams/meter.js +1 -2
- package/utils/streams/tee.js +1 -2
- package/utils/type.js +1 -2
package/types/lib/link.d.ts
CHANGED
|
@@ -35,3 +35,31 @@ export function paginationLinks({ baseUrl, page, perPage, total, searchParams }:
|
|
|
35
35
|
href: string;
|
|
36
36
|
rel: string;
|
|
37
37
|
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Generates cursor-based pagination link objects for first, prev, and next pages.
|
|
40
|
+
*
|
|
41
|
+
* Unlike offset pagination, cursor-based pagination uses opaque continuation
|
|
42
|
+
* tokens instead of page numbers. There is no `last` link because the total
|
|
43
|
+
* number of pages is unknown in cursor-based schemes.
|
|
44
|
+
*
|
|
45
|
+
* The `first` link is always present and points to the base URL without any
|
|
46
|
+
* cursor parameter (requesting the first page). `prev` and `next` are
|
|
47
|
+
* included only when the corresponding cursor token is provided.
|
|
48
|
+
*
|
|
49
|
+
* @param {object} options - Cursor pagination parameters
|
|
50
|
+
* @param {string} options.baseUrl - Base URL path (e.g. '/articles')
|
|
51
|
+
* @param {string} [options.searchParams=''] - Additional query parameters to preserve
|
|
52
|
+
* (e.g. 'sort=date&filter=active'). Appended before the cursor parameter.
|
|
53
|
+
* @param {string} [options.nextCursor] - Opaque cursor token for the next page
|
|
54
|
+
* @param {string} [options.prevCursor] - Opaque cursor token for the previous page
|
|
55
|
+
* @returns {Array<{href: string, rel: string}>} - Array of link objects
|
|
56
|
+
*/
|
|
57
|
+
export function cursorPaginationLinks({ baseUrl, searchParams, nextCursor, prevCursor }: {
|
|
58
|
+
baseUrl: string;
|
|
59
|
+
searchParams?: string | undefined;
|
|
60
|
+
nextCursor?: string | undefined;
|
|
61
|
+
prevCursor?: string | undefined;
|
|
62
|
+
}): Array<{
|
|
63
|
+
href: string;
|
|
64
|
+
rel: string;
|
|
65
|
+
}>;
|
package/types/lib/prefer.d.ts
CHANGED
|
@@ -13,11 +13,10 @@
|
|
|
13
13
|
* - `http/prefer.js` (ergo pipeline middleware)
|
|
14
14
|
*
|
|
15
15
|
* @module lib/prefer
|
|
16
|
-
* @version 0.1.0
|
|
17
16
|
* @since 0.1.0
|
|
18
17
|
*
|
|
19
18
|
* @example
|
|
20
|
-
* import parsePrefer from 'ergo/lib/prefer';
|
|
19
|
+
* import parsePrefer from '@centralping/ergo/lib/prefer';
|
|
21
20
|
*
|
|
22
21
|
* parsePrefer('return=minimal');
|
|
23
22
|
* // {return: 'minimal'}
|
|
@@ -39,11 +39,10 @@ export function defaultKeyGenerator(req: object): string;
|
|
|
39
39
|
* - `ergo-router/lib/transport/rate-limit.js` (transport-level rate limiting)
|
|
40
40
|
*
|
|
41
41
|
* @module lib/rate-limit
|
|
42
|
-
* @version 0.1.0
|
|
43
42
|
* @since 0.1.0
|
|
44
43
|
*
|
|
45
44
|
* @example
|
|
46
|
-
* import {MemoryStore, checkRateLimit, defaultKeyGenerator} from 'ergo/lib/rate-limit';
|
|
45
|
+
* import {MemoryStore, checkRateLimit, defaultKeyGenerator} from '@centralping/ergo/lib/rate-limit';
|
|
47
46
|
*
|
|
48
47
|
* const store = new MemoryStore();
|
|
49
48
|
* const key = defaultKeyGenerator(req);
|
package/types/lib/vary.d.ts
CHANGED
package/types/utils/compose.d.ts
CHANGED
|
@@ -20,11 +20,10 @@ export default compose;
|
|
|
20
20
|
* of ergo's built-in middleware).
|
|
21
21
|
*
|
|
22
22
|
* @module utils/compose
|
|
23
|
-
* @version 0.2.0
|
|
24
23
|
* @since 0.1.0
|
|
25
24
|
*
|
|
26
25
|
* @example
|
|
27
|
-
* import compose from 'ergo/utils/compose';
|
|
26
|
+
* import compose from '@centralping/ergo/utils/compose';
|
|
28
27
|
*
|
|
29
28
|
* const pipeline = compose(
|
|
30
29
|
* async (req, res) => ({user: await getUser(req)}),
|
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
* stepping by `step`. Mirrors Python's `range()` behaviour.
|
|
6
6
|
*
|
|
7
7
|
* @module utils/iterables/range
|
|
8
|
-
* @version 0.1.0
|
|
9
8
|
* @since 0.1.0
|
|
10
9
|
*
|
|
11
10
|
* @example
|
|
12
|
-
* import range from 'ergo/utils/iterables/range';
|
|
11
|
+
* import range from '@centralping/ergo/utils/iterables/range';
|
|
13
12
|
*
|
|
14
13
|
* [...range(5)] // => [0, 1, 2, 3, 4]
|
|
15
14
|
* [...range(1, 5)] // => [1, 2, 3, 4]
|
package/utils/attempt.js
CHANGED
|
@@ -7,11 +7,10 @@
|
|
|
7
7
|
* Used by `http/handler.js` to wrap the try pipeline with an error handler pipeline.
|
|
8
8
|
*
|
|
9
9
|
* @module utils/attempt
|
|
10
|
-
* @version 0.1.0
|
|
11
10
|
* @since 0.1.0
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
14
|
-
* import attempt from 'ergo/utils/attempt';
|
|
13
|
+
* import attempt from '@centralping/ergo/utils/attempt';
|
|
15
14
|
*
|
|
16
15
|
* const safe = attempt(
|
|
17
16
|
* async (req, res) => { throw new Error('oops'); },
|
package/utils/buffers/index.js
CHANGED
package/utils/buffers/match.js
CHANGED
|
@@ -9,11 +9,10 @@
|
|
|
9
9
|
* match state (`partial`) for the next chunk.
|
|
10
10
|
*
|
|
11
11
|
* @module utils/buffers/match
|
|
12
|
-
* @version 0.1.0
|
|
13
12
|
* @since 0.1.0
|
|
14
13
|
*
|
|
15
14
|
* @example
|
|
16
|
-
* import bufferMatch from 'ergo/utils/buffers/match';
|
|
15
|
+
* import bufferMatch from '@centralping/ergo/utils/buffers/match';
|
|
17
16
|
*
|
|
18
17
|
* const {matches} = bufferMatch(Buffer.from('hello world'), Buffer.from('l'));
|
|
19
18
|
* // matches => [2, 3, 9]
|
package/utils/buffers/split.js
CHANGED
|
@@ -8,13 +8,12 @@
|
|
|
8
8
|
* Returns `{buffers, partial, lookup}` where `buffers` is the array of Buffer slices.
|
|
9
9
|
*
|
|
10
10
|
* @module utils/buffers/split
|
|
11
|
-
* @version 0.1.0
|
|
12
11
|
* @since 0.1.0
|
|
13
12
|
* @requires ./match.js
|
|
14
13
|
* @requires ../get.js
|
|
15
14
|
*
|
|
16
15
|
* @example
|
|
17
|
-
* import bufferSplit from 'ergo/utils/buffers/split';
|
|
16
|
+
* import bufferSplit from '@centralping/ergo/utils/buffers/split';
|
|
18
17
|
*
|
|
19
18
|
* const {buffers} = bufferSplit(Buffer.from('a--b--c'), Buffer.from('--'));
|
|
20
19
|
* // buffers => [Buffer<'a'>, Buffer<'b'>, Buffer<'c'>]
|
package/utils/compose-with.js
CHANGED
|
@@ -21,13 +21,12 @@
|
|
|
21
21
|
* for compatibility with simple middleware that only produce domain data.
|
|
22
22
|
*
|
|
23
23
|
* @module utils/compose-with
|
|
24
|
-
* @version 0.2.0
|
|
25
24
|
* @since 0.1.0
|
|
26
25
|
* @requires ./compose.js
|
|
27
26
|
* @requires ./set.js
|
|
28
27
|
*
|
|
29
28
|
* @example
|
|
30
|
-
* import compose, {createResponseAcc} from 'ergo/utils/compose-with';
|
|
29
|
+
* import compose, {createResponseAcc} from '@centralping/ergo/utils/compose-with';
|
|
31
30
|
*
|
|
32
31
|
* const responseAcc = createResponseAcc();
|
|
33
32
|
* const pipeline = compose(
|
package/utils/compose.js
CHANGED
|
@@ -19,11 +19,10 @@
|
|
|
19
19
|
* of ergo's built-in middleware).
|
|
20
20
|
*
|
|
21
21
|
* @module utils/compose
|
|
22
|
-
* @version 0.2.0
|
|
23
22
|
* @since 0.1.0
|
|
24
23
|
*
|
|
25
24
|
* @example
|
|
26
|
-
* import compose from 'ergo/utils/compose';
|
|
25
|
+
* import compose from '@centralping/ergo/utils/compose';
|
|
27
26
|
*
|
|
28
27
|
* const pipeline = compose(
|
|
29
28
|
* async (req, res) => ({user: await getUser(req)}),
|
package/utils/flat-array.js
CHANGED
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
* Equivalent to `[...args].flat()` — accepts any mix of scalars and nested arrays.
|
|
6
6
|
*
|
|
7
7
|
* @module utils/flat-array
|
|
8
|
-
* @version 0.1.0
|
|
9
8
|
* @since 0.1.0
|
|
10
9
|
*
|
|
11
10
|
* @example
|
|
12
|
-
* import flatArray from 'ergo/utils/flat-array';
|
|
11
|
+
* import flatArray from '@centralping/ergo/utils/flat-array';
|
|
13
12
|
*
|
|
14
13
|
* flatArray('a', ['b', 'c'], 'd') // => ['a', 'b', 'c', 'd']
|
|
15
14
|
* flatArray(1, [2, 3], 4) // => [1, 2, 3, 4]
|
package/utils/get.js
CHANGED
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
* - Returns `undefined` gracefully when a step is missing (`safe: true`)
|
|
7
7
|
*
|
|
8
8
|
* @module utils/get
|
|
9
|
-
* @version 0.1.0
|
|
10
9
|
* @since 0.1.0
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
|
-
* import get from 'ergo/utils/get';
|
|
12
|
+
* import get from '@centralping/ergo/utils/get';
|
|
14
13
|
*
|
|
15
14
|
* get({a: {b: {c: 42}}}, 'a.b.c') // => 42
|
|
16
15
|
* get({a: null}, 'a.b.c', {safe: true}) // => undefined (no throw)
|
package/utils/http-errors.js
CHANGED
|
@@ -15,14 +15,13 @@
|
|
|
15
15
|
* catches them and forwards to `send()` for serialization.
|
|
16
16
|
*
|
|
17
17
|
* @module utils/http-errors
|
|
18
|
-
* @version 0.1.0
|
|
19
18
|
* @since 0.1.0
|
|
20
19
|
* @requires node:http
|
|
21
20
|
*
|
|
22
21
|
* @see {@link https://www.rfc-editor.org/rfc/rfc9457 RFC 9457 - Problem Details for HTTP APIs}
|
|
23
22
|
*
|
|
24
23
|
* @example
|
|
25
|
-
* import httpErrors from 'ergo/utils/http-errors';
|
|
24
|
+
* import httpErrors from '@centralping/ergo/utils/http-errors';
|
|
26
25
|
*
|
|
27
26
|
* throw httpErrors(404);
|
|
28
27
|
* // Error { name: 'NotFound', status: 404, type: 'https://...', title: 'Not Found', detail: 'Not Found' }
|
|
@@ -8,12 +8,11 @@
|
|
|
8
8
|
* Used by `lib/body/multiparse.js` for multipart boundary splitting.
|
|
9
9
|
*
|
|
10
10
|
* @module utils/iterables/buffer-split
|
|
11
|
-
* @version 0.1.0
|
|
12
11
|
* @since 0.1.0
|
|
13
12
|
* @requires ../buffers/split.js
|
|
14
13
|
*
|
|
15
14
|
* @example
|
|
16
|
-
* import {chain, bufferSplit, reduce} from 'ergo/utils/iterables';
|
|
15
|
+
* import {chain, bufferSplit, reduce} from '@centralping/ergo/utils/iterables';
|
|
17
16
|
*
|
|
18
17
|
* const chunks = [Buffer.from('a--b--c')];
|
|
19
18
|
* const result = chain(chunks, bufferSplit('--'), reduce((acc, [, b]) => [...acc, b.toString()], []));
|
package/utils/iterables/chain.js
CHANGED
|
@@ -8,11 +8,10 @@
|
|
|
8
8
|
* This is the core primitive for building lazy data pipelines with the iterable utilities.
|
|
9
9
|
*
|
|
10
10
|
* @module utils/iterables/chain
|
|
11
|
-
* @version 0.1.0
|
|
12
11
|
* @since 0.1.0
|
|
13
12
|
*
|
|
14
13
|
* @example
|
|
15
|
-
* import {chain, map, filter, reduce} from 'ergo/utils/iterables';
|
|
14
|
+
* import {chain, map, filter, reduce} from '@centralping/ergo/utils/iterables';
|
|
16
15
|
*
|
|
17
16
|
* chain(
|
|
18
17
|
* [1, 2, 3, 4, 5],
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
* flag is added to avoid infinite loops with stateful regexes.
|
|
7
7
|
*
|
|
8
8
|
* @module utils/iterables/exec-all
|
|
9
|
-
* @version 0.1.0
|
|
10
9
|
* @since 0.1.0
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
|
-
* import execAll from 'ergo/utils/iterables/exec-all';
|
|
12
|
+
* import execAll from '@centralping/ergo/utils/iterables/exec-all';
|
|
14
13
|
*
|
|
15
14
|
* const findWords = execAll(/([a-z]+)/ig);
|
|
16
15
|
* [...findWords('hello world')] // => [['hello'], ['world']]
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
* to the predicate (same signature as `Array.prototype.filter`).
|
|
7
7
|
*
|
|
8
8
|
* @module utils/iterables/filter
|
|
9
|
-
* @version 0.1.0
|
|
10
9
|
* @since 0.1.0
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
|
-
* import {chain, filter} from 'ergo/utils/iterables';
|
|
12
|
+
* import {chain, filter} from '@centralping/ergo/utils/iterables';
|
|
14
13
|
*
|
|
15
14
|
* [...chain([1, 2, 3, 4], filter(x => x % 2 === 0))] // => [2, 4]
|
|
16
15
|
*/
|
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
* for iterables, but composable in a `chain()` pipeline.
|
|
7
7
|
*
|
|
8
8
|
* @module utils/iterables/for-each
|
|
9
|
-
* @version 0.1.0
|
|
10
9
|
* @since 0.1.0
|
|
11
10
|
* @requires ./map.js
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
14
|
-
* import {chain, forEach, reduce} from 'ergo/utils/iterables';
|
|
13
|
+
* import {chain, forEach, reduce} from '@centralping/ergo/utils/iterables';
|
|
15
14
|
*
|
|
16
15
|
* chain(
|
|
17
16
|
* [1, 2, 3],
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
* interface for code that receives streams and needs to iterate them.
|
|
7
7
|
*
|
|
8
8
|
* @module utils/iterables/from-stream
|
|
9
|
-
* @version 0.1.0
|
|
10
9
|
* @since 0.1.0
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
|
-
* import fromStream from 'ergo/utils/iterables/from-stream';
|
|
12
|
+
* import fromStream from '@centralping/ergo/utils/iterables/from-stream';
|
|
14
13
|
* import {Readable} from 'node:stream';
|
|
15
14
|
*
|
|
16
15
|
* const readable = Readable.from(['hello', ' ', 'world']);
|
package/utils/iterables/index.js
CHANGED
package/utils/iterables/map.js
CHANGED
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
* async generators; sync transforms produce sync generators.
|
|
7
7
|
*
|
|
8
8
|
* @module utils/iterables/map
|
|
9
|
-
* @version 0.1.0
|
|
10
9
|
* @since 0.1.0
|
|
11
10
|
* @requires ../type.js
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
14
|
-
* import {chain, map} from 'ergo/utils/iterables';
|
|
13
|
+
* import {chain, map} from '@centralping/ergo/utils/iterables';
|
|
15
14
|
*
|
|
16
15
|
* [...chain([1, 2, 3], map(x => x * 2))] // => [2, 4, 6]
|
|
17
16
|
*
|
package/utils/iterables/range.js
CHANGED
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
* stepping by `step`. Mirrors Python's `range()` behaviour.
|
|
6
6
|
*
|
|
7
7
|
* @module utils/iterables/range
|
|
8
|
-
* @version 0.1.0
|
|
9
8
|
* @since 0.1.0
|
|
10
9
|
*
|
|
11
10
|
* @example
|
|
12
|
-
* import range from 'ergo/utils/iterables/range';
|
|
11
|
+
* import range from '@centralping/ergo/utils/iterables/range';
|
|
13
12
|
*
|
|
14
13
|
* [...range(5)] // => [0, 1, 2, 3, 4]
|
|
15
14
|
* [...range(1, 5)] // => [1, 2, 3, 4]
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
* least one element, the first element is used as the initial accumulator.
|
|
7
7
|
*
|
|
8
8
|
* @module utils/iterables/reduce
|
|
9
|
-
* @version 0.1.0
|
|
10
9
|
* @since 0.1.0
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
|
-
* import {chain, reduce} from 'ergo/utils/iterables';
|
|
12
|
+
* import {chain, reduce} from '@centralping/ergo/utils/iterables';
|
|
14
13
|
*
|
|
15
14
|
* chain([1, 2, 3, 4], reduce((sum, x) => sum + x, 0)) // => 10
|
|
16
15
|
*/
|
package/utils/iterables/take.js
CHANGED
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
* then returns (stops iteration).
|
|
6
6
|
*
|
|
7
7
|
* @module utils/iterables/take
|
|
8
|
-
* @version 0.1.0
|
|
9
8
|
* @since 0.1.0
|
|
10
9
|
*
|
|
11
10
|
* @example
|
|
12
|
-
* import {chain, take} from 'ergo/utils/iterables';
|
|
11
|
+
* import {chain, take} from '@centralping/ergo/utils/iterables';
|
|
13
12
|
*
|
|
14
13
|
* [...chain([1, 2, 3, 4, 5], take(3))] // => [1, 2, 3]
|
|
15
14
|
*/
|
package/utils/observables/map.js
CHANGED
package/utils/pick.js
CHANGED
|
@@ -6,13 +6,12 @@
|
|
|
6
6
|
* - Rename tuples: `pick(obj, ['a.b', 'c'])` extracts `obj.a.b` as `result.c`
|
|
7
7
|
*
|
|
8
8
|
* @module utils/pick
|
|
9
|
-
* @version 0.1.0
|
|
10
9
|
* @since 0.1.0
|
|
11
10
|
* @requires ./get.js
|
|
12
11
|
* @requires ./set.js
|
|
13
12
|
*
|
|
14
13
|
* @example
|
|
15
|
-
* import pick from 'ergo/utils/pick';
|
|
14
|
+
* import pick from '@centralping/ergo/utils/pick';
|
|
16
15
|
*
|
|
17
16
|
* pick({a: {b: 1}, c: 2}, 'a.b', 'c')
|
|
18
17
|
* // => {a: {b: 1}, c: 2}
|
package/utils/set.js
CHANGED
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
* Array nodes are created when the next path segment is a valid integer string.
|
|
7
7
|
*
|
|
8
8
|
* @module utils/set
|
|
9
|
-
* @version 0.1.0
|
|
10
9
|
* @since 0.1.0
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
|
-
* import set from 'ergo/utils/set';
|
|
12
|
+
* import set from '@centralping/ergo/utils/set';
|
|
14
13
|
*
|
|
15
14
|
* const obj = {};
|
|
16
15
|
* set(obj, 'a.b.c', 42); // obj => {a: {b: {c: 42}}}
|
package/utils/streams/index.js
CHANGED
package/utils/streams/meter.js
CHANGED
|
@@ -6,13 +6,12 @@
|
|
|
6
6
|
* (InvalidLength). Used by `http/body.js` to enforce size constraints.
|
|
7
7
|
*
|
|
8
8
|
* @module utils/streams/meter
|
|
9
|
-
* @version 0.1.0
|
|
10
9
|
* @since 0.1.0
|
|
11
10
|
* @requires node:stream
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
14
13
|
* import {pipeline} from 'node:stream';
|
|
15
|
-
* import meter from 'ergo/utils/streams/meter';
|
|
14
|
+
* import meter from '@centralping/ergo/utils/streams/meter';
|
|
16
15
|
*
|
|
17
16
|
* const m = meter({limit: 1024 * 1024, expected: 512});
|
|
18
17
|
* pipeline(readable, m, writable, err => {
|
package/utils/streams/tee.js
CHANGED
|
@@ -8,13 +8,12 @@
|
|
|
8
8
|
* If no generator is provided, a no-op generator is used (pure passthrough).
|
|
9
9
|
*
|
|
10
10
|
* @module utils/streams/tee
|
|
11
|
-
* @version 0.1.0
|
|
12
11
|
* @since 0.1.0
|
|
13
12
|
* @requires node:stream
|
|
14
13
|
*
|
|
15
14
|
* @example
|
|
16
15
|
* import {pipeline} from 'node:stream';
|
|
17
|
-
* import tee from 'ergo/utils/streams/tee';
|
|
16
|
+
* import tee from '@centralping/ergo/utils/streams/tee';
|
|
18
17
|
*
|
|
19
18
|
* async function* inspect(gen) {
|
|
20
19
|
* let chunk;
|
package/utils/type.js
CHANGED
|
@@ -9,11 +9,10 @@
|
|
|
9
9
|
* Used throughout Ergo for duck-typing checks (e.g. `type(x) === 'AsyncGeneratorFunction'`).
|
|
10
10
|
*
|
|
11
11
|
* @module utils/type
|
|
12
|
-
* @version 0.1.0
|
|
13
12
|
* @since 0.1.0
|
|
14
13
|
*
|
|
15
14
|
* @example
|
|
16
|
-
* import type from 'ergo/utils/type';
|
|
15
|
+
* import type from '@centralping/ergo/utils/type';
|
|
17
16
|
*
|
|
18
17
|
* type(42) // 'Number'
|
|
19
18
|
* type(NaN) // 'NaN'
|