@thinql/parse

0.2.0 • Public • Published

@thinql/parse

Parse ThinQL queries to ASTs

Installation

# npm
npm install @thinql/parse

# yarn
yarn add @thinql/parse

Example

import assert from 'assert'
import isEqual from 'lodash.isequal'
import parse from '@thinql/parse'

const result = parse('hello world')

assert(result.toString() === 'hello world')

assert(isEqual(result.toJSON(), {
  $type: 'Statement',
  expression: [
    {
      $type: 'LogicalAndExpression',
      assertions: [
        {
          $type: 'Assertion',
          assertion: {
            $type: 'FullTextSearch',
            value: {
              $type: 'Value',
              content: 'hello',
              literal: false,
            },
          },
          negated: false,
        },
        {
          $type: 'Assertion',
          assertion: {
            $type: 'FullTextSearch',
            value: {
              $type: 'Value',
              content: 'world',
              literal: false,
            },
          },
          negated: false,
        },
      ],
    },
  ],
}))

Package Sidebar

Install

npm i @thinql/parse

Weekly Downloads

3

Version

0.2.0

License

MIT

Unpacked Size

155 kB

Total Files

138

Last publish

Collaborators

  • mmiller42