New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

uniql-js

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uniql-js

Produces Javascript from UniQL ASTs.

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

UniQL-JS

This generates Javascript based on UniQL ASTs.

Example

const parse = require( 'uniql' );
const uniql_to_js_compiler = require( 'uniql-js' );

const compiler = uniql_to_js_compiler.create();

const ast = parse( `
    ( height <= 20 or
      ( favorites.color == "green" and height != 25 ) )
      and firstname ~= "o.+"` );
const javascript = compiler.compile( ast );
console.log( javascript );

Results:

( height <= 20 ||
  ( favorites.color == "green" && height != 25 ) )
  && firstname.match( new RegExp( "o.+" ) )

API

.create( [ options ] )

Creates a JS compiler. You can override generators for various symbols or the post-processor for the compiled code, eg:

const compiler = uniql_to_js_compiler.create( {
    generators: {
        // eg: rename a certain variable
        SYMBOL: node => {
            const symbol_text = node.arguments[ 0 ];
            if ( symbol_text === 'foo' ) {
                return 'bar';
            }

            return symbol_text;
        }
    },

    // eg: return a markdown block instead of just the compiled code
    post_process: compiled => {
        return `\`\`\`javascript\n${ compiled }\n\`\`\``;
    }
} );

License

MIT

Keywords

uniql

FAQs

Package last updated on 06 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts