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 🙏

© 2026 – Pkg Stats / Ryan Hefner

odata-filter-parser

v0.6.5

Published

Library for parsing and building OData filter strings

Readme

odata-filter-parser

Library for building and parsing OData filter strings. Supports a subset of functions defined in the OData specification V2 through V4.

Using the Library

Full API documentation and examples are available on the Documentation page.

Compatibility

Supports modern Node.js environments and browsers.

Including the Library

CommonJS

const { Parser, Predicate, Operators } = require('odata-filter-parser');

const predicate = Parser.parse("name eq 'John'");
console.log(predicate.serialize()); // (name eq 'John')

ES Modules / TypeScript

import { Parser, Predicate, Operators } from 'odata-filter-parser';

const predicate = Parser.parse("name eq 'John'");
console.log(predicate?.serialize()); // (name eq 'John')

Using the Library with TypeScript

odata-filter-parser includes built-in TypeScript type definitions (index.d.ts) exported out of the box. No manual type declarations or @custom_types workarounds are needed.

Simply import Parser, Predicate, and Operators directly in your TypeScript project:

import { Parser, Predicate, Operators } from 'odata-filter-parser';

// Parse an OData filter string
const predicate: Predicate | null = Parser.parse("date ge datetimeoffset'2023-01-01T00:00:00Z'");

// Construct predicates programmatically
const p1 = new Predicate({ subject: 'age', operator: Operators.GREATER_THAN, value: 21 });
const p2 = new Predicate({ subject: 'status', operator: Operators.EQUALS, value: 'active' });
const combined = Predicate.concat(Operators.AND, p1, p2);

console.log(combined.serialize()); // ((age gt 21) and (status eq 'active'))

Operators Reference

The library provides predefined Operators constants for constructing and parsing OData filter expressions:

| Constant Name | Keyword | Type | Description | | :--- | :--- | :--- | :--- | | Operators.EQUALS | 'eq' | Comparison | Evaluates whether a property is equal to a specified value. | | Operators.NOT_EQUAL | 'ne' | Comparison | Evaluates whether a property is not equal to a specified value. | | Operators.GREATER_THAN | 'gt' | Comparison | Evaluates whether a property value is strictly greater than a specified value. | | Operators.GREATER_THAN_EQUAL | 'ge' | Comparison | Evaluates whether a property value is greater than or equal to a specified value. | | Operators.LESS_THAN | 'lt' | Comparison | Evaluates whether a property value is strictly less than a specified value. | | Operators.LESS_THAN_EQUAL | 'le' | Comparison | Evaluates whether a property value is less than or equal to a specified value. | | Operators.AND | 'and' | Logical | Logical binary conjunction that evaluates to true if both logical expressions are true. | | Operators.OR | 'or' | Logical | Logical binary disjunction that evaluates to true if either logical expression is true. | | Operators.NOT | 'not' | Logical | Logical unary prefix operator that negates a logical expression. | | Operators.IN | 'in' | Membership | Determines whether a value is a member of a discrete set of values. | | Operators.HAS | 'has' | Flags / Bitmask | Determines whether a property contains a specific enumeration flag or bitwise mask. | | Operators.LIKE | 'like' | String Extension | Wildcard string matching operator that translates to standard OData string functions (contains, startswith, endswith). | | Operators.IS_NULL | 'is null' | Extension | Unary postfix operator that determines whether a property is null. |

Functions Reference

The library provides Functions constants for string matching functions supported in OData filter expressions:

| Constant Name | Keyword | Description | | :--- | :--- | :--- | | Functions.CONTAINS | 'contains' | Checks if a string property contains a specified substring. | | Functions.STARTSWITH | 'startswith' | Checks if a string property starts with a specified prefix substring. | | Functions.ENDSWITH | 'endswith' | Checks if a string property ends with a specified suffix substring. | | Functions.ENDSWIDTH | 'endswith' | Legacy constant retained for backward compatibility (deprecated). |

Including the Library with Aurelia CLI

If using Aurelia CLI, configure the dependency in aurelia.json:

{
   "name": "odata-filter-parser",
   "path": "../node_modules/odata-filter-parser",
   "main": "index"
}

Dependencies

Runtime

This library has zero runtime dependencies (the dependencies section in package.json is empty), ensuring zero transitive dependency conflicts and a lightweight bundle.

Development Tooling

All build and testing utilities are scoped strictly to devDependencies:

  • tsup: Bundler (powered by esbuild)
  • Vitest: Test runner
  • TypeScript: Type definitions and compilation support
  • ESLint: Code quality and linting rules

None of these development tools are required or installed when consuming odata-filter-parser in your application.

Platform Support

Works on all modern browsers and Node.js runtimes.

Building The Library

The project uses tsup (powered by esbuild) for fast zero-config bundling.

To build the unminified (dist/odata-parser.js) and minified (dist/odata-parser-min.js) library bundles:

npm run build

Running Tests

Tests are powered by Vitest.

To run all unit tests:

npm test

To run tests in watch mode during development:

npm run test:watch

Linting

To run ESLint across the codebase:

npm run eslint

Submission Guidelines

Pull requests are welcome for bug fixes or feature requests. Please contact the owner prior to proposing a pull request for major non-bug changes. All submissions should provide test coverage and pass ESLint checks (npm run eslint).

Deployment Information

  1. Update version in package.json matching the release tag.
  2. Commit changes.
  3. Create release tag:
    git tag -a <newVersion> -m "created tag <newVersion>"
    git push origin --tags
  4. Pack and publish:
    npm pack
    npm publish