JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3919
  • Score
    100M100P100Q139134F
  • License MIT

Get the code points of each character in the string

Package Exports

  • code-points

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 (code-points) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

code-points

npm version Build Status Coverage Status

Get the UTF-16-encoded code points of each character in the string

codePoints('Hello, δΈ–η•Œ\n'); //=> [72, 101, 108, 108, 111, 44, 32, 19990, 30028]

Installation

Use npm.

npm install code-points

API

codePoints(str, option)

str: string
option: Object
Return: Array<integer>

It returns the code points of each character in the string as an array.

codePoints('\udada'); //=> [56026]
codePoints('\udfdf\udada\udada'); //=> [57311, 56026, 56026]
codePoints('\udada\udfdf\udada'); //=> [814047, 56026]

option.unique

Type: boolean
Default: false

Removes duplicates from result.

codePoints('banana'); //=> [98, 97, 110, 97, 110, 97]
codePoints('banana', {unique: true}); //=> [98,97,110]

License

Copyright (c) 2014 - 2019 Shinnosuke Watanabe

Licensed under the MIT License.