Skip to content

Commit e2856d9

Browse files
fix: add back CJS support, with a test
1 parent 6714e21 commit e2856d9

5 files changed

Lines changed: 28 additions & 19 deletions

File tree

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
"type": "module",
3030
"exports": {
3131
".": {
32+
"types": {
33+
"import": "./lib/index.d.ts",
34+
"require": "./lib/index.d.cts"
35+
},
3236
"import": "./lib/index.js",
3337
"require": "./lib/index.cjs"
3438
}
@@ -58,8 +62,8 @@
5862
"*": "prettier --ignore-unknown --write"
5963
},
6064
"dependencies": {
61-
"@sindresorhus/is": "^6.0.0",
62-
"char-regex": "^2.0.0",
65+
"@sindresorhus/is": "^4.6.0",
66+
"char-regex": "^1.0.2",
6367
"emojilib": "^2.4.0",
6468
"skin-tone": "^2.0.0"
6569
},

pnpm-lock.yaml

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/e2e.test.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const { strict: assert } = require('node:assert')
2+
3+
const emoji = require('../lib/index.cjs')
4+
5+
assert.equal(emoji.emojify(':wave:'), '👋')

src/emojify.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert, default as is } from '@sindresorhus/is'
1+
import is from '@sindresorhus/is'
22

33
import { findByName } from './findByName.js'
44
import { asFunction, normalizeName } from './utils.js'
@@ -21,9 +21,9 @@ export const emojify = (
2121
const fallbackFunction =
2222
fallback === undefined ? fallback : asFunction(fallback)
2323

24-
assert.string(input)
25-
assert.any([is.undefined, is.function], fallbackFunction)
26-
assert.function(format)
24+
is.assert.string(input)
25+
is.assert.any([is.default.undefined, is.default.function_], fallbackFunction)
26+
is.assert.function_(format)
2727

2828
return input.replace(/:[\w\-+]+:/g, part => {
2929
const found = findByName(part)

src/replace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const replace = (
1818
const replace = asFunction(replacement)
1919

2020
assert.string(input)
21-
assert.function(replace)
21+
assert.function_(replace)
2222
assert.boolean(preserveSpaces)
2323

2424
const characters = input.match(charRegexMatcher)

0 commit comments

Comments
 (0)