key-value-transformer v3.2.3
key-value-transformer
Scans and replaces key value pairs in a stream of lines
import { keyValueTransformer } from "key-value-transformer";
const input = getTextStream();
const output = keyValueTransformer(input, async * (key,value) => { yield [key, "newValue" ];})
API
Table of Contents
- KeyValueUpdates
- Lines
- KeyValueTransformOptions
- colonSeparatedKeyValuePairOptions
- equalSeparatedKeyValuePairOptions
- colonSeparatedKeyValuePairOptionsDoublingKeys
- keyValueTransformer
KeyValueUpdates
Type: Function
Parameters
key
string current keyvalue
string current valuepresentKeys
Set[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) the already seen keys
Returns AsyncIterable[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> updated key and value pairs
Lines
Type: Function
Returns Iterable[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
KeyValueTransformOptions
Type: Object
Properties
extractKeyValue
Function 1st. line with key and valueextractValueContinuation
Function additional lines holding only valueslineEnding
string used to separate lineskeyValueSeparator
string chars to separate key from value like '=' or ':'keyValueLines
Function to generate line(s) for a key value(s) pairtrailingLines
Lines? lines coming after all key values have been writtenheadLines
Lines? lines before all key values have been written
colonSeparatedKeyValuePairOptions
Type: Object
equalSeparatedKeyValuePairOptions
Type: Object
colonSeparatedKeyValuePairOptionsDoublingKeys
Type: Object
keyValueTransformer
Replaces key value pairs in a stream of lines.
Parameters
source
AsyncIterable[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) input linesupdates
KeyValueUpdatesoptions
KeyValueTransformOptions (optional, defaultcolonSeparatedKeyValuePairOptions
)
Returns AsyncIterable[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) lines with replaces key value pairs
install
With npm do:
npm install key-value-transformer
license
BSD-2-Clause
2 months ago
3 months ago
3 months ago
3 months ago
12 months ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago