Skip to content

Commit 63deffb

Browse files
authored
Merge pull request #50 from jsonjoy-com/tuple-keys
feat: 🎸 allow "key" type in tuples
2 parents 7df727d + b679a94 commit 63deffb

File tree

86 files changed

+1232
-859
lines changed

Some content is hidden

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

86 files changed

+1232
-859
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
- Do not add trivial comments, usually do not add blank lines inside functions.
22
- Use Angular style commits, e.g `feat: implemented xyz`.
33
- Make sure tests (`yarn test`) pass.
4-
- In the end, make sure linter and formatter pass.
4+
- When you are doing a PR, make sure linter and formatter pass.

biome.json

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
3-
"organizeImports": {
4-
"enabled": true
5-
},
6-
"formatter": {
7-
"indentStyle": "space",
8-
"lineWidth": 120
9-
},
10-
"javascript": {
11-
"formatter": {
12-
"quoteStyle": "single",
13-
"trailingCommas": "all",
14-
"bracketSpacing": false
15-
}
16-
},
17-
"linter": {
18-
"enabled": true,
19-
"rules": {
20-
"recommended": true,
21-
"style": {
22-
"noNonNullAssertion": "off",
23-
"useNodejsImportProtocol": "off",
24-
"useTemplate": "off",
25-
"noInferrableTypes": "off",
26-
"noUselessElse": "off",
27-
"noParameterAssign": "off",
28-
"noCommaOperator": "off",
29-
"useSingleVarDeclarator": "off",
30-
"noUnusedTemplateLiteral": "off",
31-
"useDefaultParameterLast": "off",
32-
"useEnumInitializers": "off"
33-
},
34-
"suspicious": {
35-
"noExplicitAny": "off",
36-
"useIsArray": "off",
37-
"noAssignInExpressions": "off",
38-
"noConfusingVoidType": "off"
39-
},
40-
"complexity": {
41-
"noStaticOnlyClass": "off",
42-
"useOptionalChain": "off"
43-
},
44-
"security": {
45-
"noGlobalEval": "off"
46-
}
47-
}
48-
}
2+
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"formatter": {
7+
"indentStyle": "space",
8+
"lineWidth": 120
9+
},
10+
"javascript": {
11+
"formatter": {
12+
"quoteStyle": "single",
13+
"trailingCommas": "all",
14+
"bracketSpacing": false
15+
}
16+
},
17+
"linter": {
18+
"enabled": true,
19+
"rules": {
20+
"recommended": true,
21+
"style": {
22+
"noNonNullAssertion": "off",
23+
"useNodejsImportProtocol": "off",
24+
"useTemplate": "off",
25+
"noInferrableTypes": "off",
26+
"noUselessElse": "off",
27+
"noParameterAssign": "off",
28+
"noCommaOperator": "off",
29+
"useSingleVarDeclarator": "off",
30+
"noUnusedTemplateLiteral": "off",
31+
"useDefaultParameterLast": "off",
32+
"useEnumInitializers": "off"
33+
},
34+
"suspicious": {
35+
"noExplicitAny": "off",
36+
"useIsArray": "off",
37+
"noAssignInExpressions": "off",
38+
"noConfusingVoidType": "off"
39+
},
40+
"complexity": {
41+
"noStaticOnlyClass": "off",
42+
"useOptionalChain": "off"
43+
},
44+
"security": {
45+
"noGlobalEval": "off"
46+
}
47+
}
48+
}
4949
}

