jqdash
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

jqdash

description

This is a porting of jq to javascript+WebAssembly using emscripten. The steps on how to do it can be found at here. The goal is to provide jq as a library for javascript applications.

install

npm install jqdash --save

usage

The package exposes a function that asynchronously load the Module object of emscripten API. After loaded, a jq method is added to it, and expected to be the only method user will ever need to use.

function jq(input: string, query: string, options: string[] | null): {stdout: string, stderr: string};

examples

import jqdash from 'jqdash';

// jq --version
jqdash().then((module: any) => {
    const { jq } = module;
    result = jq('', '', ['--version']);
    console.log(result.stdout);
});

// jq -n now
jqdash().then((module: any) => {
    const { jq } = module;
    result = jq('', 'now', ['-n']);
    console.log(result.stdout);
});

// echo '{"name":"test"}' | jq .name
jqdash().then((module: any) => {
    const { jq } = module;
    result = jq('{"name":"test"}', '.name');
    console.log(result.stdout);
});

// load by require
const jqdash = require('jqdash').default;

jqdash.then((module) => {
    const jq = module.jq;
    const jqoutput = jq('null', 'now', ['-M']).stdout;
    ......
}

jq version

1.6

Readme

Keywords

Package Sidebar

Install

npm i jqdash

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

3.95 MB

Total Files

8

Last publish

Collaborators

  • petli-full