Skip to content

Commit 30c11fc

Browse files
committed
Refactor using emoji-test-regex-pattern
1 parent 5582475 commit 30c11fc

27 files changed

+132
-374
lines changed

.babelrc

-30
This file was deleted.

.github/workflows/main.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Build and deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
- name: Install dependencies
15+
run: npm install
16+
- name: Build
17+
run: npm run build
18+
- name: Test
19+
run: npm test

.travis.yml

-9
This file was deleted.

README.md

+23-55
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# emoji-regex [![Build status](https://travis-ci.org/mathiasbynens/emoji-regex.svg?branch=main)](https://travis-ci.org/mathiasbynens/emoji-regex)
1+
# emoji-regex [![Build status](https://github.com/mathiasbynens/emoji-regex/actions/workflows/main.yml/badge.svg)](https://github.com/mathiasbynens/emoji-regex/actions/workflows/main.yml)
22

3-
_emoji-regex_ offers a regular expression to match all emoji symbols and sequences (including textual representations of emoji) as per the Unicode Standard.
4-
5-
This repository contains a script that generates this regular expression based on [Unicode data](https://github.com/node-unicode/node-unicode-data). Because of this, the regular expression can easily be updated whenever new emoji are added to the Unicode standard.
3+
_emoji-regex_ offers a regular expression to match all emoji symbols and sequences (including textual representations of emoji) as per the Unicode Standard. It’s based on [_emoji-test-regex-pattern_](https://github.com/mathiasbynens/emoji-test-regex-pattern), which generates (at build time) the regular expression pattern based on the Unicode Standard. As a result, _emoji-regex_ can easily be updated whenever new emoji are added to Unicode.
64

75
## Installation
86

@@ -15,7 +13,7 @@ npm install emoji-regex
1513
In [Node.js](https://nodejs.org/):
1614

1715
```js
18-
const emojiRegex = require('emoji-regex/RGI_Emoji.js');
16+
const emojiRegex = require('emoji-regex');
1917
// Note: because the regular expression has the global flag set, this module
2018
// exports a function that returns the regex rather than exporting the regular
2119
// expression itself, to make it impossible to (accidentally) mutate the
@@ -29,8 +27,7 @@ const text = `
2927
`;
3028

3129
const regex = emojiRegex();
32-
let match;
33-
while (match = regex.exec(text)) {
30+
for (const match of text.matchAll(regex)) {
3431
const emoji = match[0];
3532
console.log(`Matched sequence ${ emoji } — code points: ${ [...emoji].length }`);
3633
}
@@ -49,64 +46,35 @@ Matched sequence 👩🏿 — code points: 2
4946
Matched sequence 👩🏿 — code points: 2
5047
```
5148

52-
## Regular expression flavors
53-
54-
The package comes with three distinct regular expressions:
55-
56-
```js
57-
// This is the recommended regular expression to use. It matches all
58-
// emoji recommended for general interchange, as defined via the
59-
// `RGI_Emoji` property in the Unicode Standard.
60-
// https://unicode.org/reports/tr51/#def_rgi_set
61-
// When in doubt, use this!
62-
const emojiRegexRGI = require('emoji-regex/RGI_Emoji.js');
63-
64-
// This is the old regular expression, prior to `RGI_Emoji` being
65-
// standardized. In addition to all `RGI_Emoji` sequences, it matches
66-
// some emoji you probably don’t want to match (such as emoji component
67-
// symbols that are not meant to be used separately).
68-
const emojiRegex = require('emoji-regex/index.js');
69-
70-
// This regular expression matches even more emoji than the previous
71-
// one, including emoji that render as text instead of icons (i.e.
72-
// emoji that are not `Emoji_Presentation` symbols and that aren’t
73-
// forced to render as emoji by a variation selector).
74-
const emojiRegexText = require('emoji-regex/text.js');
75-
```
76-
77-
Additionally, in environments which support ES2015 Unicode escapes, you may `require` ES2015-style versions of the regexes:
78-
79-
```js
80-
const emojiRegexRGI = require('emoji-regex/es2015/RGI_Emoji.js');
81-
const emojiRegex = require('emoji-regex/es2015/index.js');
82-
const emojiRegexText = require('emoji-regex/es2015/text.js');
83-
```
84-
8549
## For maintainers
8650

8751
### How to update emoji-regex after new Unicode Standard releases
8852

53+
1. [Update _emoji-test-regex-pattern_ as described in its repository](https://github.com/mathiasbynens/emoji-test-regex-pattern#how-to-update-emoji-test-regex-pattern-after-new-uts51-releases).
54+
55+
1. Bump the _emoji-test-regex-pattern_ dependency to the latest version.
56+
8957
1. Update the Unicode data dependency in `package.json` by running the following commands:
9058

91-
```sh
92-
# Example: updating from Unicode v12 to Unicode v13.
93-
npm uninstall @unicode/unicode-12.0.0
94-
npm install @unicode/unicode-13.0.0 --save-dev
95-
````
59+
```sh
60+
# Example: updating from Unicode v13 to Unicode v14.
61+
npm uninstall @unicode/unicode-13.0.0
62+
npm install @unicode/unicode-14.0.0 --save-dev
63+
````
9664

97-
1. Generate the new output:
65+
1. Generate the new output:
9866

99-
```sh
100-
npm run build
101-
```
67+
```sh
68+
npm run build
69+
```
10270

103-
1. Verify that tests still pass:
71+
1. Verify that tests still pass:
10472

105-
```sh
106-
npm test
107-
```
73+
```sh
74+
npm test
75+
```
10876

109-
1. Send a pull request with the changes, and get it reviewed & merged.
77+
### How to publish a new release
11078

11179
1. On the `main` branch, bump the emoji-regex version number in `package.json`:
11280

@@ -121,7 +89,7 @@ const emojiRegexText = require('emoji-regex/es2015/text.js');
12189
1. Push the release commit and tag:
12290

12391
```sh
124-
git push
92+
git push && git push --tags
12593
```
12694

12795
Our CI then automatically publishes the new release to npm.

RGI_Emoji.d.ts

-5
This file was deleted.

RGI_Emoji.js

-6
This file was deleted.

es2015/RGI_Emoji.d.ts

-5
This file was deleted.

0 commit comments

Comments
 (0)