package.json

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,14 @@
1616
"type": "github",
1717
"url": "https://github.com/sponsors/streamich"
1818
},
19-
"keywords": [
20-
"json-type",
21-
"type",
22-
"schema",
23-
"json-schema",
24-
"jtd",
25-
"json",
26-
"pointer",
27-
"jit"
28-
],
19+
"keywords": ["json-type", "type", "schema", "json-schema", "jtd", "json", "pointer", "jit"],
2920
"engines": {
3021
"node": ">=10.0"
3122
},
3223
"main": "lib/index.js",
3324
"types": "lib/index.d.ts",
3425
"typings": "lib/index.d.ts",
35-
"files": [
36-
"LICENSE",
37-
"lib/"
38-
],
26+
"files": ["LICENSE", "lib/"],
3927
"license": "Apache-2.0",
4028
"scripts": {
4129
"format": "biome format ./src",
@@ -79,16 +67,11 @@
7967
"typescript": "^5.6.2"
8068
},
8169
"jest": {
82-
"moduleFileExtensions": [
83-
"ts",
84-
"js"
85-
],
70+
"moduleFileExtensions": ["ts", "js"],
8671
"transform": {
8772
"^.+\\.ts$": "ts-jest"
8873
},
89-
"transformIgnorePatterns": [
90-
".*/node_modules/.*"
91-
],
74+
"transformIgnorePatterns": [".*/node_modules/.*"],
9275
"testRegex": ".*/(__tests__|__jest__|demo)/.*\\.(test|spec)\\.ts$"
9376
}
9477
}

src/__bench__/encode.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
/* tslint:disable no-console */
22

3-
import {ModuleType} from '..';
3+
import {Writer} from '@jsonjoy.com/buffers/lib/Writer';
44
import {CborEncoder} from '@jsonjoy.com/json-pack/lib/cbor/CborEncoder';
5+
import {EncodingFormat} from '@jsonjoy.com/json-pack/lib/constants';
56
import {JsonEncoder} from '@jsonjoy.com/json-pack/lib/json/JsonEncoder';
7+
import {ModuleType} from '..';
68
import type {CompiledBinaryEncoder} from '../codegen/types';
7-
import {EncodingFormat} from '@jsonjoy.com/json-pack/lib/constants';
8-
import {Writer} from '@jsonjoy.com/buffers/lib/Writer';
99

1010
const system = new ModuleType();
1111
const {t} = system;
1212

1313
const response = system.alias(
1414
'Response',
1515
t.Object(
16-
t.prop(
16+
t.Key(
1717
'collection',
1818
t.Object(
19-
t.prop('id', t.String({ascii: true, noJsonEscape: true})),
20-
t.prop('ts', t.num.options({format: 'u64'})),
21-
t.prop('cid', t.String({ascii: true, noJsonEscape: true})),
22-
t.prop('prid', t.String({ascii: true, noJsonEscape: true})),
23-
t.prop('slug', t.String({ascii: true, noJsonEscape: true})),
24-
t.propOpt('name', t.str),
25-
t.propOpt('src', t.str),
26-
t.propOpt('doc', t.str),
27-
t.propOpt('longText', t.str),
28-
t.prop('active', t.bool),
29-
t.prop('views', t.Array(t.num)),
19+
t.Key('id', t.String({ascii: true, noJsonEscape: true})),
20+
t.Key('ts', t.num.options({format: 'u64'})),
21+
t.Key('cid', t.String({ascii: true, noJsonEscape: true})),
22+
t.Key('prid', t.String({ascii: true, noJsonEscape: true})),
23+
t.Key('slug', t.String({ascii: true, noJsonEscape: true})),
24+
t.KeyOpt('name', t.str),
25+
t.KeyOpt('src', t.str),
26+
t.KeyOpt('doc', t.str),
27+
t.KeyOpt('longText', t.str),
28+
t.Key('active', t.bool),
29+
t.Key('views', t.Array(t.num)),
3030
),
3131
),
32-
t.prop(
32+
t.Key(
3333
'block',
3434
t.Object(
35-
t.prop('id', t.String({ascii: true, noJsonEscape: true})),
36-
t.prop('ts', t.num.options({format: 'u64'})),
37-
t.prop('cid', t.String({ascii: true, noJsonEscape: true})),
38-
t.prop('slug', t.String({ascii: true, noJsonEscape: true})),
35+
t.Key('id', t.String({ascii: true, noJsonEscape: true})),
36+
t.Key('ts', t.num.options({format: 'u64'})),
37+
t.Key('cid', t.String({ascii: true, noJsonEscape: true})),
38+
t.Key('slug', t.String({ascii: true, noJsonEscape: true})),
3939
),
4040
),
4141
),

0 commit comments

Comments
 (0)