Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add banditypes #1034

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
## Packages Compared

* [ajv](https://ajv.js.org/)
* [banditypes](https://github.com/thoughtspile/banditypes)
* [bueno](https://github.com/philipnilsson/bueno)
* [class-validator](https://github.com/typestack/class-validator) + [class-transformer](https://github.com/typestack/class-transformer)
* [computed-types](https://github.com/neuledge/computed-types)
Expand Down
26 changes: 26 additions & 0 deletions cases/banditypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { boolean, number, object, string } from 'banditypes';
import { addCase } from '../benchmarks';

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

addCase('banditypes', 'parseSafe', data => {
return dataTypeSafe(data);
});

addCase('banditypes', 'assertLoose', data => {
dataTypeSafe(data);

return true;
});
1 change: 1 addition & 0 deletions cases/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const cases = [
'ajv',
'banditypes',
'bueno',
'class-validator',
'computed-types',
Expand Down
2 changes: 1 addition & 1 deletion docs/results/node-16.json

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@typeofweb/schema": "0.7.3",
"@types/benchmark": "2.1.2",
"ajv": "8.11.0",
"banditypes": "0.2.2",
"benny": "3.7.1",
"bueno": "0.1.5",
"class-transformer": "0.5.1",
Expand Down
1 change: 1 addition & 0 deletions test/benchmarks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { cases } from '../cases';
// all cases need to be imported here because jest cannot pic up dynamically
// imported `test` and `describe`
import '../cases/ajv';
import '../cases/banditypes';
import '../cases/bueno';
import '../cases/class-validator';
import '../cases/computed-types';
Expand Down