From 66cd966605dd38833011770d5cc77a78f5aa2010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ro=C5=BCek?= Date: Tue, 30 Jan 2024 22:19:48 +0100 Subject: [PATCH] chore: tweak benchmark suite --- benchmarks/benchmark-template.mjs | 97 ---------- benchmarks/benchmark.mjs | 169 ++++++++++++++++++ benchmarks/fixtures/address-large.json | 55 ------ benchmarks/fixtures/goessner-huge.json | 66 ------- benchmarks/scenarios.mjs | 58 ++++-- benchmarks/scripts/compile-nimma.mjs | 75 +++++--- benchmarks/scripts/generate-fixtures.sh | 4 +- .../scripts/generate-schema-fixtures.mjs | 42 ++--- benchmarks/scripts/hook.mjs | 11 ++ benchmarks/scripts/rollup.config.mjs | 75 -------- benchmarks/scripts/run-benchmark.sh | 4 + .../scripts/utils/expression-to-file-path.mjs | 5 - package-lock.json | 159 ++++------------ package.json | 6 +- scripts/copy-types.mjs | 12 -- 15 files changed, 328 insertions(+), 510 deletions(-) delete mode 100644 benchmarks/benchmark-template.mjs create mode 100644 benchmarks/benchmark.mjs delete mode 100644 benchmarks/fixtures/address-large.json delete mode 100644 benchmarks/fixtures/goessner-huge.json create mode 100644 benchmarks/scripts/hook.mjs delete mode 100644 benchmarks/scripts/rollup.config.mjs create mode 100755 benchmarks/scripts/run-benchmark.sh delete mode 100644 benchmarks/scripts/utils/expression-to-file-path.mjs delete mode 100644 scripts/copy-types.mjs diff --git a/benchmarks/benchmark-template.mjs b/benchmarks/benchmark-template.mjs deleted file mode 100644 index e8d0528..0000000 --- a/benchmarks/benchmark-template.mjs +++ /dev/null @@ -1,97 +0,0 @@ -/* eslint-disable no-undef */ -/* global DOCUMENT, JSON_PATHS precompiledNimma */ -import Benchmark from 'benchmark'; -import jp from 'jsonpath'; -import * as JSONPath from 'jsonpath-plus'; -import * as process from 'node:process'; - -import Nimma from '../dist/esm/index.mjs'; - -let results = []; -const callbacksWithResults = Object.fromEntries( - JSON_PATHS.map(p => [ - p, - r => { - results.push(r.value); - }, - ]), -); - -const suite = new Benchmark.Suite(); - -suite.add('Nimma (cold)', function () { - const n = new Nimma(JSON_PATHS); - n.query(DOCUMENT, callbacksWithResults); -}); - -suite.add('Nimma (hot)', function () { - precompiledNimma(DOCUMENT, callbacksWithResults); -}); - -suite.add( - 'JSONPath-Plus (resultType=value)', - JSON_PATHS.length > 1 - ? function () { - for (const path of JSON_PATHS) { - JSONPath.JSONPath({ - json: DOCUMENT, - path, - resultType: 'value', - }); - } - } - : function () { - JSONPath.JSONPath({ - json: DOCUMENT, - path: JSON_PATHS[0], - resultType: 'value', - }); - }, -); - -suite.add( - 'JSONPath-Plus (resultType=all)', - JSON_PATHS.length > 1 - ? function () { - for (const path of JSON_PATHS) { - JSONPath.JSONPath({ - json: DOCUMENT, - path, - resultType: 'all', - }); - } - } - : function () { - JSONPath.JSONPath({ - json: DOCUMENT, - path: JSON_PATHS[0], - resultType: 'all', - }); - }, -); - -suite.add( - 'JSONPath', - JSON_PATHS.length > 1 - ? function () { - for (const path of JSON_PATHS) { - jp.query(DOCUMENT, path); - } - } - : function () { - jp.query(DOCUMENT, JSON_PATHS[0]); - }, -); - -suite.on('cycle', function (event) { - process.stdout.write(String(event.target)); - process.stdout.write('\n'); - results = []; -}); -suite.on('error', function (event) { - process.stderr.write(event.target.error.message); -}); -suite.on('complete', function () { - process.stdout.write('Fastest is ' + this.filter('fastest').map('name')); -}); -suite.run(); diff --git a/benchmarks/benchmark.mjs b/benchmarks/benchmark.mjs new file mode 100644 index 0000000..cf27055 --- /dev/null +++ b/benchmarks/benchmark.mjs @@ -0,0 +1,169 @@ +import * as assert from 'node:assert/strict'; +import * as fs from 'node:fs/promises'; +import * as path from 'node:path'; +import * as process from 'node:process'; +import { fileURLToPath } from 'node:url'; +import { parseArgs } from 'node:util'; + +import Benchmark from 'benchmark'; +import yaml from 'js-yaml'; +import jp from 'jsonpath'; +import * as JSONPath from 'jsonpath-plus'; + +import scenarios from './scenarios.mjs'; + +const options = { + scenario: { + type: 'string', + }, + document: { + type: 'string', + }, +}; + +const { values } = parseArgs({ options }); + +const scenario = scenarios.find(({ name }) => name === values.scenario); + +assert.ok(scenario); + +const { expressions } = scenario; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +const document = await loadDocument(scenario, values.document); + +let results = []; +const callbacksWithResults = Object.fromEntries( + expressions.map(p => [ + p, + r => { + results.push(r.value); + }, + ]), +); + +const suite = new Benchmark.Suite(); + +for (const [version, { cold, hot }] of Object.entries( + await loadNimma(scenario), +)) { + suite.add(`Nimma@${version} (cold)`, function () { + cold(expressions, document, callbacksWithResults); + }); + + suite.add(`Nimma@${version} (hot)`, function () { + hot(document, callbacksWithResults); + }); +} + +suite.add( + 'JSONPath-Plus (resultType=value)', + expressions.length > 1 + ? function () { + for (const path of expressions) { + JSONPath.JSONPath({ + json: document, + path, + resultType: 'value', + }); + } + } + : function () { + JSONPath.JSONPath({ + json: document, + path: expressions[0], + resultType: 'value', + }); + }, +); + +suite.add( + 'JSONPath-Plus (resultType=all)', + expressions.length > 1 + ? function () { + for (const path of expressions) { + JSONPath.JSONPath({ + json: document, + path, + resultType: 'all', + }); + } + } + : function () { + JSONPath.JSONPath({ + json: document, + path: expressions[0], + resultType: 'all', + }); + }, +); + +suite.add( + 'JSONPath', + expressions.length > 1 + ? function () { + for (const path of expressions) { + jp.query(document, path); + } + } + : function () { + jp.query(document, expressions[0]); + }, +); + +suite.on('cycle', function (event) { + process.stdout.write(String(event.target)); + process.stdout.write('\n'); + results = []; +}); +suite.on('error', function (event) { + process.stderr.write(event.target.error.message); +}); +suite.on('complete', function () { + process.stdout.write('Fastest is ' + this.filter('fastest').map('name')); +}); +suite.run(); + +async function loadNimma(scenario) { + const dirname = path.join(__dirname, `.gen/nimma/${scenario.name}`); + const files = await fs.readdir(dirname); + const versionRegex = /local|\d+\.\d+\.\d+/; + + const instances = {}; + for (const file of files) { + const [version] = file.match(versionRegex); + instances[version] ??= {}; + if (file.includes('cold')) { + instances[version].cold = ( + await import(path.join(dirname, file)) + ).default; + } else { + instances[version].hot = (await import(path.join(dirname, file))).default; + } + } + + return instances; +} + +async function loadDocument(scenario, document) { + if (document === '') { + assert.ok(scenario.defaultDocument); + return JSON.parse( + await fs.readFile( + path.join( + __dirname, + `.gen/documents/${path.basename(scenario.defaultDocument)}`, + ), + 'utf8', + ), + ); + } + + if (document.startsWith('https://')) { + return yaml.load(await (await fetch(document)).text()); + } + + return yaml.load( + await fs.readFile(path.join(process.cwd(), document), 'utf8'), + ); +} diff --git a/benchmarks/fixtures/address-large.json b/benchmarks/fixtures/address-large.json deleted file mode 100644 index 4c999e2..0000000 --- a/benchmarks/fixtures/address-large.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "type": "array", - "items": { - "type": "object", - "minProperties": 15000, - "maxProperties": 15000, - "additionalProperties": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "locations": { - "type": "array", - "items": { - "$ref": "#/$defs/Address" - } - } - }, - "required": ["locations"] - } - }, - "$defs": { - "Address": { - "type": "object", - "additionalProperties": false, - "properties": { - "country": { - "type": "string" - }, - "city": { - "type": "string" - }, - "postal-code": { - "type": "string" - }, - "street": { - "type": "object", - "properties": { - "line-1": { - "type": "string" - }, - "line-2": { - "type": "string" - }, - "number": { - "type": "string" - } - } - } - }, - "required": ["country", "city"] - } - } -} diff --git a/benchmarks/fixtures/goessner-huge.json b/benchmarks/fixtures/goessner-huge.json deleted file mode 100644 index 527c771..0000000 --- a/benchmarks/fixtures/goessner-huge.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "type": "object", - "required": ["store"], - "additionalProperties": false, - "properties": { - "store": { - "type": "object", - "required": ["book", "bicycle"], - "additionalProperties": false, - "properties": { - "book": { - "type": "array", - "minItems": 2000000, - "maxItems": 2100000, - "items": { - "type": "object", - "additionalProperties": false, - "required": ["price", "author", "title", "price"], - "properties": { - "category": { - "type": "string" - }, - "author": { - "type": "string" - }, - "title": { - "type": "string" - }, - "isbn": { - "type": "string" - }, - "price": { - "type": "number", - "minimum": 0, - "maximum": 1000 - } - } - } - }, - "bicycle": { - "type": "object", - "required": ["color", "price"], - "additionalProperties": false, - "properties": { - "color": { - "enum": [ - "red", - "yellow", - "green", - "orange", - "blue", - "purple", - "pink", - "grey" - ] - }, - "price": { - "type": "number", - "minimum": 0 - } - } - } - } - } - } -} diff --git a/benchmarks/scenarios.mjs b/benchmarks/scenarios.mjs index 4a62e24..99eb0be 100644 --- a/benchmarks/scenarios.mjs +++ b/benchmarks/scenarios.mjs @@ -1,5 +1,6 @@ export default [ { + defaultDocument: './fixtures/address.json', expressions: [ '$..street', '$..[street,city,country]', @@ -7,19 +8,10 @@ export default [ '$..address.street[?(@.number > 20)]', '$.address.street', ], - filepath: './fixtures/address.json', - }, - { - expressions: [ - '$..street', - '$..[street,city,country]', - '$..[?(@property === "street")]', - '$..address.street[?(@.number > 20)]', - '$.address.street', - ], - filepath: './fixtures/address-large.json', + name: 'address', }, { + defaultDocument: './fixtures/goessner.json', expressions: [ '$.store.book[*].author', '$..author', @@ -33,9 +25,10 @@ export default [ '$..book[?(@.isbn)]', '$..book[?(@.price<10)]', ], - filepath: './fixtures/goessner.json', + name: 'goessner', }, { + defaultDocument: './fixtures/goessner.json', expressions: [ '$.store.book[*].author', '$..author', @@ -53,7 +46,46 @@ export default [ '$..book[?(@.price>100)]', '$..book[?(@.price && @.price.toString() === "10.20")]', ], - filepath: './fixtures/goessner.json', name: 'goessner-extended', }, + { + expressions: [ + '$.paths[*][get,put,post,delete,options,head,patch,trace]', + '$.paths', + '$.paths[*][get,put,post,delete,options,head,patch,trace].parameters', + '$', + '$.info.contact', + "$..[?(@property !== 'properties' && @ && @.enum)]", + '$..[description,title]', + '$.tags', + '$.tags[*]', + '$..[?(@ && @.enum && @.type)]', + '$.components.examples[*]', + '$.paths[*][*]..content[*].examples[*]', + '$.paths[*][*]..parameters[*].examples[*]', + '$.components.parameters[*].examples[*]', + '$.paths[*][*]..headers[*].examples[*]', + '$.components.headers[*].examples[*]', + '$.security[*]', + '$.paths[*][get,put,post,delete,options,head,patch,trace].security[*]', + '$.paths[*].parameters[?(@ && @.in)]', + '$.paths[*][get,put,post,delete,options,head,patch,trace].parameters[?(@ && @.in)]', + '$.components.parameters[?(@ && @.in)]', + '$.servers[*].url', + '$..content..[?(@ && @.schema && (@.example !== void 0 || @.examples))]', + '$..headers..[?(@ && @.schema && (@.example !== void 0 || @.examples))]', + '$..parameters..[?(@ && @.schema && (@.example !== void 0 || @.examples))]', + "$.components.schemas..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]", + "$..content..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]", + "$..headers..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]", + "$..parameters..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]", + '$.servers[*]', + '$.paths[*].servers[*]', + '$.paths[*][get,put,post,delete,options,head,patch,trace].servers[*]', + '$.components.links[*].server', + '$.paths[*][get,put,post,delete,options,head,patch,trace].responses[*].links[*].server', + '$.components.responses[*].links[*].server', + ], + name: 'spectral-oas3', + }, ]; diff --git a/benchmarks/scripts/compile-nimma.mjs b/benchmarks/scripts/compile-nimma.mjs index f8631f9..4b516e9 100644 --- a/benchmarks/scripts/compile-nimma.mjs +++ b/benchmarks/scripts/compile-nimma.mjs @@ -2,37 +2,58 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import { fileURLToPath } from 'node:url'; -import Nimma from '../../dist/esm/index.mjs'; import scenarios from '../scenarios.mjs'; -import expressionToFilePath from './utils/expression-to-file-path.mjs'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const dist = path.join(__dirname, '../.gen/nimma'); -function printCode(code) { - return code.replace(/nimma\/([a-z]+)/, '../../../../dist/esm/$1/index.mjs'); +function printCode(code, base) { + return code.replace(/nimma\/([a-z]+)/, base); } -for (const { expressions, filepath } of scenarios) { - const { sourceCode } = new Nimma(expressions); - - const actualDist = path.join( - dist, - path.basename(filepath, path.extname(filepath)), - ); - - await fs.promises.mkdir(actualDist, { recursive: true }); - - await fs.promises.writeFile( - path.join(actualDist, `${expressionToFilePath(expressions.join('-'))}.mjs`), - printCode(sourceCode), - ); - - for (const expression of expressions) { - const { sourceCode } = new Nimma([expression]); - await fs.promises.writeFile( - path.join(actualDist, `${expressionToFilePath(expression)}.mjs`), - printCode(sourceCode), - ); - } -} +await Promise.all( + [ + ['local', '../../src/index.mjs', '../../../../src/runtime/index.mjs'], + [ + '0.4.0', + 'https://unpkg.com/nimma@0.4.0/src/index.mjs', + 'https://unpkg.com/nimma@0.4.0/src/runtime/index.mjs', + ], + [ + '0.3.1', + 'https://unpkg.com/nimma@0.3.1/dist/esm/index.mjs', + 'https://unpkg.com/nimma@0.3.1/dist/esm/runtime/index.mjs', + ], + [ + '0.2.2', + 'https://unpkg.com/nimma@0.2.2/dist/esm/index.mjs', + 'https://unpkg.com/nimma@0.2.2/dist/esm/runtime/index.mjs', + ], + ].map(async ([version, mod, runtimeMod]) => { + const { default: Nimma } = await import(mod); + + for (const { expressions, name } of scenarios) { + const { sourceCode } = new Nimma(expressions); + + const actualDist = path.join(dist, name); + + await fs.promises.mkdir(actualDist, { recursive: true }); + + await fs.promises.writeFile( + path.join(actualDist, `nimma-${version}.mjs`), + printCode(sourceCode, runtimeMod), + ); + + await fs.promises.writeFile( + path.join(actualDist, `nimma-cold-${version}.mjs`), + `import Nimma from '${ + version === 'local' ? '../../../../src/index.mjs' : mod + }'; +export default (expressions, input, callbacks) => { + const nimma = new Nimma(expressions); + nimma.query(input, callbacks); +};`, + ); + } + }), +); diff --git a/benchmarks/scripts/generate-fixtures.sh b/benchmarks/scripts/generate-fixtures.sh index 72c32c7..fa4845c 100755 --- a/benchmarks/scripts/generate-fixtures.sh +++ b/benchmarks/scripts/generate-fixtures.sh @@ -1,8 +1,6 @@ #!/usr/bin/env sh cd $(dirname $0) mkdir -p ../.gen -export NODE_ENV=production -npx rollup -c ./rollup.config.mjs node ./generate-schema-fixtures.mjs -node ./compile-nimma.mjs +node --no-warnings --experimental-network-imports --import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register(pathToFileURL("./hook.mjs"));' ./compile-nimma.mjs diff --git a/benchmarks/scripts/generate-schema-fixtures.mjs b/benchmarks/scripts/generate-schema-fixtures.mjs index 67cba57..c1d33b6 100644 --- a/benchmarks/scripts/generate-schema-fixtures.mjs +++ b/benchmarks/scripts/generate-schema-fixtures.mjs @@ -1,46 +1,26 @@ -import fg from 'fast-glob'; -import fileEntryCache from 'file-entry-cache'; -import jsf from 'json-schema-faker'; -import * as fs from 'node:fs'; +import * as fs from 'node:fs/promises'; import * as path from 'node:path'; import { fileURLToPath } from 'node:url'; -const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const cwd = path.join(__dirname, '../fixtures'); - -const entries = await fg(['*.json'], { absolute: true, cwd }); +import { JSONSchemaFaker } from 'json-schema-faker'; -const cache = fileEntryCache.createFromFile( - path.join(__dirname, '../.gen/.fixtures-cache'), +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const entries = (await fs.readdir(path.join(__dirname, '../fixtures'))).map( + entry => path.join(__dirname, '../fixtures', entry), ); -const changedEntries = cache.getUpdatedFiles(entries); -for (const entry of entries.filter(entry => !changedEntries.includes(entry))) { - try { - await fs.promises.access(getDist(entry), fs.constants.F_OK); - } catch (e) { - if (e.code === 'ENOENT') { - changedEntries.push(entry); - } else { - throw e; - } - } -} - -for (const entry of changedEntries) { - console.log('generating %s', entry); +for (const entry of entries) { + console.log('generating %s', path.basename(entry)); - const schema = JSON.parse(await fs.promises.readFile(entry, 'utf8')); + const schema = JSON.parse(await fs.readFile(entry, 'utf8')); - await fs.promises.mkdir(path.dirname(getDist(entry)), { recursive: true }); - await fs.promises.writeFile( + await fs.mkdir(path.dirname(getDist(entry)), { recursive: true }); + await fs.writeFile( getDist(entry), - JSON.stringify(jsf.generate(schema), null, 2), + JSON.stringify(JSONSchemaFaker.generate(schema), null, 2), ); } -cache.reconcile(); - function getDist(entry) { return path.join(__dirname, '../.gen/documents', path.basename(entry)); } diff --git a/benchmarks/scripts/hook.mjs b/benchmarks/scripts/hook.mjs new file mode 100644 index 0000000..f1a251d --- /dev/null +++ b/benchmarks/scripts/hook.mjs @@ -0,0 +1,11 @@ +import * as fs from 'node:fs/promises'; +const { dependencies } = JSON.parse( + await fs.readFile('../../package.json', 'utf8'), +); +export async function resolve(specifier, context, nextResolve) { + if (Object.hasOwn(dependencies, specifier)) { + return nextResolve(`https://cdn.skypack.dev/${specifier}`, context); + } + + return nextResolve(specifier, context); +} diff --git a/benchmarks/scripts/rollup.config.mjs b/benchmarks/scripts/rollup.config.mjs deleted file mode 100644 index f4e9b64..0000000 --- a/benchmarks/scripts/rollup.config.mjs +++ /dev/null @@ -1,75 +0,0 @@ -import * as fs from 'node:fs'; -import * as path from 'node:path'; -import { fileURLToPath } from 'node:url'; - -import scenarios from '../scenarios.mjs'; -import expressionToFilePath from './utils/expression-to-file-path.mjs'; - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const dist = path.join(__dirname, '../.gen/suites'); - -function getIntro(filepath, expressions) { - const filename = path.basename(filepath, path.extname(filepath)); - return `import * as fs from 'node:fs'; - -import precompiledNimma from '../../nimma/${filename}/${expressionToFilePath( - expressions.join('-'), - )}.mjs'; - -const JSON_PATHS = ${JSON.stringify(expressions)}; - -const DOCUMENT = JSON.parse( - await fs.promises.readFile('${path.join( - __dirname, - '../.gen/documents/', - `${filename}.json`, - )}', 'utf8'), -);`; -} - -const pkg = JSON.parse( - fs.readFileSync(path.join(__dirname, '../../package.json'), 'utf8'), -); - -const external = [ - /^node:/, - ...Object.keys({ - ...pkg.dependencies, - ...pkg.optionalDependencies, - ...pkg.devDependencies, - }), -]; - -export default scenarios.flatMap(scenario => { - const dir = path.join( - dist, - scenario.name ?? - path.basename(scenario.filepath, path.extname(scenario.filepath)), - ); - - return [ - { - external, - input: path.join(__dirname, '../benchmark-template.mjs'), - output: { - dir, - entryFileNames: 'all.mjs', - format: 'es', - intro: getIntro(scenario.filepath, scenario.expressions), - }, - treeshake: false, - }, - - ...scenario.expressions.map((expression, i) => ({ - external, - input: path.join(__dirname, '../benchmark-template.mjs'), - output: { - dir, - entryFileNames: `${i}.mjs`, - format: 'es', - intro: getIntro(scenario.filepath, [expression]), - }, - treeshake: false, - })), - ]; -}); diff --git a/benchmarks/scripts/run-benchmark.sh b/benchmarks/scripts/run-benchmark.sh new file mode 100755 index 0000000..35180bb --- /dev/null +++ b/benchmarks/scripts/run-benchmark.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +cd $(dirname $0) +node --no-warnings --experimental-network-imports --import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register(pathToFileURL("./hook.mjs"));' ../benchmark.mjs --scenario="$1" --document="$2" + diff --git a/benchmarks/scripts/utils/expression-to-file-path.mjs b/benchmarks/scripts/utils/expression-to-file-path.mjs deleted file mode 100644 index 3828839..0000000 --- a/benchmarks/scripts/utils/expression-to-file-path.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import fnv1a from '@sindresorhus/fnv1a'; - -export default function (expr) { - return fnv1a(expr, { size: 128 }); -} diff --git a/package-lock.json b/package-lock.json index 5ab5030..3139840 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,6 @@ "@babel/preset-env": "^7.23.9", "@eslint/js": "^8.56.0", "@ls-lint/ls-lint": "^1.10.0", - "@sindresorhus/fnv1a": "^3.0.0", "benchmark": "^2.1.4", "c8": "^9.1.0", "chai": "^5.0.3", @@ -28,11 +27,10 @@ "eslint-plugin-chai-expect": "^3.0.0", "eslint-plugin-chai-friendly": "^0.7.4", "eslint-plugin-simple-import-sort": "^10.0.0", - "fast-glob": "^3.3.2", - "file-entry-cache": "^6.0.1", "globals": "^13.24.0", "husky": "^4.3.8", - "json-schema-faker": "^0.5.0-rcv.39", + "js-yaml": "^4.1.0", + "json-schema-faker": "^0.5.5", "jsonpath": "^1.1.1", "jsonpath-plus": "^7.1.0", "karma": "^6.4.2", @@ -1844,22 +1842,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/@eslint/eslintrc/node_modules/argparse": { - "version": "2.0.1", - "dev": true, - "license": "Python-2.0" - }, - "node_modules/@eslint/eslintrc/node_modules/js-yaml": { - "version": "4.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/@eslint/js": { "version": "8.56.0", "dev": true, @@ -2051,17 +2033,6 @@ "linux" ] }, - "node_modules/@sindresorhus/fnv1a": { - "version": "3.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@socket.io/component-emitter": { "version": "3.1.0", "dev": true, @@ -2189,12 +2160,10 @@ } }, "node_modules/argparse": { - "version": "1.0.10", - "dev": true, - "license": "MIT", - "dependencies": { - "sprintf-js": "~1.0.2" - } + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true }, "node_modules/assertion-error": { "version": "2.0.1", @@ -3071,11 +3040,6 @@ "node": ">=10" } }, - "node_modules/eslint/node_modules/argparse": { - "version": "2.0.1", - "dev": true, - "license": "Python-2.0" - }, "node_modules/eslint/node_modules/escape-string-regexp": { "version": "4.0.0", "dev": true, @@ -3132,17 +3096,6 @@ "node": ">=10.13.0" } }, - "node_modules/eslint/node_modules/js-yaml": { - "version": "4.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/espree": { "version": "9.6.1", "dev": true, @@ -3251,22 +3204,6 @@ "dev": true, "license": "MIT" }, - "node_modules/fast-glob": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", - "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", - "dev": true, - "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - }, - "engines": { - "node": ">=8.6.0" - } - }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "dev": true, @@ -3979,12 +3916,12 @@ "license": "MIT" }, "node_modules/js-yaml": { - "version": "3.14.1", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, - "license": "MIT", "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" @@ -4014,23 +3951,16 @@ "license": "MIT" }, "node_modules/json-schema-faker": { - "version": "0.5.0-rcv.39", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/json-schema-faker/-/json-schema-faker-0.5.5.tgz", + "integrity": "sha512-MlnBqcsM1t8jdHs00ltae0rlSwWI2nrd1IfnAF+UcHsqKFrlAhrbDFVKiA8C0E860PuspKoV4oImJdvtF7aqwg==", "dev": true, - "license": "MIT", "dependencies": { "json-schema-ref-parser": "^6.1.0", - "jsonpath-plus": "^5.1.0" + "jsonpath-plus": "^7.2.0" }, "bin": { - "jsf": "bin/gen.js" - } - }, - "node_modules/json-schema-faker/node_modules/jsonpath-plus": { - "version": "5.1.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10.0.0" + "jsf": "bin/gen.cjs" } }, "node_modules/json-schema-ref-parser": { @@ -4043,6 +3973,28 @@ "ono": "^4.0.11" } }, + "node_modules/json-schema-ref-parser/node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/json-schema-ref-parser/node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/json-schema-traverse": { "version": "0.4.1", "dev": true, @@ -4296,27 +4248,6 @@ "node": ">= 0.6" } }, - "node_modules/merge2": { - "version": "1.4.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, - "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "dev": true, - "dependencies": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, "node_modules/mime": { "version": "2.5.2", "dev": true, @@ -4424,11 +4355,6 @@ "sprintf-js": "^1.0.3" } }, - "node_modules/mocha/node_modules/argparse": { - "version": "2.0.1", - "dev": true, - "license": "Python-2.0" - }, "node_modules/mocha/node_modules/brace-expansion": { "version": "2.0.1", "dev": true, @@ -4448,17 +4374,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mocha/node_modules/js-yaml": { - "version": "4.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/mocha/node_modules/minimatch": { "version": "5.0.1", "dev": true, diff --git a/package.json b/package.json index 9ed7ace..ed7c027 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,6 @@ "@babel/preset-env": "^7.23.9", "@eslint/js": "^8.56.0", "@ls-lint/ls-lint": "^1.10.0", - "@sindresorhus/fnv1a": "^3.0.0", "benchmark": "^2.1.4", "c8": "^9.1.0", "chai": "^5.0.3", @@ -73,11 +72,10 @@ "eslint-plugin-chai-expect": "^3.0.0", "eslint-plugin-chai-friendly": "^0.7.4", "eslint-plugin-simple-import-sort": "^10.0.0", - "fast-glob": "^3.3.2", - "file-entry-cache": "^6.0.1", "globals": "^13.24.0", "husky": "^4.3.8", - "json-schema-faker": "^0.5.0-rcv.39", + "js-yaml": "^4.1.0", + "json-schema-faker": "^0.5.5", "jsonpath": "^1.1.1", "jsonpath-plus": "^7.1.0", "karma": "^6.4.2", diff --git a/scripts/copy-types.mjs b/scripts/copy-types.mjs deleted file mode 100644 index 3acc56c..0000000 --- a/scripts/copy-types.mjs +++ /dev/null @@ -1,12 +0,0 @@ -import cpy from 'cpy'; -import * as path from 'path'; -import { fileURLToPath } from 'url'; - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - -for (const dist of ['esm', 'cjs']) { - await cpy(['**/*.d.ts'], path.join(__dirname, '../dist', dist), { - cwd: path.join(__dirname, '../src'), - parents: true, - }); -}