Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/get-4byte-chars
Get all 4-byte characters form a string
https://github.com/shinnn/get-4byte-chars
Last synced: 27 days ago
JSON representation
Get all 4-byte characters form a string
- Host: GitHub
- URL: https://github.com/shinnn/get-4byte-chars
- Owner: shinnn
- License: mit
- Created: 2016-08-19T10:08:12.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-10-03T10:44:19.000Z (about 8 years ago)
- Last Synced: 2024-10-04T10:04:00.838Z (about 1 month ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# get-4byte-chars
[![NPM version](https://img.shields.io/npm/v/get-4byte-chars.svg)](https://www.npmjs.com/package/get-4byte-chars)
[![Bower version](https://img.shields.io/bower/v/get-4byte-chars.svg)](https://github.com/shinnn/get-4byte-chars/releases)
[![Build Status](https://travis-ci.org/shinnn/get-4byte-chars.svg?branch=master)](https://travis-ci.org/shinnn/get-4byte-chars)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/get-4byte-chars.svg)](https://coveralls.io/r/shinnn/get-4byte-chars)
[![dependencies Status](https://david-dm.org/shinnn/get-4byte-chars/status.svg)](https://david-dm.org/shinnn/get-4byte-chars)
[![devDependencies Status](https://david-dm.org/shinnn/get-4byte-chars/dev-status.svg)](https://david-dm.org/shinnn/get-4byte-chars?type=dev)Get all 4-byte characters form a string
```javascript
get4byteChars('I 💓 🍣.'); //=> ['💓', '🍣']
```## Installation
### [npm](https://www.npmjs.com/)
```
npm install get-4byte-chars
```### [bower](https://bower.io/)
```
bower install get-4byte-chars
```## API
### get4byteChars(*str* [, *option*])
*str*: `String`
*option*: `Object`
Return: `Array`It detects characters that costs 4 bytes in [UTF-8](https://tools.ietf.org/html/rfc3629) from a given string, and returns them as an array.
#### option.unique
Type: `Boolean`
Default: `true`Omit all duplicated characters from result.
```javascript
get4byteChars('🌊🌊 \😺/ 🌊🌊');
//=> ['🌊', '😺']get4byteChars('🌊🌊 \😺/ 🌊🌊', {unique: false});
//=> ['🌊', '🌊', '😺', '🌊', '🌊']
```## License
Copyright (c) 2016 [Shinnosuke Watanabe](https://github.com/shinnn)
Licensed under [the MIT License](./LICENSE).