nberlette/emoji

📦  ES6, CJS, and JSON

View project on GitHub

Jump To:  ·•· Example Fiddle ·•· Installation ·•· Integration ·•· Command Line Interface ·•·


· · ·


🌍  Using with Content Delivery Networks (CDNs)

Thanks to wonderful services like unpkg, jsdelivr, and esm.run, you can use packages like this without adding any dependencies to your project! (preferably only in your development environment)

🔗  unpkg.com/@nberlette/emoji

🔗  cdn.jsdelivr.net/npm/@nberlette/emoji

🆕  esm.run/@nberlette/emoji


· · ·


🧪  Example using esm.run



· · ·


💿  Install as a Dependency

Pick your flavor of package manager (I like pnpm, followed closely by yarn)

pnpm add @nberlette/emoji
yarn add @nberlette/emoji
npm i --save @nberlette/emoji

· · ·


🔘  Integrate with your project

There’s two distinctive styles of code to choose from, depending on your project’s configuration.

🅰️  ES6 (import): used by Next.js, React, Svelte, Babel …

Works with default (any name), named (must be emoji), and aliased (assign a new name):

// default
import nicksEmojiLib from '@nberlette/emoji';
// named 
import { emoji } from '@nberlette/emoji';
// aliased
import { emoji as emojiAlias } from '@nberlette/emoji';

· · ·

🅱️  CommonJS (require): used by Node.js, RunKit, …

CommonJS “equivalents” for default, named, and aliased imports:

// default
const myEmojiLib = require('@nberlette/emoji').default;
// named
const { emoji } = require('@nberlette/emoji');
// aliased
const { emoji: myEmojiAlias } = require('@nberlette/emoji');

Please note the quotes around “equivalents”.
require is a far cry from import, both in terms of functionality, and level of community support. CommonJS also forces us to include entire modules, even when we only need a couple lines of code.

Furthermore, ES modules can allow 🔗 tree-shaking and 🔗 code splitting.
Just some food for thought. I’ll let you be the judge 😉


· · ·


📺  Command Line Interface

Before using the emoji command in your terminal, you’ll first need to globally install it:

💿 Global installation

yarn global add @nberlette/emoji
pnpm add -g @nberlette/emoji
npm i -g @nberlette/emoji

🔘  Usage & Syntax

$ emoji [keyword]
⚠️  Warning: if keyword is left blank, it currently prints all emojis.
  • Exact match: returns just the emoji for keyword
  • Single result: returns the emoji + keyword (or shortcode)
  • Many results: returns emoji, keyword pair for each matching entry


MIT · © 2021+ Nicholas Berlette



🔝