npm.io
1.0.1 • Published 9 years ago

strip-brackets

Licence
—
Version
1.0.1
Deps
0
Vulns
0
Weekly
0
Stars
1

strip-brackets

Strips unecessary brackets

Greenkeeper badge

Usage

Pass it some configuration parameters and it will give you a new function that strips all unnecessary brackets.

Function Signature

stripBrackets(openChar = '[', closeChar = ']', joinChars = [',']) => input => output
import stripBrackets from 'strip-brackets';

const stripSquareBrackets = stripBrackets('[', ']', [',']);
stripSquareBrackets('[[a,b],[c],[[d]]]'); // => "[a,b],c,d"

const stripParens = stripBrackets('(', ')', [',']);
stripParens('((a,b),(c),((d)))'); // => "(a,b),c,d"
Parameters
openChar The opening bracket. Default: `[` closeChar The closing bracket. Default: `]` joinChars Characters that indicate that the current part of the string should be wrapped in brackets. Default: `[","]` input The string you want to strip brackets from output The resulting string, with unnecessary brackets removed