2
0
mirror of https://github.com/iconify/iconify.git synced 2024-11-09 23:00:56 +00:00

chore(utils): rename function to get qualified emoji variations

This commit is contained in:
Vjacheslav Trushkin 2022-12-15 11:58:57 +02:00
parent 5a78469fdb
commit c25750a0e0
5 changed files with 12 additions and 12 deletions

View File

@ -1,6 +1,6 @@
import { getEmojiSequenceFromString } from '../cleanup'; import { getEmojiSequenceFromString } from '../cleanup';
import { convertEmojiSequenceToUTF32 } from '../convert'; import { convertEmojiSequenceToUTF32 } from '../convert';
import { addOptionalEmojiVariations } from '../test/variations'; import { addQualifiedEmojiVariations } from '../test/variations';
import { createEmojisTree, parseEmojiTree } from './tree'; import { createEmojisTree, parseEmojiTree } from './tree';
/** /**
@ -46,7 +46,7 @@ export function createOptimisedRegex(
); );
// Add variations // Add variations
sequences = addOptionalEmojiVariations(sequences, testData); sequences = addQualifiedEmojiVariations(sequences, testData);
// Parse // Parse
return createOptimisedRegexForEmojiSequences(sequences); return createOptimisedRegexForEmojiSequences(sequences);

View File

@ -10,7 +10,7 @@ type EmojiStatus =
| 'fully-qualified' | 'fully-qualified'
| 'minimally-qualified' | 'minimally-qualified'
| 'unqualified'; | 'unqualified';
const componentStatus: EmojiStatus = 'component'; export const componentStatus: EmojiStatus = 'component';
// Allowed status values, in order of conversion // Allowed status values, in order of conversion
const allowedStatus: Set<EmojiStatus> = new Set([ const allowedStatus: Set<EmojiStatus> = new Set([

View File

@ -37,7 +37,7 @@ export function guessQualifiedEmojiSequence(sequence: number[]): number[] {
} }
/** /**
* Add optional variations to emojis * Add qualified variations to emojis
* *
* Also converts list to UTF-32 as needed * Also converts list to UTF-32 as needed
* *
@ -45,16 +45,16 @@ export function guessQualifiedEmojiSequence(sequence: number[]): number[] {
* If missing or emoji is missing in test data, `FE0F` is added to every single code emoji. * If missing or emoji is missing in test data, `FE0F` is added to every single code emoji.
* It can also be an array of sequences. * It can also be an array of sequences.
*/ */
export function addOptionalEmojiVariations( export function addQualifiedEmojiVariations(
sequences: number[][], sequences: number[][],
testData?: (number[] | EmojiTestDataItem)[] testData?: (number[] | EmojiTestDataItem)[]
): number[][]; ): number[][];
export function addOptionalEmojiVariations( export function addQualifiedEmojiVariations(
sequences: number[][], sequences: number[][],
testData: (number[] | EmojiTestDataItem)[], testData: (number[] | EmojiTestDataItem)[],
toString: (value: number[]) => string toString: (value: number[]) => string
): string[]; ): string[];
export function addOptionalEmojiVariations( export function addQualifiedEmojiVariations(
sequences: number[][], sequences: number[][],
testData: (number[] | EmojiTestDataItem)[] = [], testData: (number[] | EmojiTestDataItem)[] = [],
toString?: (value: number[]) => string toString?: (value: number[]) => string

View File

@ -105,7 +105,7 @@ export {
parseEmojiTestFile, parseEmojiTestFile,
getQualifiedEmojiSequencesMap, getQualifiedEmojiSequencesMap,
} from './emoji/test/parse'; } from './emoji/test/parse';
export { addOptionalEmojiVariations } from './emoji/test/variations'; export { addQualifiedEmojiVariations as addOptionalEmojiVariations } from './emoji/test/variations';
export { export {
createOptimisedRegex, createOptimisedRegex,
createOptimisedRegexForEmojiSequences, createOptimisedRegexForEmojiSequences,

View File

@ -5,9 +5,9 @@ import {
getQualifiedEmojiSequencesMap, getQualifiedEmojiSequencesMap,
parseEmojiTestFile, parseEmojiTestFile,
} from '../lib/emoji/test/parse'; } from '../lib/emoji/test/parse';
import { addOptionalEmojiVariations } from '../lib/emoji/test/variations'; import { addQualifiedEmojiVariations } from '../lib/emoji/test/variations';
describe('Optional variations of emoji sequences', () => { describe('Qualified variations of emoji sequences', () => {
it('Variations without data', () => { it('Variations without data', () => {
const sequences = [ const sequences = [
// simple emoji, twice to check duplicates // simple emoji, twice to check duplicates
@ -27,7 +27,7 @@ describe('Optional variations of emoji sequences', () => {
'1F9D7 1F3FE 200D 2640 FE0F', '1F9D7 1F3FE 200D 2640 FE0F',
'1F9D7 1F3FF 200D 2642 ', '1F9D7 1F3FF 200D 2642 ',
].map(getEmojiSequenceFromString); ].map(getEmojiSequenceFromString);
const results = addOptionalEmojiVariations(sequences); const results = addQualifiedEmojiVariations(sequences);
expect( expect(
results.map((sequence) => results.map((sequence) =>
getEmojiSequenceString(sequence, { getEmojiSequenceString(sequence, {
@ -124,7 +124,7 @@ describe('Optional variations of emoji sequences', () => {
// fake keycap, not in test file // fake keycap, not in test file
'2345 20E3 200D 1235', '2345 20E3 200D 1235',
].map(getEmojiSequenceFromString); ].map(getEmojiSequenceFromString);
const results = addOptionalEmojiVariations( const results = addQualifiedEmojiVariations(
sequences, sequences,
testDataSequences testDataSequences
); );