export function parse()

in src/index.js [20:50]


export function parse(text: string, options?: ParsingOptions): Array<EmojiEntity> {
  const assetType = options && options.assetType ? options.assetType : 'svg';
  const getTwemojiUrl =
    options && options.buildUrl
      ? options.buildUrl
      : (codepoints, assetType) =>
          assetType === 'png'
            ? `https://twemoji.maxcdn.com/v/latest/72x72/${codepoints}.png`
            : `https://twemoji.maxcdn.com/v/latest/svg/${codepoints}.svg`;

  const entities = [];

  emojiRegex.lastIndex = 0;
  while (true) {
    const result = emojiRegex.exec(text);
    if (!result) {
      break;
    }

    const emojiText = result[0];
    const codepoints = toCodePoints(removeVS16s(emojiText)).join('-');

    entities.push({
      url: codepoints ? getTwemojiUrl(codepoints, assetType) : '',
      indices: [result.index, emojiRegex.lastIndex],
      text: emojiText,
      type: TypeName
    });
  }
  return entities;
}