Skip to content

Commit ffe0184

Browse files
authored
Add Sury to the benchmark (#1896)
1 parent 69c517a commit ffe0184

File tree

7 files changed

+80
-0
lines changed

7 files changed

+80
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
* [succulent](https://github.com/aslilac/succulent)
5252
* [superstruct](https://github.com/ianstormtaylor/superstruct)
5353
* [suretype](https://github.com/grantila/suretype)
54+
* [sury](https://github.com/DZakh/sury)
5455
* [tiny-schema-validator](https://github.com/5alidz/tiny-schema-validator)
5556
* [to-typed](https://github.com/jsoldi/to-typed)
5657
* [toi](https://github.com/hf/toi)

cases/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const cases = [
3838
'succulent',
3939
'superstruct',
4040
'suretype',
41+
'sury',
4142
'tiny-schema-validator',
4243
'to-typed',
4344
'toi',

cases/sury.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import * as S from 'sury';
2+
3+
import { createCase } from '../benchmarks';
4+
5+
S.global({
6+
disableNanNumberValidation: true,
7+
});
8+
9+
const schema = S.schema({
10+
number: S.number,
11+
negNumber: S.number,
12+
maxNumber: S.number,
13+
string: S.string,
14+
longString: S.string,
15+
boolean: S.boolean,
16+
deeplyNested: {
17+
foo: S.string,
18+
num: S.number,
19+
bool: S.boolean,
20+
},
21+
});
22+
23+
createCase('sury', 'parseSafe', () => {
24+
const parseSafe = S.compile(schema, 'Any', 'Output', 'Sync');
25+
return data => {
26+
return parseSafe(data);
27+
};
28+
});
29+
30+
createCase('sury', 'parseStrict', () => {
31+
const parseStrict = S.compile(S.deepStrict(schema), 'Any', 'Output', 'Sync');
32+
return data => {
33+
return parseStrict(data);
34+
};
35+
});
36+
37+
createCase('sury', 'assertLoose', () => {
38+
const assertLoose = S.compile(schema, 'Any', 'Assert', 'Sync');
39+
return data => {
40+
assertLoose(data)!;
41+
return true;
42+
};
43+
});
44+
45+
createCase('sury', 'assertStrict', () => {
46+
const assertStrict = S.compile(S.deepStrict(schema), 'Any', 'Assert', 'Sync');
47+
return data => {
48+
assertStrict(data)!;
49+
return true;
50+
};
51+
});

download-packages-popularity.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ export const packages = [
134134
name: 'suretype',
135135
packageName: 'suretype',
136136
},
137+
{
138+
name: 'sury',
139+
packageName: 'sury',
140+
},
137141
{
138142
name: 'tiny-schema-validator',
139143
packageName: 'tiny-schema-validator',

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"succulent": "0.18.1",
8585
"superstruct": "2.0.2",
8686
"suretype": "2.4.1",
87+
"sury": "10.0.0",
8788
"svgo": "3.3.2",
8889
"tiny-schema-validator": "5.0.3",
8990
"to-typed": "0.5.2",

test/benchmarks.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import '../cases/stnl';
4343
import '../cases/succulent';
4444
import '../cases/superstruct';
4545
import '../cases/suretype';
46+
import '../cases/sury';
4647
import '../cases/to-typed';
4748
import '../cases/toi';
4849
import '../cases/ts-interface-checker';

0 commit comments

Comments
 (0)