runes2
Unicode-aware JS string splitting, typescript version
Last updated 2 years ago by bluelovers .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install runes2 
SYNC missed versions from official npm registry.

✂️ Runes

Unicode-aware JS string splitting with full Emoji support.

Split a string into its constituent characters, without munging emoji and other non-BMP code points.

this is typescript version fork form runes

Why?

The native String#split implementation does not pay attention to surrogate pairs. When the code units of a surrogate pair are split apart, they are not intelligible on their own. Unless they are put back together in the correct order, individual code units will cause problems in code that handles strings.

Installation

$ npm install runes2

Example

const runes = require('runes2').default
const runes = require('runes2').runes
import runes from 'runes2';
import { runes } from 'runes2';
// Standard String.split
'♥️'.split('') // => ['♥', '️']
'Emoji ????'.split('') // => ['E', 'm', 'o', 'j', 'i', ' ', '�', '�']
'????‍????‍????‍????'.split('') // => ['�', '�', '‍', '�', '�', '‍', '�', '�', '‍', '�', '�']

// ES6 string iterator
	[
...
'♥️'
] =>
['♥', '️']
	[
...
'Emoji ????'
] // => [ 'E', 'm', 'o', 'j', 'i', ' ', '????' ]
[...'????‍????‍????‍????'] // => [ '????', '', '????', '', '????', '', '????' ]

// Runes
runes('♥️') // => ['♥️']
runes('Emoji ????') // => ['E', 'm', 'o', 'j', 'i', ' ', '????']
runes('????‍????‍????‍????') // => ['????‍????‍????‍????']

Substring example

// String.substring
'????‍????‍????‍????a'.substring(1) // => '�‍????‍????‍????a'

// Runes
runes.substr('????‍????‍????‍????a', 1) // => 'a'

Current Tags

  • 1.1.4                                ...           latest (2 years ago)

22 Versions

  • 1.1.4                                ...           2 years ago
  • 1.1.3                                ...           2 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.0.10                                ...           3 years ago
  • 1.0.9                                ...           3 years ago
  • 1.0.8                                ...           4 years ago
  • 1.0.7                                ...           4 years ago
  • 1.0.5                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 0.4.16                                ...           4 years ago
  • 0.4.15                                ...           5 years ago
  • 0.4.14                                ...           6 years ago
  • 0.4.13                                ...           6 years ago
  • 0.4.12                                ...           6 years ago
  • 0.4.7                                ...           7 years ago
  • 0.4.6                                ...           7 years ago
  • 0.4.5                                ...           7 years ago
  • 0.4.4                                ...           8 years ago
  • 0.4.3                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 22
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |