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" ];})
- KeyValueUpdates
- Lines
- KeyValueTransformOptions
- colonSeparatedKeyValuePairOptions
- equalSeparatedKeyValuePairOptions
- colonSeparatedKeyValuePairOptionsDoublingKeys
- keyValueTransformer
Type: Function
Returns AsyncIterable<Array<string>> updated key and value pairs
Type: Function
Returns Iterable<string>
Type: Object
-
extractKeyValue
Function 1st. line with key and value -
extractValueContinuation
Function additional lines holding only values -
lineEnding
string used to separate lines -
keyValueSeparator
string chars to separate key from value like '=' or ':' -
keyValueLines
Function to generate line(s) for a key value(s) pair -
trailingLines
Lines? lines coming after all key values have been written -
headLines
Lines? lines before all key values have been written
Type: Object
Type: Object
Type: Object
Replaces key value pairs in a stream of lines.
-
source
AsyncIterable<string> input lines -
updates
KeyValueUpdates -
options
KeyValueTransformOptions (optional, defaultcolonSeparatedKeyValuePairOptions
)
Returns AsyncIterable<string> lines with replaces key value pairs
With npm do:
npm install key-value-transformer
BSD-2-Clause