# @ambassify/aql-condition

> AQL condition tool

Latest version **0.7.1** (published 2025-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ambassify/aql-condition
pnpm add @ambassify/aql-condition
yarn add @ambassify/aql-condition
bun add @ambassify/aql-condition
```

## Health

**Score 40/100 (D)** — status: stable.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.7.1 |
| Published | 2025-04-03 |
| First published | 2019-06-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16 |
| Dependencies | 1 |
| Unpacked size | 65.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ambassify |
| Maintainers | ambassify |

## Links

- npm: https://www.npmjs.com/package/@ambassify/aql-condition
- Repository: https://github.com/ambassify/aql
- Homepage: https://github.com/ambassify/aql#readme
- Issues: https://github.com/ambassify/aql/issues
- npm.io page: https://npm.io/package/@ambassify/aql-condition

## Dependencies (1)

- [@ambassify/aql-parser](https://npm.io/package/@ambassify/aql-parser.md) ^0.7.1

## Recent versions

- 0.7.1 (latest) — 2025-04-03
- 0.7.0 — 2025-04-03
- 0.6.1 — 2023-09-08
- 0.5.0 — 2021-09-16
- 0.4.1 — 2021-03-26
- 0.4.0 — 2020-11-06
- 0.3.1 — 2020-10-13
- 0.3.0 — 2020-10-13
- 0.2.0 — 2019-09-24
- 0.1.1 — 2019-06-12

## README

# aql-condition

Tool to help you build AQL conditions in code.

## Usage

```sh
npm install --save @ambassify/aql-condition
```

```js
const Condition = require('@ambassify/aql-condition');
```

### Normalize

Get an normalized version of your condition. This function tries to strip as much
irrelevant parts of your condition as it can detect.

```js
condition = Condition.normalize(condition);
```

### Parse

Parse a condition string and normalize it.

```js
const url = `https://foo.com/?condition=${encodeURIComponent(JSON.stringify(condition))}`;
const condition = Condition.parse(url);
```

### Filter

Get a subcondition of a condition by recursively filtering out only the parts you are interested in.

E.g. if you only want parts of the condition that target the "foo" key:

```js
condition = Condition.filter(condition, c => c.key === 'foo');
```

### And / Or / Not

Easily construct normalized and/or/not conditions.

```js
condition = Condition.and(condition, extraCondition);
condition = Condition.or(condition, anotherCondition);
condition = Condtion.and(a, b, c, d, asMuchAsYouWant);
negated = Condition.not(condition);
```

---
_Source: https://npm.io/package/@ambassify/aql-condition · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
