Skip to content

Commit

Permalink
Merge pull request #37 from lxsmnsyc/next
Browse files Browse the repository at this point in the history
1.0 Next
  • Loading branch information
lxsmnsyc authored Dec 12, 2023
2 parents f37faa5 + 2a46071 commit 9300c24
Show file tree
Hide file tree
Showing 174 changed files with 8,422 additions and 9,182 deletions.
11 changes: 0 additions & 11 deletions .eslintrc

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ console.log(result);
Output (as a string):

```js
((h,j,k,m,o)=>(o={number:[0.3325212548332517,-0,0/0,1/0,-1/0],string:["hello world","\x3Cscript>Hello World\x3C/script>"],boolean:[!0,!1],null:null,undefined:void 0,bigint:9007199254740991n,array:h=[,,,,k=(j=[],new Map([["hello","world"],["mutual",m=new Set(["hello","world"])]]))],regexp:/[a-z0-9]+/i,date:new Date("2023-11-19T09:25:24.118Z"),map:k,set:m},h[3]=h,k.set("self",k),m.add(m).add(h),o.self=o,o))()
((h,j,k,m,o)=>(o={number:[0.5337763749243287,-0,0/0,1/0,-1/0],string:["hello world","\x3Cscript>Hello World\x3C/script>"],boolean:[!0,!1],null:null,undefined:void 0,bigint:9007199254740991n,array:h=[,,,,k=(j=[],new Map([["hello","world"],["mutual",m=new Set(["hello","world"])]]))],regexp:/[a-z0-9]+/i,date:new Date("2023-12-07T17:28:57.909Z"),map:k,set:m},h[3]=h,k.set("self",k),m.add(m).add(h),o.self=o,o))()

// Formatted for readability
((h, j, k, m, o) => (
(o = {
number: [0.3325212548332517, -0, 0 / 0, 1 / 0, -1 / 0],
number: [0.5337763749243287, -0, 0 / 0, 1 / 0, -1 / 0],
string: ["hello world", "\x3Cscript>Hello World\x3C/script>"],
boolean: [!0, !1],
null: null,
Expand All @@ -83,7 +83,7 @@ Output (as a string):
]))),
]),
regexp: /[a-z0-9]+/i,
date: new Date("2023-11-19T09:25:24.118Z"),
date: new Date("2023-12-07T17:28:57.909Z"),
map: k,
set: m,
}),
Expand Down
18 changes: 0 additions & 18 deletions benchmark/.eslintrc.cjs

This file was deleted.

10 changes: 3 additions & 7 deletions benchmark/build-src.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import * as esbuild from 'esbuild';

esbuild.buildSync({
entryPoints: [
'./src/index.ts',
],
entryPoints: ['./src/index.ts'],
outfile: './build/index.cjs',
bundle: true,
minify: true,
sourcemap: false,
format: 'cjs',
platform: 'node',
tsconfig: './tsconfig.json',
target: "es2018",
target: 'es2018',
legalComments: 'eof',
external: [
"benny",
],
external: ['benny'],
});
9 changes: 9 additions & 0 deletions benchmark/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { serializeAsync } from 'seroval';
import { BlobPlugin } from 'seroval-plugins/web';

const example = new Blob(['Hello, World!'], { type: 'text/plain ' });
console.log(
await serializeAsync(example, {
plugins: [BlobPlugin],
}),
);
7 changes: 3 additions & 4 deletions benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"devDependencies": {
"@types/node": "^20.8.3",
"esbuild": "^0.19.4",
"eslint": "^8.51.0",
"eslint-config-lxsmnsyc": "^0.6.5",
"tslib": "^2.6.2",
"typescript": "^5.3.2"
},
Expand All @@ -21,7 +19,8 @@
"next-json": "^0.2.2",
"o-son": "^1.0.1",
"serialize-javascript": "^6.0.1",
"seroval": "workspace:^0.15.1",
"seroval": "workspace:*",
"seroval-plugins": "workspace:*",
"superjson": "^1.13.3",
"tosource": "2.0.0-alpha.3",
"warp10": "^2.1.0"
Expand All @@ -44,4 +43,4 @@
"*": {}
},
"version": "0.15.1"
}
}
45 changes: 21 additions & 24 deletions benchmark/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/* eslint-disable no-void */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import util from 'util';
import {
suite, add, cycle, complete, save,
} from 'benny';
import { suite, add, cycle, complete, save } from 'benny';

// fixtures
import circularDedupe from './fixtures/circular-dedupe';
Expand Down Expand Up @@ -43,24 +39,24 @@ const tools = [
];

const fixtures = {
// 'circular-dedupe': circularDedupe,
// 'circular-simple': circularSimple,
// 'dedupe-object': dedupeObject,
// 'large-circular-collection': largeCircularCollection,
// 'large-complex-collection': largeComplexCollection,
// 'large-dedupe-collection': largeDedupeCollection,
// 'large-invalid-keys-collection': largeInvalidKeysCollection,
// 'large-simple-collection': largeSimpleCollection,
// 'simple-object': simpleObject,
'circular-dedupe': circularDedupe,
'circular-simple': circularSimple,
'dedupe-object': dedupeObject,
'large-circular-collection': largeCircularCollection,
'large-complex-collection': largeComplexCollection,
'large-dedupe-collection': largeDedupeCollection,
'large-invalid-keys-collection': largeInvalidKeysCollection,
'large-simple-collection': largeSimpleCollection,
'simple-object': simpleObject,
'small-collection': smallCollection,
};

Object.entries(fixtures).forEach(([key, value]) => {
for (const [key, value] of Object.entries(fixtures)) {
const suiteName = key;
const getData = value as () => unknown;

// Skip benchmarks that couldn't properly serialize and hydrate the structure.
const toolsForFixture = tools.map((tool) => {
const toolsForFixture = tools.map(tool => {
let skip = false;
try {
skip = !util.isDeepStrictEqual(
Expand All @@ -76,9 +72,11 @@ Object.entries(fixtures).forEach(([key, value]) => {

void suite(
`${suiteName} to string`,
...toolsForFixture.map(({ name, utils, skip }) => (skip ? add.skip : add)(name, () => {
utils.toString(getData());
})),
...toolsForFixture.map(({ name, utils, skip }) =>
(skip ? add.skip : add)(name, () => {
utils.toString(getData());
}),
),
cycle(),
complete(),
save({
Expand All @@ -99,17 +97,16 @@ Object.entries(fixtures).forEach(([key, value]) => {

void suite(
`${suiteName} from string`,
...toolsForFixture.map(({ name, utils }) => (
...toolsForFixture.map(({ name, utils }) =>
// This does not account for parse time since eval is cached.
// skipped for now because it is not useful until a way to avoid eval cache is found.
add.skip(name, () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const sampleOutput = utils.toString(getData());
return (): void => {
utils.fromString(sampleOutput);
};
})
)),
}),
),
cycle(),
complete(),
save({
Expand All @@ -127,4 +124,4 @@ Object.entries(fixtures).forEach(([key, value]) => {
format: 'csv',
}),
);
});
}
21 changes: 0 additions & 21 deletions benchmark/tsconfig.eslint.json

This file was deleted.

Loading

0 comments on commit 9300c24

Please sign in to comment.