项目作者: albinekb

项目描述 :
🔮 Parse a string like KEY=value into [key, value]
高级语言: JavaScript
项目地址: git://github.com/albinekb/parse-key-value-pair.git
创建时间: 2018-02-14T19:01:52Z
项目社区:https://github.com/albinekb/parse-key-value-pair

开源协议:

下载


parse-key-value-pair

Parse a string like KEY=value into [key, value]

Installation

npm:

  1. npm install --save parse-key-value-pair

yarn:

  1. yarn add parse-key-value-pair

Usage

  1. import parseKeyValue from 'parse-key-value-pair'
  2. 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 =