How to use the term-img.string function in term-img

To help you get started, we’ve selected a few term-img examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dongy7 / twitch-chat-cli / cli.js View on Github external
emotes.forEach(emote => {
      const { id, code } = emote
      const img = termImg.string(path.join(IMAGES_DIR, `${id}.png`))
      map[code] = img
    })
  })
github freaktechnik / twitch-chatlog / lib / index.js View on Github external
return stringReplaceAsync(f.text, /(^|\b)([0-9a-z]+[a-z])(\d+)(\b|$)/g, async (match, prefix, type, amount, postfix) => {
                        if(cheerEmoteList.includes(type)) {
                            const tier = getCheerTier(type, amount, cheerEmotes);
                            if(loadImages) {
                                const emote = await getCheerEmote(type, tier);
                                return prefix + termImg.string(emote, {
                                    fallback: () => cheers.formatCheer(amount, tier.color)
                                }) + chalk.bold.hex(tier.color)(amount) + postfix;
                            }
                            return prefix + cheers.formatCheer(amount, tier.color) + postfix;
                        }
                        return match;
                    });
                }
github sindresorhus / terminal-image / index.js View on Github external
exports.buffer = async buffer => {
	return termImg.string(buffer, {
		width: '100%',
		height: '100%',
		fallback: () => render(buffer)
	});
};
github freaktechnik / twitch-chatlog / lib / index.js View on Github external
const frags = await Promise.all(msg.message.fragments.map(async (f) => {
                if(f.emoticon && loadImages) {
                    const emote = await getEmoticon(f.emoticon.emoticon_id);
                    return termImg.string(emote, {
                        fallback: () => f.text
                    });
                }
                else if(msg.message.bits_spent) {
                    return stringReplaceAsync(f.text, /(^|\b)([0-9a-z]+[a-z])(\d+)(\b|$)/g, async (match, prefix, type, amount, postfix) => {
                        if(cheerEmoteList.includes(type)) {
                            const tier = getCheerTier(type, amount, cheerEmotes);
                            if(loadImages) {
                                const emote = await getCheerEmote(type, tier);
                                return prefix + termImg.string(emote, {
                                    fallback: () => cheers.formatCheer(amount, tier.color)
                                }) + chalk.bold.hex(tier.color)(amount) + postfix;
                            }
                            return prefix + cheers.formatCheer(amount, tier.color) + postfix;
                        }
                        return match;

term-img

Display images in iTerm

MIT
Latest version published 5 months ago

Package Health Score

70 / 100
Full package analysis

Popular term-img functions