Skip to content

grncdr/js-parenthesize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 

Repository files navigation

parenthesize

Wrap a string in parens, brackets, or whatever else you want.

Synopsis

var assert = require('assert')
var parenthesize = require('./')

parenthesize is a function that will wrap a given value in parenthesis:

assert.equal('(A comment)', parenthesize("A comment"))

You can replace the parens by providing an alternative delimiter:

assert.equal('[1]', parenthesize(1, '[]'))

If you want multi-character or other unusual delimiters, use an array for the second argument:

assert.equal('do\nputs "wat"\nend', parenthesize('puts "wat"', ['do\n', '\nend']))

API

module.exports = (String, (String|Array<String>)? ) => String

LIcense

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published