gnata-js
v0.2.1
Published
Browser JSONata via gnata WASM for backend parity, not a performance optimization
Downloads
1,151
Maintainers
Readme
gnata-js
Browser JSONata evaluation via gnata WebAssembly. Runs the same Go evaluator used by backend services in the browser for expression parity — not a performance optimization over the jsonata npm package.
Install
npm install gnata-jsUsage
import { jsonata } from 'gnata-js';
const result = await jsonata('Account.Order.Product.Price').evaluate({
Account: {
Order: [
{ Product: { Price: 34.45 } },
{ Product: { Price: 21.67 } },
],
},
});
// [34.45, 21.67]Asset Setup
The package ships gnata.wasm and wasm_exec.js in node_modules/gnata-js/wasm/. Copy them so your web server serves them at /wasm/:
// rspack / webpack
new CopyPlugin({
patterns: [{ from: 'node_modules/gnata-js/wasm', to: 'wasm' }],
});Override paths with configure() if needed:
import { jsonata, configure } from 'gnata-js';
configure({ wasmUrl: '/assets/gnata.wasm', execJsUrl: '/assets/wasm_exec.js' });License
MIT
