npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@slackbyte/odata-query-parser

v0.0.5

Published

A highly versatile and fast OData Version 4.01 Parser.

Downloads

2

Readme

odata-query-parser

A highly versatile and fast OData Version 4.01 Parser which support almost all the available system query options like $filter, $orderby, $skip, $top, $count. The Open Data Protocol (OData) enables the creation of REST-based data services which allow resources, identified using Uniform Resource Locators (URLs) and defined in a data model. The Parser on high level works on lexer scanner strategy.

How to build

To run the parser in local, please clone the repository and follow the below steps:

npm install
npm run parser

To test and for test coverage:

npm test
npm run test:report

How to use

import { parseFilter, parseOrderby, parseSkip, parseTop } from '@slackbyte/odata-query-parser';
const filter = "Price gt 20 or Rating ge 10 not (Name eq 'uday singh' and City in ('Redmond', 'London'))"
console.log(parseFilter(filter));

Output:

{
  token: [
    { tokenType: 'conditionMemberExp', subType: '', value: 'Price' },
    { tokenType: 'comOperatorExp', subType: 'greaterThanExp', value: '>'},
    { tokenType: 'conditionMemberExp', subType: '', value: '20' },
    { tokenType: 'logOperatorExp', subType: 'orExp', value: 'OR' },
    { tokenType: 'conditionMemberExp', subType: '', value: 'Rating' },
    { tokenType: 'comOperatorExp', subType: 'greaterThanEqualToExp', value: '>='},
    { tokenType: 'conditionMemberExp', subType: '', value: '10' },
    { tokenType: 'logOperatorExp', subType: 'notExp', value: 'NOT' },
    { tokenType: 'groupOperatorExp', subType: 'openBracExp', value: '('},
    { tokenType: 'conditionMemberExp', subType: '', value: 'Name' },
    { tokenType: 'comOperatorExp', subType: 'equalToExp', value: '=' },
    { tokenType: 'conditionMemberExp', subType: '', value: "'uday singh'"},
    { tokenType: 'logOperatorExp', subType: 'andExp', value: 'AND' },
    { tokenType: 'conditionMemberExp', subType: '', value: 'City' },
    { tokenType: 'comOperatorExp', subType: 'inExp', value: 'in' },
    { tokenType: 'conditionMemberExp', subType: '', value: "('Redmond', 'London')"},
    { tokenType: 'groupOperatorExp', subType: 'closeBracExp', value: ')'}
  ]
}

Support Features

  • [x] $count
  • [x] $filter
    • [x] Comparison Operators
      • [x] eq
      • [x] ne
      • [x] lt
      • [x] le
      • [x] gt
      • [x] ge
      • [x] has
      • [x] in
    • [x] Logical Operators
      • [x] and
      • [x] or
      • [x] not
    • [x] Arithmetic Operators
      • [x] add
      • [x] sub
      • [x] mul
      • [x] div
      • [ ] divby
      • [x] mod
    • [x] String Functions
      • [x] indexof
      • [x] contains
      • [x] endswith
      • [x] startswith
      • [x] length
      • [x] substring
      • [x] tolower
      • [x] toupper
      • [x] trim
      • [x] concat
    • [x] Date Functions
      • [x] year
      • [x] month
      • [x] day
      • [x] hour
      • [x] minute
      • [x] second
      • [x] fractionalseconds
      • [x] date
      • [x] time
      • [x] totaloffsetminutes
      • [x] now
      • [x] mindatetime
      • [x] maxdatetime
    • [x] Math Functions
      • [x] round
      • [x] floor
      • [x] ceiling
    • [x] Type and conditional Functions
      • [x] cast
      • [x] isof
      • [x] case
  • [ ] $select
  • [x] $top
  • [x] $skip
  • [x] $orderby

CONTRIBUTING

I love your inputs! and I want to make your contribution to this project easy and transparent, whether it's:

  • Reporting a bug
  • Discussing the current state of the code
  • Submitting a fix
  • Proposing new features

Please raise a pull request. 😊

Made with love in INDIA. ❤️