Skip to content

Commit 882b749

Browse files
committed
Release 0.13.12
1 parent e418260 commit 882b749

61 files changed

Lines changed: 678 additions & 322 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bin/build

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh -e
2+
3+
node_modules/.bin/kiss-test 'src/**/*.test.js'
4+
5+
node_modules/.bin/eslint --fix
6+
7+
node_modules/.bin/tsc \
8+
--allowJs \
9+
--declaration \
10+
--emitDeclarationOnly \
11+
--module NodeNext \
12+
--moduleResolution NodeNext \
13+
--outDir types \
14+
--rootDir src \
15+
--strict \
16+
--target ESNext \
17+
src/index.js
18+
19+
node_modules/.bin/tsc || true

bin/dev

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh -e
2+
3+
exec node_modules/.bin/watchy -w src -- bin/build

bin/release

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh -e
2+
3+
bin/build
4+
5+
bumpit
6+
7+
version=$(jq -r .version package.json)
8+
9+
git commit -am "Release $version"
10+
git tag -m $version $version
11+
git push
12+
git push --tags
13+
npm publish

bin/test

Lines changed: 0 additions & 3 deletions
This file was deleted.

bin/test-watch

Lines changed: 0 additions & 3 deletions
This file was deleted.

eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import config from 'eslint-config-coderiety';
2+
3+
export default [...config, { ignores: ['types'] }];

package.json

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
{
22
"name": "pave",
33
"type": "module",
4-
"version": "0.13.11",
4+
"version": "0.13.12",
55
"author": "Casey Foster <c@sey.me>",
66
"license": "MIT",
7-
"main": "src/index.js",
8-
"module": "src/index.js",
9-
"sideEffects": false,
107
"repository": {
118
"type": "git",
129
"url": "https://github.com/caseywebdev/pave"
1310
},
11+
"imports": {
12+
"#*": "./*"
13+
},
14+
"exports": {
15+
".": {
16+
"types": "./types/index.d.ts",
17+
"default": "./src/index.js"
18+
}
19+
},
1420
"devDependencies": {
21+
"@types/node": "22",
22+
"eslint-config-coderiety": "2",
23+
"eslint": "9",
1524
"kiss-test": "0.2",
25+
"typescript": "5",
1626
"watchy": "0.10"
1727
},
1828
"files": [
19-
"/src/*.js",
20-
"!/src/*.test.js"
29+
"/src",
30+
"!/src/*.test.js",
31+
"/types"
2132
]
2233
}

src/cache-execute.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import isObject from './is-object.js';
2-
import normalizeKey from './normalize-key.js';
3-
import normalizeRoot from './normalize-root.js';
1+
/** @import {Query} from '#src/index.js' */
2+
3+
import { isObject } from '#src/is-object.js';
4+
import { normalizeKey } from '#src/normalize-key.js';
5+
import { normalizeRoot } from '#src/normalize-root.js';
46

57
const { isArray } = Array;
68

9+
/**
10+
* @param {{ cache: { [K: string]: any }; query: Query; value: any }} options
11+
* @returns {any}
12+
*/
713
const walk = ({ cache, query, value }) => {
814
while (true) {
915
if (isArray(value)) {
@@ -25,10 +31,10 @@ const walk = ({ cache, query, value }) => {
2531
continue;
2632
}
2733

28-
// eslint-disable-next-line no-unused-vars
34+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2935
let { _, $, ..._query } = query;
3036
_query = _query[`_on_${value._type}`] ?? _query;
31-
const data = {};
37+
const data = /** @type {typeof _query} */ ({});
3238
for (const alias in _query) {
3339
if (alias.startsWith('_on_')) continue;
3440

@@ -43,5 +49,6 @@ const walk = ({ cache, query, value }) => {
4349
}
4450
};
4551

46-
export default ({ cache, key, query }) =>
52+
/** @param {{ cache: { [K: string]: any }; key?: string; query: Query }} options */
53+
export const cacheExecute = ({ cache, key, query }) =>
4754
walk({ cache, query, value: cache[key ?? normalizeRoot({ query })] });

src/cache-execute.test.js

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import { strict as assert } from 'assert';
1+
import { strict as assert } from 'node:assert';
22

3-
import cacheExecute from './cache-execute.js';
3+
import { cacheExecute } from '#src/cache-execute.js';
44

55
export default {
66
missing: () => {
77
assert.deepEqual(
8-
cacheExecute({
9-
cache: {},
10-
query: { dne: {} }
11-
}),
8+
cacheExecute({ cache: {}, query: { dne: {} } }),
129
undefined
1310
);
1411
},
@@ -111,21 +108,9 @@ export default {
111108
root: { _type: ['Root'] }
112109
}
113110
},
114-
query: {
115-
foo: {
116-
id: {},
117-
name: {},
118-
root: { foo: { id: {} } }
119-
}
120-
}
111+
query: { foo: { id: {}, name: {}, root: { foo: { id: {} } } } }
121112
}),
122-
{
123-
foo: {
124-
id: 1,
125-
name: 'foo',
126-
root: { foo: { id: 1 } }
127-
}
128-
}
113+
{ foo: { id: 1, name: 'foo', root: { foo: { id: 1 } } } }
129114
);
130115
},
131116
literal: () => {
@@ -136,9 +121,7 @@ export default {
136121
},
137122
query: { literal: { ignored: {} } }
138123
}),
139-
{
140-
literal: { _literal: 'anything', _ref: 'nofollow' }
141-
}
124+
{ literal: { _literal: 'anything', _ref: 'nofollow' } }
142125
);
143126
}
144127
};

src/context.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default class Context {
1+
export class Context {
22
/**
33
* @param {unknown} context
44
* @param {unknown} [value]

0 commit comments

Comments
 (0)