kevel-keyword-builder
v1.0.1
Published
A simple dependency-free library to construct Kevel (Adzerk) flight-level keyword targeting strings.
Maintainers
Readme
Kevel Keyword Builder
A lightweight, dependency-free Node.js package to safely construct Flight-Level Keyword Targeting strings for the Kevel Decision API.
Kevel uses a specific syntax to handle boolean logic for flight keyword targeting:
- AND Logic: Keywords separated by commas (
,) - OR Logic: Rules separated by newlines (
\n) - NOT Logic: Keyword prefixed with an exclamation mark (
!)
This library helps you programmatically generate these strings without manual string manipulation.
Installation
npm install kevel-keyword-builderUsage
const kevel = require('kevel-keyword-builder');
// Basic AND targeting
const andRule = kevel.and('sports', 'basketball');
console.log(andRule);
// Output: "sports,basketball"
// Basic NOT targeting
const notRule = kevel.not('soccer');
console.log(notRule);
// Output: "!soccer"
// Complex Targeting: (sports AND basketball) OR (sports AND !soccer)
const complexRule = kevel.or(
kevel.and('sports', 'basketball'),
kevel.and('sports', kevel.not('soccer'))
);
console.log(complexRule);
// Output:
// sports,basketball
// sports,!soccerAPI
and(...keywords: (string | string[])[])
Combines keywords using Kevel's AND operator (,).
or(...rules: (string | string[])[])
Combines rules using Kevel's OR operator (\n).
not(keyword: string)
Prefixes a keyword with Kevel's NOT operator (!).
License
MIT
