Need private packages and team management tools?Check out npm Teams »

strip-brackets

1.0.1 • Public • Published

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

Keywords

none

Install

npm i strip-brackets

DownloadsWeekly Downloads

0

Version

1.0.1

License

none

Last publish

Collaborators

  • avatar