$ npm install quote
Safe quoting a given string without adding duplicate quotes
Install using node or bower
npm install quote --save
bower install quote --save
Use
// node
var quote = require('quote');
quote('foo'); // "foo"
quote('"foo"'); // "foo"
quote(quote('foo')); // "foo"
In the browser just use global function quote
Only single quote character is supported, default is double quotes "
.
To change:
var quote = require('quote')({ quotes: '*' });
quote('foo'); // *foo*
quote('bar'); // *bar*
Because this is both Node and browser package, you need to build it using universal module definition CLI tool.
npm run build
npm test
Author: Gleb Bahmutov © 2014 @bahmutov glebbahmutov.com
License: MIT - do anything with the code, but don't blame me if it does not work.
Spread the word: tweet, star on github, etc.
Support: if you find any problems with this module, email / tweet / open issue on Github
© 2010 - cnpmjs.org x YWFE | Home | YWFE