strip-variation-selectors
v1.0.0
Published
Easily remove Unicode variation selectors from strings.
Downloads
194
Maintainers
Readme
strip-variation-selectors
strip-variation-selectors removes Unicode variation selectors from strings.
Installation
Via npm:
npm install strip-variation-selectors
In a browser:
<script src="strip-variation-selectors.js"></script>
In Node.js, io.js, Narwhal, and RingoJS:
var stripVariationSelectors = require('strip-variation-selectors');
In Rhino:
load('strip-variation-selectors.js');
Using an AMD loader like RequireJS:
require(
{
'paths': {
'strip-variation-selectors': 'path/to/strip-variation-selectors'
}
},
['strip-variation-selectors'],
function(stripVariationSelectors) {
console.log(stripVariationSelectors);
}
);
API
stripVariationSelectors.version
A string representing the semantic version number.
stripVariationSelectors.reverse(string)
This function takes a string and returns the stripped version of that string, where any variation selectors have been removed.
Usage example
// Note: U+FE0E is a variation selector.
const string = '\u21D5\u25B6\uFE0E\u{1F600}'; // '⇕▶︎😀'
console.log(
[...string].length
); // 4
const stripped = stripVariationSelectors(string);
console.log(
[...string].length
); // 3
Unit tests & code coverage
After cloning this repository, run npm install
to install the dependencies needed for strip-variation-selectors development and testing. You may want to install Istanbul globally using npm install istanbul -g
.
Once that’s done, you can run the unit tests in Node using npm test
or node tests/tests.js
. To run the tests in Rhino, Ringo, Narwhal, and web browsers as well, use grunt test
.
To generate the code coverage report, use grunt cover
.
Author
| | |---| | Mathias Bynens |
License
strip-variation-selectors is available under the MIT license.