This commit is contained in:
GCHQDeveloper581 2026-03-15 14:30:40 +00:00 committed by GitHub
commit c5567f6ef6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 17 deletions

12
package-lock.json generated
View file

@ -53,7 +53,7 @@
"highlight.js": "^11.11.1",
"ieee754": "^1.2.1",
"jimp": "^1.6.0",
"jq-wasm": "^1.1.0-jq-1.8.1",
"jq-web": "^0.5.1",
"jquery": "3.7.1",
"js-sha3": "^0.9.3",
"jsesc": "^3.1.0",
@ -12158,11 +12158,11 @@
"integrity": "sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==",
"license": "BSD-3-Clause"
},
"node_modules/jq-wasm": {
"version": "1.1.0-jq-1.8.1",
"resolved": "https://registry.npmjs.org/jq-wasm/-/jq-wasm-1.1.0-jq-1.8.1.tgz",
"integrity": "sha512-lWfu34lpDFIygOYcL5TzxhZIApDR9iR5XywcVoyUAZ6jlQrj8HKHOKeCcHgUm2dE9RVdbP3eqNAKGLuj+k4seQ==",
"license": "MIT"
"node_modules/jq-web": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/jq-web/-/jq-web-0.5.1.tgz",
"integrity": "sha512-3Fa3E6g3U1O1j46ljy0EM10yRr4txzILga8J7bqOG8F89gZ6Lilz82WG9z6TItWpYEO0YGa4W8yFGj+NMM1xqQ==",
"license": "ISC"
},
"node_modules/jquery": {
"version": "3.7.1",

View file

@ -136,7 +136,7 @@
"highlight.js": "^11.11.1",
"ieee754": "^1.2.1",
"jimp": "^1.6.0",
"jq-wasm": "^1.1.0-jq-1.8.1",
"jq-web": "^0.5.1",
"jquery": "3.7.1",
"js-sha3": "^0.9.3",
"jsesc": "^3.1.0",

View file

@ -6,7 +6,7 @@
import Operation from "../Operation.mjs";
import OperationError from "../errors/OperationError.mjs";
import * as jq from "jq-wasm";
import jq from "jq-web";
/**
* jq operation
@ -40,15 +40,16 @@ class Jq extends Operation {
* @returns {string}
*/
run(input, args) {
return (async () => {
const [query] = args;
try {
const result = await jq.json(input, query);
return JSON.stringify(result);
} catch (err) {
throw new OperationError(`Invalid jq expression: ${err.message}`);
}
})();
const [query] = args;
let result;
try {
result = jq.json(input, query);
} catch (err) {
throw new OperationError(`Invalid jq expression: ${err.message}`);
}
return JSON.stringify(result);
}
}