# unicode-slice

> Slice a unicode string by it's visual width

Latest version **1.0.1** (published 2019-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install unicode-slice
pnpm add unicode-slice
yarn add unicode-slice
bun add unicode-slice
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-10-11 |
| First published | 2018-06-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 2 |
| Unpacked size | 11.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | jacobbubu |
| Maintainers | jacobbubu |

## Links

- npm: https://www.npmjs.com/package/unicode-slice
- Repository: https://github.com/NXMIX/unicode-slice
- Homepage: https://github.com/NXMIX/unicode-slice#readme
- Issues: https://github.com/NXMIX/unicode-slice/issues
- npm.io page: https://npm.io/package/unicode-slice

## Dependencies (2)

- [ansi-styles](https://npm.io/package/ansi-styles.md) ^4.1.0
- [@nxmix/emoji-seq-match](https://npm.io/package/@nxmix/emoji-seq-match.md) ^1.0.0

## Recent versions

- 1.0.1 (latest) — 2019-10-11
- 1.0.0 — 2018-06-12
- 0.1.0 — 2018-06-04

## README

# unicode-slice

[![Build Status](https://travis-ci.org/NXMIX/unicode-slice.svg?branch=master)](https://travis-ci.org/NXMIX/unicode-slice)
[![Coverage Status](https://coveralls.io/repos/github/NXMIX/unicode-slice/badge.svg)](https://coveralls.io/github/NXMIX/unicode-slice)
[![npm](https://img.shields.io/npm/v/unicode-slice.svg?maxAge=1000)](https://www.npmjs.com/package/unicode-slice/)

> Slice a unicode string by it's visual width

### Install

`npm i unicode-slice --save`

[Typescript](https://www.typescriptlang.org) definition file is already included.

### EXAMPLES

```js
const slice = require('unicode-slice').default;

// String.prototype.slice
"👶🏽".slice(0, 1);
//=>'�'

// Deal with emoji skin-tone modifer as one character
slice("👶" + "🏽", 0, 1);
//=> 👶🏽

// Won't separate emoji family :)
slice("👩‍👩‍👦‍👦", 0, 1);
//=> 👩‍👩‍👦‍👦

// Ansi color is preserved
slice("12" + chalk.red("34") + "56", 1, 5);
//=> 2\u001b[31m34\u001b[39m5
```

Using ES2015w Modules:

```ts
import slice from 'unicode-slice';

slice('👶🏽', 0, 1);
```

## Author

[Rong Shen](https://github.com/jacobbubu)

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