# code-point

> Get a UTF-16-encoded code point number of a character

Latest version **1.1.0** (published 2016-06-02) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.1.0 |
| Published | 2016-06-02 |
| First published | 2014-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Shinnosuke Watanabe |
| Maintainers | shinnn |
| Keywords | code, point, code-point, string, char, character, unicode, utf16, utf-16, codepointat, surrogate, plane, browser, client-side |

## Links

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

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

- 1.1.0 (latest) — 2016-06-02
- 2.0.0-1 (next) — 2018-12-10
- 2.0.0-0 — 2018-12-06
- 1.0.1 — 2014-10-10
- 1.0.0 — 2014-10-10
- 0.0.1 — 2014-10-10
- 0.0.0 — 2014-10-10

## README

# code-point.js

[![NPM version](https://img.shields.io/npm/v/code-point.svg)](https://www.npmjs.com/package/code-point)
[![Bower version](https://img.shields.io/bower/v/code-point.svg)](https://github.com/shinnn/code-point.js/releases)
[![Build Status](https://travis-ci.org/shinnn/code-point.js.svg?branch=master)](https://travis-ci.org/shinnn/code-point.js)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/code-point.js.svg)](https://coveralls.io/r/shinnn/code-point.js)
[![devDependency Status](https://david-dm.org/shinnn/code-point.js/dev-status.svg)](https://david-dm.org/shinnn/code-point.js#info=devDependencies)

Get a [UTF-16](https://wikipedia.org/wiki/UTF-16)-encoded code point number of a character

```javascript
'A'.charCodeAt(0); //=> 65
codePoint('A'); //=> 65

'嶲'.charCodeAt(0); //=> 55422
codePoint('嶲'); //=> 195060
```

## Installation

### Package managers

#### [npm](https://www.npmjs.com/)

```
npm install code-point
```

#### [Bower](http://bower.io/)

```
bower install code-point
```

### Standalone

[Download the script file directly.](https://raw.githubusercontent.com/shinnn/code-point.js/master/browser.js)

## API

### codePoint(*character*)

*character*: `String`  
Return: `Number`

If it takes a string as an argument, it returns the same result of `character.codePointAt(0)`.

It throws an error if the argument is not a string or the string is empty.

```javascript
codePoint('\udada'); //=> 56026
codePoint('\udada\udfdf'); //=> 814047
```

It works correctly even in ECMAScript <= 5 environments that don't support  [`String.prototype.codePointAt`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt).

## Credit

This module includes the code of [mathiasbynens](https://github.com/mathiasbynens) / [String.prototype.codePointAt](https://github.com/mathiasbynens/String.prototype.codePointAt). Thanks, [Mathias Bynens][mathias].

## Licenses

### [String.prototype.codePointAt](https://github.com/mathiasbynens/String.prototype.codePointAt#license)

Author: [Mathias Bynens][mathias]

> This polyfill is available under the [MIT](https://opensource.org/licenses/mit-license) license.

### code-point.js

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

Licensed under [the MIT License](https://github.com/shinnn/code-point/blob/master/LICENSES.md#code-pointjs).

[mathias]: https://mathiasbynens.be/

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