Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@ajuhos/malloy-filter

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ajuhos/malloy-filter

Parsers for the Malloy filtering sub-languages

latest
Source
npmnpm
Version
0.0.334
Version published
Weekly downloads
44
51.72%
Maintainers
1
Weekly downloads
 
Created
Source

Filter Languages

There is a unique filter language for each filterable data type. The documentation-bRoKeN-lInK describes the various languages.

Grammars

malloy-filter use moo and nearley to generate parsers for each sub language. The grammars are in grammars.

After changing a .ne file use npm run build to update the generated parser.

API

Refer to the clause interfaces for details on the output of the parser, or look at the parser tests in src/test/ for more examples of parser output.

import {StringFilterExpression, StringClause} from '@ajuhos/malloy-filter'

// or ...
// NumberFilterExpression, NumberClause
// BooleanFilterExpression, BooleanClause
// TemporalFilterExpression, TemporalClause

// Each has two entry points, "parse" and "unparse"

const stringParse = StringFilterExpression.parse('FOO%,-FOOD')
if (stringParse.parsed) {
    console.log(JSON.stringify(stringParse.parsed, null, 2));
    /*
     * Output will look something like this ...
     * { operator: ',',
     *   members: [
     *     {operator: 'starts', values: ['FOO']}
     *     {operator: '=', not: true, values: ['FOOD']}
     *   ],
     * }
     */
    console.log(StringFilterExpression.unparse(stringParse.parse));
    /*
     * There will be minor variations on unparse, for example in this
     * case there will be space after the comma:
     *
     * FOO%, -FOOD
     */
} else {
    console.log(stringParse.log);
}

Testing

The malloy-filter tests use Jest.

npm run build
npm run test

FAQs

Package last updated on 08 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts