# code-points

> Get the code points of each character in the string

Latest version **2.0.0-1** (published 2019-04-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install code-points
pnpm add code-points
yarn add code-points
bun add code-points
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0-1 |
| Published | 2019-04-05 |
| First published | 2014-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Shinnosuke Watanabe |
| Maintainers | shinnn |
| Keywords | code, point, code-point, string, char, character, unicode, utf16, utf-16, codepointat, surrogate, plane |

## Links

- npm: https://www.npmjs.com/package/code-points
- Repository: https://github.com/shinnn/code-points.js
- Homepage: https://github.com/shinnn/code-points.js#readme
- Issues: https://github.com/shinnn/code-points.js/issues
- npm.io page: https://npm.io/package/code-points

## Dependencies (1)

- [code-point](https://npm.io/package/code-point.md) ^1.0.1

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 2.0.0-1 (latest) — 2019-04-05
- 2.0.0-0 — 2019-04-05
- 1.1.3 — 2015-06-01
- 1.1.2 — 2015-02-26
- 1.1.1 — 2014-11-12
- 1.1.0 — 2014-10-16
- 1.0.0 — 2014-10-15

## README

# code-points

[![npm version](https://img.shields.io/npm/v/code-points.svg)](https://www.npmjs.com/package/code-points)
[![Build Status](https://travis-ci.com/shinnn/code-points.js.svg?branch=master)](https://travis-ci.com/shinnn/code-points.js)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/code-points.js.svg)](https://coveralls.io/github/shinnn/code-points.js)

Get the [UTF-16](https://wikipedia.org/wiki/UTF-16)-encoded code points of each character in the string

```javascript
codePoints('Hello, 世界\n'); //=> [72, 101, 108, 108, 111, 44, 32, 19990, 30028]
```

## Installation

[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).

```
npm install code-points
```

## API

### codePoints(*str*, *option*)

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

It returns the [code point](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)s of each character in the string as an array.

```javascript
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.

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

## License

Copyright (c) 2014 - 2019 [Shinnosuke Watanabe](https://github.com/shinnn)

Licensed under [the MIT License](https://github.com/shinnn/code-points/blob/master/LICENSE).

---
_Source: https://npm.io/package/code-points · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
