Name: alternating-case-to-object
Owner: ABC News
Description: Convert an alternating cased string to a JSON object
Created: 2017-09-26 04:26:29.0
Updated: 2017-09-26 06:17:02.0
Pushed: 2017-10-02 01:36:47.0
Homepage: null
Size: 35
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A function to convert ALTERNATINGcase strings to objects.
t alternatingCaseToObject = require('alternating-case-to-object');
rnatingCaseToObject('PROPvalueSECONDthingALLOWEDyesTHINGS100');
>>
op: 'value',
cond: 'thing',
lowed: true,
ings: 100
"true"
, "yes"
, "false"
& "no"
will be converted to the booleans true
, true
, false
& false
, respectively.rnatingCaseToObject('GROUPfirstGROUPsecondGROUPthird');
>>
oup: ['first', 'second', 'third'];
You can pass an object as a second argument, defining one or more options:
Props in this array will always be returned as arrays, even if they occur in the config string zero or one time.
rnatingCaseToObject('AtrueA100BvalueAvalueDvalue', {
rayProps: ['a', 'b', 'c']
>>
[true, 100, 'value'],
['value'],
[],
'value'
Props in the config will be renamed if they occur in this object.
rnatingCaseToObject('CAMELCASEtrueKEBABCASE100', {
opMap: {
camelcase: 'camelCase',
kebabcase: 'kebab-case'
>>
melCase: true,
ebab-case': 100