parse-key-value-pair
v2.0.1
Published
Parse a string like `KEY=value` into `[key, value]`
Downloads
165
Readme
parse-key-value-pair
Parse a string like KEY=value
into [key, value]
Installation
npm:
npm install --save parse-key-value-pair
yarn:
yarn add parse-key-value-pair
Usage
import parseKeyValue from 'parse-key-value-pair'
const [key, value] = parseKeyValue('NODE_ENV=production')
API
parseKeyValuePair(input) => [key, value]
Returns the parsed key and value
parseKeyValuePair(input, { ignoreMalformed: true }) => [key, value] | null
Returns the parsed key and value, returns null
for malformed strings like ""
and =