code-points
Get the code points of each character in the string
Last updated a year ago by shinnn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install code-points 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 2.0.0-1                                ...           latest (a year ago)

7 Versions

  • 2.0.0-1                                ...           a year ago
  • 2.0.0-0                                ...           a year ago
  • 1.1.3                                ...           5 years ago
  • 1.1.2                                ...           5 years ago
  • 1.1.1                                ...           6 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 48
This Week 324
This Month 324
Last Day 73
Last Week 440
Last Month 1,451
Dependencies (1)
Dev Dependencies (17)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |