Skip to content

Commit 34e4b9d

Browse files
committed
feat: remove fast-json-stringify
With "fast-json-stringify": simple message x 731,726 ops/sec ±1.00% (96 runs sampled) message with printf x 604,838 ops/sec ±0.98% (95 runs sampled) message with context x 660,218 ops/sec ±0.68% (97 runs sampled) message with large context x 715,211 ops/sec ±1.52% (74 runs sampled) message with large context x 724,470 ops/sec ±1.29% (77 runs sampled) Without "fast-json-stringify": simple message x 630,566 ops/sec ±0.59% (99 runs sampled) message with printf x 551,880 ops/sec ±0.49% (100 runs sampled) message with context x 577,205 ops/sec ±0.57% (99 runs sampled) message with large context x 620,727 ops/sec ±1.03% (78 runs sampled) message with large context x 622,001 ops/sec ±1.47% (76 runs sampled) The difference is too minor at this point to make it worthwhile
1 parent 074e361 commit 34e4b9d

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

package-lock.json

+40-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
},
1818
"browser": "./dist/browser.js",
1919
"dependencies": {
20-
"fast-json-stringify": "^5.8.0",
2120
"fast-printf": "^1.6.9",
2221
"safe-stable-stringify": "^2.4.3",
2322
"semver-compare": "^1.0.0"

src/Roarr.ts

+1-25
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,16 @@
11
import { createLogger } from './factories/createLogger';
22
import { createRoarrInitialGlobalState } from './factories/createRoarrInitialGlobalState';
33
import { type MessageSerializer, type RoarrGlobalState } from './types';
4-
import fastJson from 'fast-json-stringify';
54
import safeStringify from 'safe-stable-stringify';
65

7-
const fastStringify = fastJson({
8-
properties: {
9-
message: {
10-
type: 'string',
11-
},
12-
sequence: {
13-
type: 'string',
14-
},
15-
time: {
16-
type: 'integer',
17-
},
18-
version: {
19-
type: 'string',
20-
},
21-
},
22-
type: 'object',
23-
});
24-
256
const ROARR = createRoarrInitialGlobalState(
267
(globalThis.ROARR as RoarrGlobalState) || {},
278
);
289

2910
globalThis.ROARR = ROARR;
3011

3112
const serializeMessage: MessageSerializer = (message) => {
32-
return (
33-
'{"context":' +
34-
safeStringify(message.context) +
35-
',' +
36-
fastStringify(message).slice(1)
37-
);
13+
return safeStringify(message);
3814
};
3915

4016
const Roarr = createLogger((message) => {

0 commit comments

Comments
 (0)