key-value-transformer
v3.2.3
Published
Scans and replaces key value pairs in a stream of lines
Downloads
6,218
Readme
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
Returns AsyncIterable<Array<string>> updated key and value pairs
Lines
Type: Function
Returns Iterable<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> 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