@zuplo/cli 6.71.22 → 6.71.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/node_modules/@fastify/fast-json-stringify-compiler/.github/dependabot.yml +42 -2
  2. package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/ci.yml +6 -1
  3. package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/lock-threads.yml +19 -0
  4. package/node_modules/@fastify/fast-json-stringify-compiler/LICENSE +1 -1
  5. package/node_modules/@fastify/fast-json-stringify-compiler/README.md +1 -1
  6. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.gitattributes +2 -0
  7. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/dependabot.yml +13 -0
  8. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/ci.yml +33 -0
  9. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/lock-threads.yml +19 -0
  10. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/LICENSE +22 -0
  11. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/README.md +742 -0
  12. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-branch.js +116 -0
  13. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-lib.js +339 -0
  14. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-thread.js +33 -0
  15. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench.js +391 -0
  16. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/build/build-schema-validator.js +26 -0
  17. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/eslint.config.js +9 -0
  18. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/example.js +81 -0
  19. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/server.js +42 -0
  20. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/index.js +1308 -0
  21. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/location.js +24 -0
  22. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/merge-schemas.js +9 -0
  23. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/schema-validator.js +1134 -0
  24. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/serializer.js +141 -0
  25. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/standalone.js +34 -0
  26. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/validator.js +96 -0
  27. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/package.json +89 -0
  28. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/additionalProperties.test.js +332 -0
  29. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/allof.test.js +751 -0
  30. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/any.test.js +231 -0
  31. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/anyof.test.js +812 -0
  32. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/array.test.js +688 -0
  33. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/asNumber.test.js +13 -0
  34. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/basic.test.js +400 -0
  35. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/bigint.test.js +76 -0
  36. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/clean-cache.test.js +47 -0
  37. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/const.test.js +314 -0
  38. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/date.test.js +639 -0
  39. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/debug-mode.test.js +130 -0
  40. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/defaults.test.js +376 -0
  41. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/enum.test.js +37 -0
  42. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fix-604.test.js +25 -0
  43. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fixtures/.keep +0 -0
  44. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/if-then-else.test.js +540 -0
  45. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/inferType.test.js +92 -0
  46. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/infinity.test.js +55 -0
  47. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/integer.test.js +194 -0
  48. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/invalidSchema.test.js +38 -0
  49. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-479.test.js +57 -0
  50. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-793.test.js +107 -0
  51. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-794.test.js +177 -0
  52. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-836.test.js +183 -0
  53. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-add-comma.test.js +57 -0
  54. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/README.md +10 -0
  55. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4/required.json +54 -0
  56. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4.test.js +12 -0
  57. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6/required.json +70 -0
  58. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6.test.js +12 -0
  59. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7/required.json +70 -0
  60. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7.test.js +12 -0
  61. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/util.js +31 -0
  62. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/missing-values.test.js +88 -0
  63. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/multi-type-serializer.test.js +19 -0
  64. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nestedObjects.test.js +63 -0
  65. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nullable.test.js +543 -0
  66. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/oneof.test.js +510 -0
  67. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/patternProperties.test.js +168 -0
  68. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/recursion.test.js +245 -0
  69. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.json +12 -0
  70. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.test.js +2077 -0
  71. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/regex.test.js +32 -0
  72. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/required.test.js +204 -0
  73. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/requiresAjv.test.js +50 -0
  74. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize.test.js +141 -0
  75. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize2.test.js +18 -0
  76. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize3.test.js +17 -0
  77. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize4.test.js +16 -0
  78. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize5.test.js +16 -0
  79. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize6.test.js +22 -0
  80. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize7.test.js +68 -0
  81. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/side-effect.test.js +196 -0
  82. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/standalone-mode.test.js +219 -0
  83. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/string.test.js +84 -0
  84. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/surrogate.test.js +67 -0
  85. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/toJSON.test.js +203 -0
  86. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typebox.test.js +36 -0
  87. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typesArray.test.js +550 -0
  88. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/unknownFormats.test.js +27 -0
  89. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/webpack.test.js +50 -0
  90. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.d.ts +219 -0
  91. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.tst.ts +259 -0
  92. package/node_modules/@fastify/fast-json-stringify-compiler/package.json +6 -11
  93. package/node_modules/@fastify/fast-json-stringify-compiler/types/{index.test-d.ts → index.tst.ts} +34 -32
  94. package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts +5 -0
  95. package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts.map +1 -1
  96. package/node_modules/@posthog/core/dist/posthog-core-stateless.js +50 -10
  97. package/node_modules/@posthog/core/dist/posthog-core-stateless.mjs +47 -10
  98. package/node_modules/@posthog/core/dist/posthog-core.d.ts +2 -2
  99. package/node_modules/@posthog/core/dist/posthog-core.d.ts.map +1 -1
  100. package/node_modules/@posthog/core/dist/posthog-core.js +10 -6
  101. package/node_modules/@posthog/core/dist/posthog-core.mjs +11 -7
  102. package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.d.ts +1 -0
  103. package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.d.ts.map +1 -1
  104. package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.js +3 -0
  105. package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.mjs +3 -0
  106. package/node_modules/@posthog/core/dist/utils/promise-queue.d.ts +3 -0
  107. package/node_modules/@posthog/core/dist/utils/promise-queue.d.ts.map +1 -1
  108. package/node_modules/@posthog/core/dist/utils/promise-queue.js +15 -3
  109. package/node_modules/@posthog/core/dist/utils/promise-queue.mjs +15 -3
  110. package/node_modules/@posthog/core/package.json +1 -1
  111. package/node_modules/@posthog/core/src/posthog-core-stateless.ts +80 -14
  112. package/node_modules/@posthog/core/src/posthog-core.ts +18 -7
  113. package/node_modules/@posthog/core/src/testing/PostHogCoreTestClient.ts +4 -0
  114. package/node_modules/@posthog/core/src/utils/promise-queue.ts +17 -4
  115. package/node_modules/@posthog/types/dist/posthog.d.ts +12 -0
  116. package/node_modules/@posthog/types/dist/posthog.d.ts.map +1 -1
  117. package/node_modules/@posthog/types/package.json +1 -1
  118. package/node_modules/@posthog/types/src/posthog.ts +13 -0
  119. package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
  120. package/node_modules/@protobufjs/utf8/index.js +29 -18
  121. package/node_modules/@protobufjs/utf8/package.json +2 -2
  122. package/node_modules/@protobufjs/utf8/tests/index.js +5 -0
  123. package/node_modules/@types/node/README.md +1 -1
  124. package/node_modules/@types/node/buffer.d.ts +64 -25
  125. package/node_modules/@types/node/crypto.d.ts +18 -5
  126. package/node_modules/@types/node/diagnostics_channel.d.ts +237 -3
  127. package/node_modules/@types/node/dns.d.ts +1 -1
  128. package/node_modules/@types/node/ffi.d.ts +486 -0
  129. package/node_modules/@types/node/fs/promises.d.ts +3 -0
  130. package/node_modules/@types/node/fs.d.ts +21 -6
  131. package/node_modules/@types/node/http.d.ts +25 -0
  132. package/node_modules/@types/node/index.d.ts +1 -0
  133. package/node_modules/@types/node/package.json +2 -2
  134. package/node_modules/@types/node/process.d.ts +14 -1
  135. package/node_modules/@types/node/quic.d.ts +92 -11
  136. package/node_modules/@types/node/sqlite.d.ts +55 -0
  137. package/node_modules/@types/node/stream/iter.d.ts +150 -0
  138. package/node_modules/@types/node/stream.d.ts +32 -0
  139. package/node_modules/@types/node/test.d.ts +112 -2
  140. package/node_modules/@types/node/ts5.6/index.d.ts +1 -0
  141. package/node_modules/@types/node/ts5.7/index.d.ts +1 -0
  142. package/node_modules/@types/node/util.d.ts +19 -2
  143. package/node_modules/@types/node/v8.d.ts +84 -2
  144. package/node_modules/@types/node/worker_threads.d.ts +8 -7
  145. package/node_modules/@zuplo/core/package.json +1 -1
  146. package/node_modules/@zuplo/graphql/out/esm/index.js +11 -11
  147. package/node_modules/@zuplo/graphql/out/esm/index.js.map +1 -1
  148. package/node_modules/@zuplo/graphql/package.json +1 -1
  149. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  150. package/node_modules/@zuplo/otel/package.json +1 -1
  151. package/node_modules/@zuplo/runtime/out/esm/{chunk-54PA7VDV.js → chunk-4QJJMELB.js} +1 -1
  152. package/node_modules/@zuplo/runtime/out/esm/{chunk-54PA7VDV.js.map → chunk-4QJJMELB.js.map} +1 -1
  153. package/node_modules/@zuplo/runtime/out/esm/chunk-MJWTZPC2.js +402 -0
  154. package/node_modules/@zuplo/runtime/out/esm/chunk-MJWTZPC2.js.map +1 -0
  155. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  156. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  157. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +7 -7
  158. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
  159. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
  160. package/node_modules/@zuplo/runtime/out/types/index.d.ts +263 -19
  161. package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +33 -7
  162. package/node_modules/@zuplo/runtime/package.json +1 -1
  163. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -1
  164. package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
  165. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -1
  166. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
  167. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +1 -1
  168. package/node_modules/hono/dist/cjs/utils/body.js +12 -4
  169. package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
  170. package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
  171. package/node_modules/hono/dist/middleware/serve-static/index.js +1 -1
  172. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
  173. package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
  174. package/node_modules/hono/dist/utils/body.js +12 -4
  175. package/node_modules/hono/dist/utils/buffer.js +2 -1
  176. package/node_modules/hono/dist/validator/validator.js +3 -3
  177. package/node_modules/hono/package.json +8 -7
  178. package/node_modules/iconv-lite/encodings/sbcs-data.js +2 -0
  179. package/node_modules/iconv-lite/encodings/utf32.js +10 -3
  180. package/node_modules/iconv-lite/package.json +2 -2
  181. package/node_modules/iconv-lite/types/encodings.d.ts +2 -0
  182. package/node_modules/protobufjs/dist/light/protobuf.js +2 -2
  183. package/node_modules/protobufjs/dist/light/protobuf.min.js +2 -2
  184. package/node_modules/protobufjs/dist/minimal/protobuf.js +2 -2
  185. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +2 -2
  186. package/node_modules/protobufjs/dist/protobuf.js +5 -2
  187. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  188. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  189. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  190. package/node_modules/protobufjs/package.json +1 -1
  191. package/node_modules/protobufjs/src/parse.js +3 -0
  192. package/node_modules/toad-cache/README.md +10 -9
  193. package/node_modules/toad-cache/dist/toad-cache.cjs +139 -139
  194. package/node_modules/toad-cache/dist/toad-cache.mjs +136 -140
  195. package/node_modules/toad-cache/package.json +8 -8
  196. package/node_modules/toad-cache/toad-cache.d.cts +20 -14
  197. package/node_modules/toad-cache/toad-cache.d.ts +18 -14
  198. package/package.json +6 -6
  199. package/node_modules/@fastify/fast-json-stringify-compiler/.eslintrc +0 -1
  200. package/node_modules/@zuplo/runtime/out/esm/chunk-36XLJ4X6.js +0 -389
  201. package/node_modules/@zuplo/runtime/out/esm/chunk-36XLJ4X6.js.map +0 -1
  202. package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
  203. /package/node_modules/@zuplo/runtime/out/esm/{chunk-36XLJ4X6.js.LEGAL.txt → chunk-MJWTZPC2.js.LEGAL.txt} +0 -0
