Skip to content

albinekb/parse-key-value-pair

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 =