Package Exports
- escaper
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (escaper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Escaper
Library for escaping string literals, regular expressions and comments in the syntax of JavaScript.
Supported:
' ... '
" ... "
` ... `
,` ... ${...} `
/ ... /
// ...
/* ... */
,/** ... */
,/*! ... */
Install
https://raw.githubusercontent.com/kobezzza/Escaper/master/dist/escaper.min.js
or
npm install escaper
or
bower install escaper
or
git clone https://github.com/kobezzza/Escaper
Usage
var str = '"foo" 1 + /foo/ + 2 /* 1 */ 3',
content = [];
// __ESCAPER_QUOT__0_ 1 + __ESCAPER_QUOT__1_ + 2 __ESCAPER_QUOT__2_ 3
str = Escaper.replace(str, true, content);
// "foo" 1 + /foo/ + 2 /* 1 */ 3
Escaper.paste(str, content);
API
Escaper.replace(str, opt_withComment, opt_quotContent)
Replace blocks ' ... '
, " ... "
, ` ... `
, / ... /
, // ...
, /* ... */
on
__ESCAPER_QUOT__number_
in the specified string.
Arguments
string
str
— source string(Object|boolean)=
opt_withCommentsOrParams = false
— parameters:
{
'@all' : true, // Replace all sequences
'@comments': true, // Replace all kinds of comments
'@strings' : true, // Replace all kinds of string literals
'@literals': true, // Replace all kinds of string literals
// and regular expressions
"'" : true,
'"' : true,
'`' : true,
'/' : true,
'//' : true,
'/*' : true,
'/**' : true,
'/*!' : true
}
If set value to -1
, it will be removal, without the possibility of replacing back,
or true
/false
— include/exclude.
If parameter opt_withCommentsOrParams
is boolean:
true // Replace all sequences
false // Replace all kinds of string literals and regular expressions
Array=
opt_quotContent = Escaper.quotContent
— content store
@return {string}
Escaper.paste(str, opt_quotContent)
Replace __ESCAPER_QUOT__number_
in the specified string on the real content.
Arguments
string
str
— source stringArray=
opt_quotContent = Escaper.quotContent
— content store
@return {string}
License
The MIT License.