Package Exports
- obtain-unicode
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 (obtain-unicode) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Isomorphic Unicode Codepoint to/from String converter
about
implementation of Obtain Unicode Algorithm from DOMString at http://www.w3.org/TR/WebIDL/#dfn-obtain-unicode
also polyfill of String.fromCodePoint() for convert codepoints to string. https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint#Polyfill
install
$ npm install obtain-unicodeusage
works in node and browser. Isomorphic !! no Browserify.
var obtainUnicode = obtainUnicode || require('../obtain-unicode').obtainUnicode;
console.log(obtainUnicode('beer!🍻'));
// [98, 101, 101, 114, 33, 127867]
console.log(String.fromCodePoint(98, 101, 101, 114, 33, 127867));
// "beer!🍻test
$ npm testand also open test/index.html in your browser and see console.
for TypeScript
and also add this type declare to your code. (because d.ts can't include this)
// polyfill for String.fromCodePoint
declare var String: {
new (value?: any): String;
(value?: any): string;
prototype: String;
fromCharCode(...codes: number[]): string;
/**
* Pollyfill of String.fromCodePoint
*/
fromCodePoint(...codePoints: number[]): string;
}License
The MIT License (MIT) Copyright (c) 2015 Jxck