@@ -0,0 +1,116 @@
1
+ 'use strict'
2
+
3
+ const { spawn } = require('child_process')
4
+
5
+ const cliSelect = require('cli-select')
6
+ const simpleGit = require('simple-git')
7
+
8
+ const git = simpleGit(process.cwd())
9
+
10
+ const COMMAND = 'npm run bench'
11
+ const DEFAULT_BRANCH = 'main'
12
+ const PERCENT_THRESHOLD = 5
13
+ const greyColor = '\x1b[30m'
14
+ const redColor = '\x1b[31m'
15
+ const greenColor = '\x1b[32m'
16
+ const resetColor = '\x1b[0m'
17
+
18
+ async function selectBranchName (message, branches) {
19
+ console.log(message)
20
+ const result = await cliSelect({
21
+ type: 'list',
22
+ name: 'branch',
23
+ values: branches
24
+ })
25
+ console.log(result.value)
26
+ return result.value
27
+ }
28
+
29
+ async function executeCommandOnBranch (command, branch) {
30
+ console.log(`${greyColor}Checking out "${branch}"${resetColor}`)
31
+ await git.checkout(branch)
32
+
33
+ console.log(`${greyColor}Execute "${command}"${resetColor}`)
34
+ const childProcess = spawn(command, { stdio: 'pipe', shell: true })
35
+
36
+ let result = ''
37
+ childProcess.stdout.on('data', (data) => {
38
+ process.stdout.write(data.toString())
39
+ result += data.toString()
40
+ })
41
+
42
+ await new Promise(resolve => childProcess.on('close', resolve))
43
+
44
+ console.log()
45
+
46
+ return parseBenchmarksStdout(result)
47
+ }
48
+
49
+ function parseBenchmarksStdout (text) {
50
+ const results = []
51
+
52
+ const lines = text.split('\n')
53
+ for (const line of lines) {
54
+ const match = /^(.+?)(\.*) x (.+) ops\/sec .*$/.exec(line)
55
+ if (match !== null) {
56
+ results.push({
57
+ name: match[1],
58
+ alignedName: match[1] + match[2],
59
+ result: parseInt(match[3].split(',').join(''))
60
+ })
61
+ }
62
+ }
63
+
64
+ return results
65
+ }
66
+
67
+ function compareResults (featureBranch, mainBranch) {
68
+ for (const { name, alignedName, result: mainBranchResult } of mainBranch) {
69
+ const featureBranchBenchmark = featureBranch.find(result => result.name === name)
70
+ if (featureBranchBenchmark) {
71
+ const featureBranchResult = featureBranchBenchmark.result
72
+ const percent = (featureBranchResult - mainBranchResult) * 100 / mainBranchResult
73
+ const roundedPercent = Math.round(percent * 100) / 100
74
+
75
+ const percentString = roundedPercent > 0 ? `+${roundedPercent}%` : `${roundedPercent}%`
76
+ const message = alignedName + percentString.padStart(7, '.')
77
+
78
+ if (roundedPercent > PERCENT_THRESHOLD) {
79
+ console.log(`${greenColor}${message}${resetColor}`)
80
+ } else if (roundedPercent < -PERCENT_THRESHOLD) {
81
+ console.log(`${redColor}${message}${resetColor}`)
82
+ } else {
83
+ console.log(message)
84
+ }
85
+ }
86
+ }
87
+ }
88
+
89
+ (async function () {
90
+ const branches = await git.branch()
91
+ const currentBranch = branches.branches[branches.current]
92
+
93
+ let featureBranch = null
94
+ let mainBranch = null
95
+
96
+ if (process.argv[2] === '--ci') {
97
+ featureBranch = currentBranch.name
98
+ mainBranch = DEFAULT_BRANCH
99
+ } else {
100
+ featureBranch = await selectBranchName('Select the branch you want to compare (feature branch):', branches.all)
101
+ mainBranch = await selectBranchName('Select the branch you want to compare with (main branch):', branches.all)
102
+ }
103
+
104
+ try {
105
+ const featureBranchResult = await executeCommandOnBranch(COMMAND, featureBranch)
106
+ const mainBranchResult = await executeCommandOnBranch(COMMAND, mainBranch)
107
+ compareResults(featureBranchResult, mainBranchResult)
108
+ } catch (error) {
109
+ console.error('Switch to origin branch due to an error', error.message)
110
+ }
111
+
112
+ await git.checkout(currentBranch.commit)
113
+ await git.checkout(currentBranch.name)
114
+
115
+ console.log(`${greyColor}Back to ${currentBranch.name} ${currentBranch.commit}${resetColor}`)
116
+ })()
@@ -0,0 +1,339 @@
1
+ 'use strict'
2
+
3
+ const { Bench } = require('tinybench')
4
+ const suite = new Bench({
5
+ name: 'Library Comparison Benchmarks',
6
+ setup: (_task, mode) => {
7
+ // Run the garbage collector before warmup at each cycle
8
+ if (mode === 'warmup' && typeof globalThis.gc === 'function') {
9
+ globalThis.gc()
10
+ }
11
+ }
12
+ })
13
+
14
+ const STR_LEN = 1e4
15
+ const LARGE_ARRAY_SIZE = 2e4
16
+ const MULTI_ARRAY_LENGTH = 1e3
17
+
18
+ const schema = {
19
+ title: 'Example Schema',
20
+ type: 'object',
21
+ properties: {
22
+ firstName: {
23
+ type: 'string'
24
+ },
25
+ lastName: {
26
+ type: ['string', 'null']
27
+ },
28
+ age: {
29
+ description: 'Age in years',
30
+ type: 'integer',
31
+ minimum: 0
32
+ }
33
+ }
34
+ }
35
+ const schemaCJS = {
36
+ title: 'Example Schema',
37
+ type: 'object',
38
+ properties: {
39
+ firstName: {
40
+ type: 'string'
41
+ },
42
+ lastName: {
43
+ type: ['string', 'null']
44
+ },
45
+ age: {
46
+ description: 'Age in years',
47
+ type: 'number',
48
+ minimum: 0
49
+ }
50
+ }
51
+ }
52
+
53
+ const schemaAJVJTD = {
54
+ properties: {
55
+ firstName: {
56
+ type: 'string'
57
+ },
58
+ lastName: {
59
+ type: 'string',
60
+ nullable: true
61
+ },
62
+ age: {
63
+ type: 'uint8'
64
+ }
65
+ }
66
+ }
67
+
68
+ const arraySchema = {
69
+ title: 'array schema',
70
+ type: 'array',
71
+ items: schema
72
+ }
73
+
74
+ const arraySchemaCJS = {
75
+ title: 'array schema',
76
+ type: 'array',
77
+ items: schemaCJS
78
+ }
79
+
80
+ const arraySchemaAJVJTD = {
81
+ elements: schemaAJVJTD
82
+ }
83
+
84
+ const dateFormatSchema = {
85
+ description: 'Date of birth',
86
+ type: 'string',
87
+ format: 'datetime'
88
+ }
89
+
90
+ const dateFormatSchemaCJS = {
91
+ description: 'Date of birth',
92
+ type: 'string',
93
+ format: 'datetime'
94
+ }
95
+
96
+ const obj = {
97
+ firstName: 'Matteo',
98
+ lastName: 'Collina',
99
+ age: 32
100
+ }
101
+
102
+ const date = new Date()
103
+
104
+ const multiArray = new Array(MULTI_ARRAY_LENGTH)
105
+ const largeArray = new Array(LARGE_ARRAY_SIZE)
106
+
107
+ const CJS = require('compile-json-stringify')
108
+ const CJSStringify = CJS(schemaCJS)
109
+ const CJSStringifyArray = CJS(arraySchemaCJS)
110
+ const CJSStringifyDate = CJS(dateFormatSchemaCJS)
111
+ const CJSStringifyString = CJS({ type: 'string' })
112
+
113
+ const FJS = require('..')
114
+ const stringify = FJS(schema)
115
+ const stringifyArrayDefault = FJS(arraySchema)
116
+ const stringifyArrayJSONStringify = FJS(arraySchema, {
117
+ largeArrayMechanism: 'json-stringify'
118
+ })
119
+ const stringifyDate = FJS(dateFormatSchema)
120
+ const stringifyString = FJS({ type: 'string' })
121
+ let str = ''
122
+
123
+ const Ajv = require('ajv/dist/jtd')
124
+ const ajv = new Ajv()
125
+ const ajvSerialize = ajv.compileSerializer(schemaAJVJTD)
126
+ const ajvSerializeArray = ajv.compileSerializer(arraySchemaAJVJTD)
127
+ const ajvSerializeString = ajv.compileSerializer({ type: 'string' })
128
+
129
+ const { createAccelerator } = require('json-accelerator')
130
+ const accelStringify = createAccelerator(schema)
131
+ const accelArray = createAccelerator(arraySchema)
132
+ const accelDate = FJS(dateFormatSchema)
133
+ const accelString = FJS({ type: 'string' })
134
+
135
+ const getRandomString = (length) => {
136
+ if (!Number.isInteger(length)) {
137
+ throw new Error('Expected integer length')
138
+ }
139
+
140
+ const validCharacters = 'abcdefghijklmnopqrstuvwxyz'
141
+ const nValidCharacters = 26
142
+
143
+ let result = ''
144
+ for (let i = 0; i < length; ++i) {
145
+ result += validCharacters[Math.floor(Math.random() * nValidCharacters)]
146
+ }
147
+
148
+ return result[0].toUpperCase() + result.slice(1)
149
+ }
150
+
151
+ for (let i = 0; i < STR_LEN; i++) {
152
+ largeArray[i] = {
153
+ firstName: getRandomString(8),
154
+ lastName: getRandomString(6),
155
+ age: Math.ceil(Math.random() * 99)
156
+ }
157
+
158
+ str += i
159
+ if (i % 100 === 0) {
160
+ str += '"'
161
+ }
162
+ }
163
+
164
+ for (let i = STR_LEN; i < LARGE_ARRAY_SIZE; ++i) {
165
+ largeArray[i] = {
166
+ firstName: getRandomString(10),
167
+ lastName: getRandomString(4),
168
+ age: Math.ceil(Math.random() * 99)
169
+ }
170
+ }
171
+
172
+ for (let i = 0; i < MULTI_ARRAY_LENGTH; i++) {
173
+ multiArray[i] = obj
174
+ }
175
+
176
+ suite.add('fast-json-stringify: creation', function () {
177
+ FJS(schema)
178
+ })
179
+ suite.add('compile-json-stringify: creation', function () {
180
+ CJS(schemaCJS)
181
+ })
182
+ suite.add('AJV: creation', function () {
183
+ ajv.compileSerializer(schemaAJVJTD)
184
+ })
185
+ suite.add('json-accelerator: creation', function () {
186
+ createAccelerator(schema)
187
+ })
188
+
189
+ suite.add('JSON.stringify: array', function () {
190
+ JSON.stringify(multiArray)
191
+ })
192
+
193
+ suite.add('fast-json-stringify [default]: array', function () {
194
+ stringifyArrayDefault(multiArray)
195
+ })
196
+
197
+ suite.add('json-accelerator: array', function () {
198
+ accelArray(multiArray)
199
+ })
200
+
201
+ suite.add('fast-json-stringify [json-stringify]: array', function () {
202
+ stringifyArrayJSONStringify(multiArray)
203
+ })
204
+
205
+ suite.add('compile-json-stringify: array', function () {
206
+ CJSStringifyArray(multiArray)
207
+ })
208
+
209
+ suite.add('AJV: array', function () {
210
+ ajvSerializeArray(multiArray)
211
+ })
212
+
213
+ suite.add('JSON.stringify: large array', function () {
214
+ JSON.stringify(largeArray)
215
+ })
216
+
217
+ suite.add('fast-json-stringify [default]: large array', function () {
218
+ stringifyArrayDefault(largeArray)
219
+ })
220
+
221
+ suite.add('fast-json-stringify [json-stringify]: large array', function () {
222
+ stringifyArrayJSONStringify(largeArray)
223
+ })
224
+
225
+ suite.add('compile-json-stringify: large array', function () {
226
+ CJSStringifyArray(largeArray)
227
+ })
228
+
229
+ suite.add('AJV: large array', function () {
230
+ ajvSerializeArray(largeArray)
231
+ })
232
+
233
+ suite.add('JSON.stringify: long string', function () {
234
+ JSON.stringify(str)
235
+ })
236
+
237
+ suite.add('fast-json-stringify: long string', function () {
238
+ stringifyString(str)
239
+ })
240
+
241
+ suite.add('json-accelerator: long string', function () {
242
+ stringifyString(str)
243
+ })
244
+
245
+ suite.add('compile-json-stringify: long string', function () {
246
+ CJSStringifyString(str)
247
+ })
248
+
249
+ suite.add('AJV: long string', function () {
250
+ ajvSerializeString(str)
251
+ })
252
+
253
+ suite.add('JSON.stringify: short string', function () {
254
+ JSON.stringify('hello world')
255
+ })
256
+
257
+ suite.add('fast-json-stringify: short string', function () {
258
+ stringifyString('hello world')
259
+ })
260
+
261
+ suite.add('json-accelerator: short string', function () {
262
+ accelString('hello world')
263
+ })
264
+
265
+ suite.add('compile-json-stringify: short string', function () {
266
+ CJSStringifyString('hello world')
267
+ })
268
+
269
+ suite.add('AJV: short string', function () {
270
+ ajvSerializeString('hello world')
271
+ })
272
+
273
+ suite.add('JSON.stringify: obj', function () {
274
+ JSON.stringify(obj)
275
+ })
276
+
277
+ suite.add('fast-json-stringify: obj', function () {
278
+ stringify(obj)
279
+ })
280
+
281
+ suite.add('json-accelerator: obj', function () {
282
+ accelStringify(obj)
283
+ })
284
+
285
+ suite.add('compile-json-stringify: obj', function () {
286
+ CJSStringify(obj)
287
+ })
288
+
289
+ suite.add('AJV: obj', function () {
290
+ ajvSerialize(obj)
291
+ })
292
+
293
+ suite.add('JSON.stringify: date', function () {
294
+ JSON.stringify(date)
295
+ })
296
+
297
+ suite.add('fast-json-stringify: date', function () {
298
+ stringifyDate(date)
299
+ })
300
+
301
+ suite.add('json-accelerate: date', function () {
302
+ accelDate(date)
303
+ })
304
+
305
+ suite.add('compile-json-stringify: date', function () {
306
+ CJSStringifyDate(date)
307
+ })
308
+
309
+ suite.run().then(() => {
310
+ const results = suite.tasks.map(task => ({
311
+ name: task.name,
312
+ hz: task.result.throughput.mean,
313
+ rme: task.result.latency.rme,
314
+ samples: task.result.latency.df + 1
315
+ }))
316
+
317
+ const scenarios = {}
318
+ for (const result of results) {
319
+ const [library, scenario] = result.name.split(':').map(s => s.trim())
320
+
321
+ if (!scenarios[scenario]) scenarios[scenario] = []
322
+ scenarios[scenario].push({ ...result, library })
323
+ }
324
+
325
+ for (const [scenario, tasks] of Object.entries(scenarios)) {
326
+ console.log(`\n--- ${scenario} ---`)
327
+ const sorted = tasks.sort((a, b) => b.hz - a.hz)
328
+ const winner = sorted[0]
329
+
330
+ for (const task of sorted) {
331
+ const formattedHz = task.hz.toLocaleString('en-US', { maximumFractionDigits: 0 })
332
+ const formattedRme = task.rme.toFixed(2)
333
+ const isWinner = task === winner
334
+ const prefix = isWinner ? '🏆 ' : ' '
335
+
336
+ console.log(`${prefix}${task.library.padEnd(40)} x ${formattedHz.padStart(15)} ops/sec ±${formattedRme}% (${task.samples} runs sampled)`)
337
+ }
338
+ }
339
+ }).catch(err => console.error(`Error: ${err.message}`))
@@ -0,0 +1,33 @@
1
+ 'use strict'
2
+
3
+ const { workerData: benchmark, parentPort } = require('worker_threads')
4
+
5
+ const { Bench } = require('tinybench')
6
+
7
+ const bench = new Bench({
8
+ name: benchmark.name,
9
+ setup: (_task, mode) => {
10
+ // Run the garbage collector before warmup at each cycle
11
+ if (mode === 'warmup' && typeof globalThis.gc === 'function') {
12
+ globalThis.gc()
13
+ }
14
+ }
15
+ })
16
+
17
+ const FJS = require('..')
18
+ const stringify = FJS(benchmark.schema)
19
+
20
+ bench.add(benchmark.name, () => {
21
+ stringify(benchmark.input)
22
+ }).run().then(() => {
23
+ const task = bench.tasks[0]
24
+ const hz = task.result.throughput.mean // ops/sec
25
+ const rme = task.result.latency.rme // relative margin of error (%)
26
+ const samples = task.result.latency.df + 1 // degrees of freedom + 1 = sample count
27
+
28
+ const formattedHz = hz.toLocaleString('en-US', { maximumFractionDigits: 0 })
29
+ const formattedRme = rme.toFixed(2)
30
+
31
+ const output = `${task.name} x ${formattedHz} ops/sec ±${formattedRme}% (${samples} runs sampled)`
32
+ parentPort.postMessage(output)
33
+ }).catch(err => parentPort.postMessage(`Error: ${err.message}`))