Socket
Socket
Sign inDemoInstall

obtain-unicode

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

obtain-unicode

implementation of convert a DOMString to a sequence of Unicode characters at http://www.w3.org/TR/WebIDL/#dfn-obtain-unicode and shim for String.fromCodePoint()


Version published
Weekly downloads
8.1K
increased by2.19%
Maintainers
1
Weekly downloads
 
Created
Source

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-unicode

usage

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 test

and also open test/index.html in your browser and see console.

for TypeScript

use obtain-unicode.d.ts

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

Keywords

FAQs

Package last updated on 02 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc