Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ cases/ts-auto-guard/build
cases/ts-auto-guard/src/index.guard.ts
cases/type-predicate-generator/build
cases/type-predicate-generator/src/index_guards.ts
cases/paseri/src/index.ts
cases/paseri/build
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,8 @@ cases/ts-auto-guard/src/index.guard.ts
cases/type-predicate-generator/build
cases/type-predicate-generator/src/index_guards.ts

# Paseri
cases/paseri/build

# Bun binary lock file makes mergin harder. Using text lock file instead.
bun.lockb
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
save-exact=true
save-exact=true
@jsr:registry=https://npm.jsr.io
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* [pure-parse](https://github.com/johannes-lindgren/pure-parse)
* [purify-ts](https://github.com/gigobyte/purify)
* [parse-dont-validate](https://github.com/Packer-Man/parse-dont-validate)
* [Paseri](https://github.com/vbudovski/paseri)
* [r-assign](https://github.com/micnic/r-assign)
* [rescript-schema](https://github.com/DZakh/rescript-schema)
* [rulr](https://github.com/ryansmith94/rulr)
Expand Down
116 changes: 91 additions & 25 deletions bun.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cases/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const cases = [
'myzod',
'ok-computer',
'parse-dont-validate',
'paseri',
'pure-parse',
'purify-ts',
'r-assign',
Expand Down
76 changes: 76 additions & 0 deletions cases/paseri/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import * as p from './build';
import { addCase } from '../../benchmarks';

const dataTypeStrip = p
.object({
number: p.number(),
negNumber: p.number(),
maxNumber: p.number(),
string: p.string(),
longString: p.string(),
boolean: p.boolean(),
deeplyNested: p
.object({
foo: p.string(),
num: p.number(),
bool: p.boolean(),
})
.strip(),
})
.strip();

const dataTypeStrict = p
.object({
number: p.number(),
negNumber: p.number(),
maxNumber: p.number(),
string: p.string(),
longString: p.string(),
boolean: p.boolean(),
deeplyNested: p
.object({
foo: p.string(),
num: p.number(),
bool: p.boolean(),
})
.strict(),
})
.strict();

const dataTypePassthrough = p
.object({
number: p.number(),
negNumber: p.number(),
maxNumber: p.number(),
string: p.string(),
longString: p.string(),
boolean: p.boolean(),
deeplyNested: p
.object({
foo: p.string(),
num: p.number(),
bool: p.boolean(),
})
.passthrough(),
})
.passthrough();

addCase('paseri', 'parseSafe', data => {
return dataTypeStrip.parse(data);
});

addCase('paseri', 'parseStrict', data => {
return dataTypeStrict.parse(data);
});

addCase('paseri', 'assertLoose', data => {
dataTypePassthrough.parse(data);

return true;
});

addCase('paseri', 'assertStrict', data => {
dataTypeStrict.parse(data);

return true;
});
3 changes: 3 additions & 0 deletions cases/paseri/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { object, string, number, boolean } from '@vbudovski/paseri';

export { object, string, number, boolean };
9 changes: 9 additions & 0 deletions cases/paseri/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"moduleResolution": "Bundler",
"module": "ESNext"
},
"exclude": ["build"],
"reflection": true
}
5 changes: 5 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ async function main() {
stdio: 'inherit',
});
}
if (c === 'paseri') {
childProcess.execSync('npm run compile:paseri', {
stdio: 'inherit',
});
}

const cmd = [...process.argv.slice(0, 2), 'run-internal', c];

Expand Down
Loading
Loading