Awesome
emoji-str-position
「 emoji in str position 」
Install
npm install emoji-str-position
yarn add emoji-str-position
Usage
const m = require('emoji-str-position');
const text = `
\u{231A}: ⌚ default emoji presentation character (Emoji_Presentation)
\u{2194}\u{FE0F}: ↔️ default text presentation character rendered as emoji
\u{1F469}: 👩 emoji modifier base (Emoji_Modifier_Base)
\u{1F469}\u{1F3FF}: 👩🏿 emoji modifier base followed by a modifier
`;
const data = m(text);
// data.emojiPos.length === 8
<details>
<summary> <b>data</b> details </summary>
data.emojiIdx
//
data.emojiIdx ==
{
'1': true,
'4': true,
'64': true,
'68': true,
'125': true,
'129': true,
'174': true,
'180': true,
};
data.emojiPos
const emojiPos = [
{
emoji: '⌚',
len: 1,
pos: 1,
},
{
emoji: '⌚',
len: 1,
pos: 4,
},
{
emoji: '↔️',
len: 1,
pos: 64,
},
{
emoji: '↔️',
len: 1,
pos: 68,
},
{
emoji: '👩',
len: 1,
pos: 125,
},
{
emoji: '👩',
len: 1,
pos: 129,
},
{
emoji: '👩🏿',
len: 1,
pos: 174,
},
{
emoji: '👩🏿',
len: 1,
pos: 180,
},
];
the emoji length
diff Between node
with Browser
</details>
API
emojiStrPosition(str) : data
str
name: | str |
---|
Type: | string |
Desc: | str with/out emoji. |
data
emojiPos
name: | emojipos |
---|
Type: | Array |
Opt: | emoji: <source emoji> |
Opt: | len :< emoji length> |
Opt: | pos :< emoji in str index> |
emojiIdx
name: | emojiIdx |
---|
Type: | Object |
Opt: | index : true |
Desc:index : | each emoji from pos to pos+len, be true emojiIdx[pos...(pos+len)] = true |
concat
- emoji-regex A regular expression to match all Emoji-only symbols as per the Unicode Standard.
Use by
License
MIT © chinanf-boy