caql-js-compiler

A CaQL compiler that converts queries into executable JavaScript.

caql-js-compiler

Compile CaQL queries into executable JavaScript.

Learn more: Calypso Query Language (CaQL) Specification.

Install

npm install caql-js-compiler

Example

var JSCompiler = require('caql-js-compiler');

var entries = [
  { name: 'Postini', founded_year: 1999, total_money_raised: '$0' },
  { name: 'Digg', founded_year: 2004, total_money_raised: '$45M' },
  { name: 'Airbnb', founded_year: 2007, total_money_raised: '$120M' },
  { name: 'TripIt', founded_year: 2006, total_money_raised: '$13.1M' },
  { name: 'Twitter', founded_year: 2006, total_money_raised: '$1.16B' },
  { name: 'Spotify', founded_year: 2006, total_money_raised: '$183M' },
  { name: 'Airbnb', founded_year: 2008, total_money_raised: '$776.4M' }
];

var compiler = new JSCompiler();

var query =   'select name, founded_year, total_money_raised as worth '
            + 'where founded_year >= 1999 and name not like "%air%" '
            + 'order by founded_year desc, name';

compiler
  .compile(query)
  .execute(entries)
  .forEach(function(result) {
    console.log(result);
  });

// Output:
//
//    { name: 'Spotify', founded_year: 2006, worth: '$183M' }
//    { name: 'TripIt', founded_year: 2006, worth: '$13.1M' }
//    { name: 'Twitter', founded_year: 2006, worth: '$1.16B' }
//    { name: 'Digg', founded_year: 2004, worth: '$45M' }
//    { name: 'Postini', founded_year: 1999, worth: '$0' }

License

MIT

HomePage

https://github.com/kevinswiber/caql-js-compiler

Repository

https://github.com/kevinswiber/caql-js-compiler


上一篇:json-stream
下一篇:calypso-query-decompiler

相关推荐

  • 关于vue与vue-template-compiler版本号不一致的问题

    说实话....这个问题确实给我气炸了 当我脚手架升级之后(cil3.5升级到3.10) 运行vue ui命令 就报这个 告诉你你的vue版本和vue-template不一致,对吧 这我哪能忍,赶紧...

    1 年前
  • 使用Vue脚手架构建项目时Runtime + Compiler和Runtime-only的区别

    在使用vue-cli脚手架构建项目时,会遇到一个选项Vue build(vue构建),有两个选项,Runtime + Compiler和Runtime-only,以下为有道翻译直译 Runtim...

    1 年前
  • 使用Google Closure Compiler进行Js代码压缩

    1.Google Closure Compiler是什么? The Closure Compiler is a tool for making JavaScript download and run...

    2 年前
  • yox-template-compiler

    Template compiler for Yox.js yox-template-compiler Template compiler for Yox.js HomePage https://git...

    2 年前
  • yox-expression-compiler

    Expression compiler for Yox.js yox-expression-compiler Expression compiler for Yox.js HomePage https...

    2 年前
  • xtemplate-compiler

    undefined xtemplate-compiler CDN by jsDelivr - A free, fast, and re...

    3 个月前
  • win-find-jscript-compiler

    Find .NET's jsc.exe on Windows win-find-jscript-compiler Find .NET's jsc.exe on Windows. Noop on oth...

    2 年前
  • webpack-closure-compiler

    Google Closure Compiler plugin for Webpack webpack-closure-compiler Google Closure Compiler plugin f...

    2 年前
  • webpack compiler 钩子

    Compiler 模块是 webpack 的支柱引擎,它通过 CLI 或 Node API 传递的所有选项,创建出一个 compilation 实例。它扩展(extend)自 Tapable 类,以便...

    6 个月前
  • webcompiler

    Lint, type-check, compile, package and gzip JavaScript (ES6 + Flow static types + JSX), for the brow...

    1 年前

官方社区

扫码加入 JavaScript 社区