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

@balena/odata-parser

v3.1.2

Published

An OData parser written in OMeta

Downloads

40,828

Readme

odata-parser

npm version

An OData parser written in OMeta.

OData is a protocol build on top of REST and HTTP, it's goal is to provide a uniform and reliable way to access and navigate resources.
For a full specification of the protocol refer to this link

This module is a part of the odata-compiler

The parser takes an input string representing the odata request and returns an object {tree, binds} if the parse is successful.

Imagine wanting the access a resource which is stored at as a depth two child of some other resource, the corresponding odata query would be something like /parent/child/granchild
This string is parsed into a tree where every intermediate resource is a node, each node contains the following properties

  • resource: The name of resource
  • key: An object containing the integer index at which the bind for the resource, if any, can be found
  • link: A reference to a child node if specified via the $links option
  • property: A reference to a child node if present
  • count: A boolean value representing if the $count option was specified for the resource
  • options: An object containing any other query options specified in the odata request

The binds array contains all the reference to primitive values contained in the odata request, example of such primitive values are: Reals, Booleans, Dates, Text, ecc.
These binds are stored in the binds array and are referenced in the tree by the integer index where the bind resides in this array.

Examples

input: /model

output:

{ tree:
   { resource: 'model',
     key: undefined,
     link: undefined,
     property: undefined,
     count: undefined,
     options: undefined }

input: /model(1)/child

output:

{ tree:
   { resource: 'model',
     key: { bind: 0 },
     link: undefined,
     property:
      { resource: 'child',
        key: undefined,
        link: undefined,
        property: undefined,
        count: undefined,
        options: undefined },
     count: undefined,
     options: undefined },
  binds: [ [ 'Real', 1 ] ] }

input: /model/$count?$filter=id gt 5

output:

{ tree:
   { resource: 'model',
     key: undefined,
     link: undefined,
     property: undefined,
     count: true,
     options: { '$filter': [ 'gt', { name: 'id', property: undefined }, { bind: 0 } ] } },
  binds: [ [ 'Real', 5 ] ] }

Tests

Tests can be found under the test/ folder, to run the whole suite use npm test