NormalizationOptions
KIT · interface · Type contract
Pipeline options.
Import
ts
import type { NormalizationOptions } from '@jangts/agent-core/kits/normalization';1
js
/** @typedef {import('@jangts/agent-core/kits/normalization').NormalizationOptions} NormalizationOptions */1
Other public entry points:@jangts/agent-core/types, @jangts/agent-core/kits/normalization, @jangts/agent-core/kits.
Definition
ts
interface NormalizationOptions<Value, Context>1
Type parameters
| Type parameter | Constraint | Default type |
|---|---|---|
Value | — | — |
Context | — | — |
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
isComplete | ((value: Value, context: Context) => boolean) | undefined | Optional | Read-only. Stops the walk after the step that first returns true; later steps then do not run. |
Examples
- Normalization: ordered value transformation: Collect cleaning, replacement, and stop conditions into one transformation list that actually drives execution.
Start by cleaning one query
Beginner · Node.js
ts
import { Normalization } from '@jangts/agent-core/kits/normalization';
const query = Normalization.defineNormalization<string>([
{ id: 'trim', normalize: value => value.trim() },
]);
console.log(query.normalize(' Agent Core ', undefined));1
2
3
4
5
2
3
4
5
js
import { Normalization } from '@jangts/agent-core/kits/normalization';
const query = Normalization.defineNormalization([
{ id: 'trim', normalize: value => value.trim() },
]);
console.log(query.normalize(' Agent Core ', undefined));1
2
3
4
5
2
3
4
5
Continue by adding steps and a stop condition
Configuration · Node.js
ts
import { Normalization } from '@jangts/agent-core/kits/normalization';
const query = Normalization.defineNormalization<string>([
{ id: 'trim', normalize: value => value.trim() },
{ id: 'collapse-space', normalize: value => value.replace(/\s+/g, ' ') },
{ id: 'lowercase', when: value => value !== '*', normalize: value => value.toLowerCase() },
], { isComplete: value => value === '*' });
const values = [' Agent Core ', 'agent core', '*'].map(value => query.normalize(value, undefined));
console.log(Normalization.uniqueBy(values, value => value));1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
js
import { Normalization } from '@jangts/agent-core/kits/normalization';
const query = Normalization.defineNormalization([
{ id: 'trim', normalize: value => value.trim() },
{ id: 'collapse-space', normalize: value => value.replace(/\s+/g, ' ') },
{ id: 'lowercase', when: value => value !== '*', normalize: value => value.toLowerCase() },
], { isComplete: value => value === '*' });
const values = [' Agent Core ', 'agent core', '*'].map(value => query.normalize(value, undefined));
console.log(Normalization.uniqueBy(values, value => value));1
2
3
4
5
6
7
8
2
3
4
5
6
7
8