key-value-transformer
Scans and replaces key value pairs in a stream of linesimport { keyValueTransformer } from "key-value-transformer";
const input = getTextStream();
const output = keyValueTransformer(input, async * (key,value) => { yield [key, "newValue" ];})
API
Table of Contents
* [Parameters](#parameters)
* [Properties](#properties)
- colonSeparatedKeyValuePairOptions
- equalSeparatedKeyValuePairOptions
- colonSeparatedKeyValuePairOptionsDoublingKeys
- keyValueTransformer
* [Parameters](#parameters-1)
KeyValueUpdates
Type: FunctionParameters
Returns AsyncIterable<Array<string>> updated key and value pairs
Lines
Type: FunctionReturns Iterable<string>
KeyValueTransformOptions
Type: ObjectProperties
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: ObjectequalSeparatedKeyValuePairOptions
Type: ObjectcolonSeparatedKeyValuePairOptionsDoublingKeys
Type: ObjectkeyValueTransformer
Replaces key value pairs in a stream of lines.Parameters
source
AsyncIterable<string> input linesupdates
KeyValueUpdatesoptions
KeyValueTransformOptions (optional, defaultcolonSeparatedKeyValuePairOptions
)
Returns AsyncIterable<string> lines with replaces key value pairs
install
With npm do:npm install key-value-transformer
license
BSD-2-Clause