Skip to content

A porting of jq to javascript using WebAssembly.

Notifications You must be signed in to change notification settings

petli-full/jqdash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A porting of jq to javascript using WebAssembly.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published