0.2.0 • Published 5 years ago

@thinql/parse v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@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,
        },
      ],
    },
  ],
}))