noncharacters

WebJar for noncharacters

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

noncharacters
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

noncharacters
WebJar for noncharacters
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/jonschlinkert/noncharacters

Download noncharacters

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/noncharacters/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>noncharacters</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/noncharacters/
implementation 'org.webjars.npm:noncharacters:1.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/noncharacters/
implementation ("org.webjars.npm:noncharacters:1.1.0")
'org.webjars.npm:noncharacters:jar:1.1.0'
<dependency org="org.webjars.npm" name="noncharacters" rev="1.1.0">
  <artifact name="noncharacters" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='noncharacters', version='1.1.0')
)
libraryDependencies += "org.webjars.npm" % "noncharacters" % "1.1.0"
[org.webjars.npm/noncharacters "1.1.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

noncharacters NPM version

34 non-character code points (labeled ), that are set aside and guaranteed to never be used for a character. Perfect to use for placeholders or temporary replacements during string transformations.

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

Install with npm

npm i noncharacters --save

Usage

var noncharacters = require('noncharacters');
//=> ['\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

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on February 27, 2015.

Versions

Version
1.1.0