Skip to content

Latest commit

 

History

History
72 lines (49 loc) · 1.58 KB

.verb.md

File metadata and controls

72 lines (49 loc) · 1.58 KB

{%= name %} {%= badge("fury") %}

{%= description %}

See the wikipedia article on non-characters. Also, I used regenerate from mathiasbynens to generate the range of characters.

{%= include("install-npm", {save: true}) %}

Usage

var noncharacters = require('{%= name %}');
//=> ['\uFFFF', '\uFFFE', ...]

Example

Let's say you need to transform a string but you need to temporarily replace some characters that might cause issues.

Create your own placeholders:

// arbitrary characters we want to replace, 
// mapped to placeholder non-characters
var placeholders = {
  '{': noncharacters[0],
  '}': noncharacters[1]
};

// the string with characters to replace
var str = 'This is a template: {name}';

// actually replace the characters
Object.keys(placeholders).forEach(function(ch) {
  str = str.replace(ch, placeholders[ch]);
});
//=> This is a template: \uFFFFname\uFFFE

Now you can do whatever you want to str. Then, to change back:

Object.keys(placeholders).forEach(function(ch) {
  str = str.replace(placeholders[ch], ch);
});
//=> This is a template: {name}

Run tests

Install dev dependencies:

npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue]({%= bugs.url %})

Author

{%= include("author") %}

License

{%= copyright() %} {%= license() %}


{%= include("footer") %}