Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

runes2

bluelovers451.3kMIT1.1.4TypeScript support: included

Unicode-aware JS string splitting, typescript version

char, emoji, runes, split, split string, string, unicode, create-by-yarn-tool, create-by-tsdx

readme

✂️ 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'

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

1.1.4 (2024-01-29)

🔖 Miscellaneous

1.1.3 (2023-11-24)

📌 Dependencies

1.1.2 (2023-04-12)

🔖 Miscellaneous

1.1.1 (2023-04-12)

🐛 Bug Fixes

  • runes: correctly handle subdivision-flags (f04aeb6)

🔖 Miscellaneous

1.0.10 (2022-11-01)

🔖 Miscellaneous

1.0.9 (2022-10-15)

🐛 Bug Fixes

  • Delete duplicated GRAPHEMS (55f5418)

📦 Code Refactoring

🔖 Miscellaneous

1.0.8 (2022-09-16)

🔖 Miscellaneous

1.0.7 (2022-08-27)

🔖 Miscellaneous

1.0.5 (2022-08-26)

🔖 Miscellaneous

1.0.4 (2022-08-26)

♻️ Chores

1.0.3 (2022-08-26)

Note: Version bump only for package runes2

1.0.3 (2022-08-26)

🔖 Miscellaneous

1.0.2 (2022-08-26)

BREAKING CHANGES

  • no longer supported const runes = require('runes2')

📦 Code Refactoring

🚨 Tests

1.0.1 (2022-08-24)

🐛 Bug Fixes

✨ Features

  • subtree import and update test (f7fe9ee)

📦 Code Refactoring

📚 Documentation

🛠 Build System

♻️ Chores

🔖 Miscellaneous

BREAKING CHANGES

  • no longer supported const runes = require('runes2')
  • support cjs and esm #1

0.4.0 "🔖 Miscellaneous" (2016-12-12)

🔖 Miscellaneous

0.4.16 (2022-01-17)

🔖 Miscellaneous

0.4.15 (2021-07-05)

🛠 Build System

  • typescript: importHelpers (0716543)

0.4.14 (2020-06-20)

Note: Version bump only for package runes2

0.4.13 (2020-06-07)

Note: Version bump only for package runes2

0.4.12 (2020-06-06)

Bug Fixes

  • avoid jest snap with unicode title (7192534)

0.4.11 (2020-06-06)

Bug Fixes

  • jest snap with unicode title (8bb0b19)

0.4.10 (2020-06-06)

Bug Fixes

0.4.9 (2020-06-06)

Note: Version bump only for package runes2

0.4.8 (2020-06-06)

Features

  • subtree import and update test (4a7a44c)