@involvex/emoji-cli 2.2.5 → 2.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bin/emoji-cli-improved.cjs +602 -0
- package/lib/bin/emoji-cli-improved.cjs.map +1 -0
- package/lib/bin/emoji-cli-improved.d.cts +4 -0
- package/lib/bin/emoji-cli-improved.d.ts +4 -0
- package/lib/bin/emoji-cli-improved.js +440 -0
- package/lib/bin/emoji-cli-improved.js.map +1 -0
- package/lib/{index.js → chunk-DT5PQCNR.js} +11 -10
- package/lib/chunk-DT5PQCNR.js.map +1 -0
- package/lib/{index.cjs → src/index.cjs} +10 -10
- package/lib/src/index.cjs.map +1 -0
- package/lib/src/index.js +25 -0
- package/lib/src/index.js.map +1 -0
- package/package.json +3 -3
- package/src/emojify.ts +3 -3
- package/src/search.ts +4 -4
- package/bin/emoji-cli-improved.ts +0 -422
- package/lib/index.cjs.map +0 -1
- package/lib/index.js.map +0 -1
- /package/lib/{index.d.cts → src/index.d.cts} +0 -0
- /package/lib/{index.d.ts → src/index.d.ts} +0 -0
package/lib/src/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
emojify,
|
|
3
|
+
find,
|
|
4
|
+
get,
|
|
5
|
+
has,
|
|
6
|
+
random,
|
|
7
|
+
replace,
|
|
8
|
+
search,
|
|
9
|
+
strip,
|
|
10
|
+
unemojify,
|
|
11
|
+
which
|
|
12
|
+
} from "../chunk-DT5PQCNR.js";
|
|
13
|
+
export {
|
|
14
|
+
emojify,
|
|
15
|
+
find,
|
|
16
|
+
get,
|
|
17
|
+
has,
|
|
18
|
+
random,
|
|
19
|
+
replace,
|
|
20
|
+
search,
|
|
21
|
+
strip,
|
|
22
|
+
unemojify,
|
|
23
|
+
which
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@involvex/emoji-cli",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "Friendly emoji lookups and parsing utilities for Node.js. 💖",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"emoji",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"main": "./lib/index.js",
|
|
40
40
|
"bin": {
|
|
41
|
-
"emoji-cli": "bin/emoji-cli-improved.
|
|
41
|
+
"emoji-cli": "lib/bin/emoji-cli-improved.js"
|
|
42
42
|
},
|
|
43
43
|
"files": [
|
|
44
44
|
"lib/",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"lint:spelling": "cspell \"**\" \".github/**/*\"",
|
|
62
62
|
"prepare": "husky install",
|
|
63
63
|
"should-semantic-release": "should-semantic-release --verbose",
|
|
64
|
-
"start": "node
|
|
64
|
+
"start": "node lib/bin/emoji-cli-improved.js",
|
|
65
65
|
"test": "vitest",
|
|
66
66
|
"test:cjs": "node ./src/e2e.cjs",
|
|
67
67
|
"tsc": "tsc"
|
package/src/emojify.ts
CHANGED
|
@@ -31,9 +31,9 @@ export const emojify = (
|
|
|
31
31
|
const fallbackFunction =
|
|
32
32
|
fallback === undefined ? fallback : asFunction(fallback)
|
|
33
33
|
|
|
34
|
-
is.
|
|
35
|
-
is.
|
|
36
|
-
is.
|
|
34
|
+
is.string(input)
|
|
35
|
+
is.any([is.undefined, is.function_], fallbackFunction)
|
|
36
|
+
is.function_(format)
|
|
37
37
|
|
|
38
38
|
return input.replace(/:[\w\-+]+:/g, part => {
|
|
39
39
|
const found = findByName(part)
|
package/src/search.ts
CHANGED
|
@@ -7,14 +7,14 @@ import { normalizeName } from './utils.js'
|
|
|
7
7
|
* Search for emojis containing the provided name or pattern in their name.
|
|
8
8
|
*/
|
|
9
9
|
export const search = (keyword: RegExp | string) => {
|
|
10
|
-
assert.any([is.
|
|
10
|
+
assert.any([is.string, is.regExp], keyword)
|
|
11
11
|
|
|
12
|
-
if (is.
|
|
12
|
+
if (is.string(keyword)) {
|
|
13
13
|
keyword = normalizeName(keyword)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
if (is.
|
|
17
|
-
const normalizedPattern = normalizeName(keyword.
|
|
16
|
+
if (is.regExp(keyword)) {
|
|
17
|
+
const normalizedPattern = normalizeName(keyword.toString())
|
|
18
18
|
keyword = new RegExp(normalizedPattern)
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -1,422 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import * as cli from '../lib/index.js'
|
|
4
|
-
|
|
5
|
-
// Type definitions for better type safety
|
|
6
|
-
interface CLIConfig {
|
|
7
|
-
name: string
|
|
8
|
-
description: string
|
|
9
|
-
version: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface Command {
|
|
13
|
-
name: string
|
|
14
|
-
aliases: string[]
|
|
15
|
-
description: string
|
|
16
|
-
handler: (args?: string) => void | Promise<void>
|
|
17
|
-
requiresArgs: boolean
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface ParsedArgs {
|
|
21
|
-
command: string
|
|
22
|
-
args: string[]
|
|
23
|
-
help: boolean
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Configuration
|
|
27
|
-
const CONFIG: CLIConfig = {
|
|
28
|
-
name: 'emoji-cli',
|
|
29
|
-
description: 'Friendly emoji lookups and parsing utilities for Node.js',
|
|
30
|
-
version: '2.2.3', // TODO: Get version from package.json dynamically
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Available commands
|
|
34
|
-
const COMMANDS: Command[] = [
|
|
35
|
-
{
|
|
36
|
-
name: 'search',
|
|
37
|
-
aliases: ['--search'],
|
|
38
|
-
description: 'Search for emojis by name or pattern',
|
|
39
|
-
handler: runSearch,
|
|
40
|
-
requiresArgs: true,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'emojify',
|
|
44
|
-
aliases: ['--emojify'],
|
|
45
|
-
description: 'Convert text to emojis',
|
|
46
|
-
handler: runEmojify,
|
|
47
|
-
requiresArgs: true,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'unemojify',
|
|
51
|
-
aliases: ['--unemojify'],
|
|
52
|
-
description: 'Convert emojis back to text',
|
|
53
|
-
handler: runUnemojify,
|
|
54
|
-
requiresArgs: true,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'get',
|
|
58
|
-
aliases: ['--get'],
|
|
59
|
-
description: 'Get a specific emoji by name',
|
|
60
|
-
handler: runGet,
|
|
61
|
-
requiresArgs: true,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'has',
|
|
65
|
-
aliases: ['--has'],
|
|
66
|
-
description: 'Check if an emoji exists',
|
|
67
|
-
handler: runHas,
|
|
68
|
-
requiresArgs: true,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: 'find',
|
|
72
|
-
aliases: ['--find', '-f'],
|
|
73
|
-
description: 'Find emojis by name',
|
|
74
|
-
handler: runFind,
|
|
75
|
-
requiresArgs: true,
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: 'random',
|
|
79
|
-
aliases: ['--random', '--rnd', '-r'],
|
|
80
|
-
description: 'Get a random emoji',
|
|
81
|
-
handler: runRandom,
|
|
82
|
-
requiresArgs: false,
|
|
83
|
-
},
|
|
84
|
-
]
|
|
85
|
-
|
|
86
|
-
// Error handling
|
|
87
|
-
class CLIError extends Error {
|
|
88
|
-
code: number
|
|
89
|
-
|
|
90
|
-
constructor(message: string, code: number) {
|
|
91
|
-
super(message)
|
|
92
|
-
this.code = code
|
|
93
|
-
this.name = 'CLIError'
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
class ValidationError extends CLIError {
|
|
98
|
-
constructor(message: string) {
|
|
99
|
-
super(message, 2)
|
|
100
|
-
this.name = 'ValidationError'
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Utility functions
|
|
105
|
-
function createOutputFormatter() {
|
|
106
|
-
return {
|
|
107
|
-
success: (
|
|
108
|
-
data:
|
|
109
|
-
| never
|
|
110
|
-
| string
|
|
111
|
-
| {
|
|
112
|
-
emoji: string
|
|
113
|
-
name?: string
|
|
114
|
-
key?: string
|
|
115
|
-
}
|
|
116
|
-
| (
|
|
117
|
-
| string
|
|
118
|
-
| {
|
|
119
|
-
emoji: string
|
|
120
|
-
name?: string
|
|
121
|
-
key?: string
|
|
122
|
-
}
|
|
123
|
-
)[],
|
|
124
|
-
) => {
|
|
125
|
-
if (Array.isArray(data)) {
|
|
126
|
-
if (data.length === 0) {
|
|
127
|
-
console.log('No results found')
|
|
128
|
-
return
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
data.forEach((item, index) => {
|
|
132
|
-
if (typeof item === 'string') {
|
|
133
|
-
console.log(`${item}`)
|
|
134
|
-
} else if (item && typeof item === 'object') {
|
|
135
|
-
const displayName = item.name || item.key || 'unknown'
|
|
136
|
-
console.log(`${index + 1}. ${item.emoji} ${displayName}`)
|
|
137
|
-
} else {
|
|
138
|
-
console.log(`${index + 1}. ${item}`)
|
|
139
|
-
}
|
|
140
|
-
})
|
|
141
|
-
} else if (data && typeof data === 'object') {
|
|
142
|
-
const displayName = data.name || data.key || 'unknown'
|
|
143
|
-
console.log(`${data.emoji} ${displayName}`)
|
|
144
|
-
} else if (data !== undefined && data !== null) {
|
|
145
|
-
console.log(data)
|
|
146
|
-
} else {
|
|
147
|
-
console.log('No result found')
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
error: (message: string) => {
|
|
151
|
-
console.error(`❌ Error: ${message}`)
|
|
152
|
-
},
|
|
153
|
-
warning: (message: string) => {
|
|
154
|
-
console.warn(`⚠️ Warning: ${message}`)
|
|
155
|
-
},
|
|
156
|
-
info: (message: string) => {
|
|
157
|
-
console.log(`ℹ️ ${message}`)
|
|
158
|
-
},
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const output = createOutputFormatter()
|
|
163
|
-
|
|
164
|
-
// Argument parsing
|
|
165
|
-
function parseArgs(args: string[]): ParsedArgs {
|
|
166
|
-
if (args.length === 0) {
|
|
167
|
-
return { command: '', args: [], help: true }
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const [first, ...rest] = args
|
|
171
|
-
|
|
172
|
-
// Check for help flags
|
|
173
|
-
if (first === '--help' || first === '-h') {
|
|
174
|
-
return { command: '', args: [], help: true }
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
command: first,
|
|
179
|
-
args: rest,
|
|
180
|
-
help: false,
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Command resolution
|
|
185
|
-
function resolveCommand(input: string): Command | null {
|
|
186
|
-
if (!input) {
|
|
187
|
-
return null
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return (
|
|
191
|
-
COMMANDS.find(cmd => cmd.name === input || cmd.aliases.includes(input)) ||
|
|
192
|
-
null
|
|
193
|
-
)
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Validation
|
|
197
|
-
function validateArgs(command: Command, args: string[]): void {
|
|
198
|
-
if (command.requiresArgs && args.length === 0) {
|
|
199
|
-
throw new ValidationError(`Command "${command.name}" requires arguments`)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (!command.requiresArgs && args.length > 0) {
|
|
203
|
-
throw new ValidationError(
|
|
204
|
-
`Command "${command.name}" does not accept arguments`,
|
|
205
|
-
)
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Command handlers
|
|
210
|
-
async function runSearch(query?: string): Promise<void> {
|
|
211
|
-
if (!query) {
|
|
212
|
-
throw new ValidationError('Search query is required')
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
try {
|
|
216
|
-
const results = cli.search(query)
|
|
217
|
-
output.success(results)
|
|
218
|
-
} catch (error) {
|
|
219
|
-
output.error(
|
|
220
|
-
`Failed to search for "${query}": ${
|
|
221
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
222
|
-
}`,
|
|
223
|
-
)
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
async function runEmojify(text?: string): Promise<void> {
|
|
228
|
-
if (!text) {
|
|
229
|
-
throw new ValidationError('Text to emojify is required')
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
try {
|
|
233
|
-
const result = cli.emojify(text)
|
|
234
|
-
output.success(result)
|
|
235
|
-
} catch (error) {
|
|
236
|
-
output.error(
|
|
237
|
-
`Failed to emojify text: ${
|
|
238
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
239
|
-
}`,
|
|
240
|
-
)
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
async function runUnemojify(text?: string): Promise<void> {
|
|
245
|
-
if (!text) {
|
|
246
|
-
throw new ValidationError('Text to unemojify is required')
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
try {
|
|
250
|
-
const result = cli.unemojify(text)
|
|
251
|
-
output.success(result)
|
|
252
|
-
} catch (error) {
|
|
253
|
-
output.error(
|
|
254
|
-
`Failed to unemojify text: ${
|
|
255
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
256
|
-
}`,
|
|
257
|
-
)
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
async function runGet(name?: string): Promise<void> {
|
|
262
|
-
if (!name) {
|
|
263
|
-
throw new ValidationError('Emoji name is required')
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
try {
|
|
267
|
-
const result = cli.get(name)
|
|
268
|
-
if (result) {
|
|
269
|
-
output.success(result)
|
|
270
|
-
} else {
|
|
271
|
-
output.warning(`Emoji "${name}" not found`)
|
|
272
|
-
}
|
|
273
|
-
} catch (error) {
|
|
274
|
-
output.error(
|
|
275
|
-
`Failed to get emoji "${name}": ${
|
|
276
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
277
|
-
}`,
|
|
278
|
-
)
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
async function runHas(name?: string): Promise<void> {
|
|
283
|
-
if (!name) {
|
|
284
|
-
throw new ValidationError('Emoji name is required')
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
try {
|
|
288
|
-
const result = cli.has(name)
|
|
289
|
-
output.success(
|
|
290
|
-
result ? `✅ Emoji "${name}" exists` : `❌ Emoji "${name}" not found`,
|
|
291
|
-
)
|
|
292
|
-
} catch (error) {
|
|
293
|
-
output.error(
|
|
294
|
-
`Failed to check emoji "${name}": ${
|
|
295
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
296
|
-
}`,
|
|
297
|
-
)
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
async function runFind(name?: string): Promise<void> {
|
|
302
|
-
if (!name) {
|
|
303
|
-
throw new ValidationError('Search term is required')
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
try {
|
|
307
|
-
const result = cli.find(name)
|
|
308
|
-
if (result) {
|
|
309
|
-
output.success(result)
|
|
310
|
-
} else {
|
|
311
|
-
output.warning(`No emojis found for "${name}"`)
|
|
312
|
-
}
|
|
313
|
-
} catch (error) {
|
|
314
|
-
output.error(
|
|
315
|
-
`Failed to find emojis for "${name}": ${
|
|
316
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
317
|
-
}`,
|
|
318
|
-
)
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
async function runRandom(): Promise<void> {
|
|
323
|
-
try {
|
|
324
|
-
const result = cli.random()
|
|
325
|
-
output.success(result)
|
|
326
|
-
} catch (error) {
|
|
327
|
-
output.error(
|
|
328
|
-
`Failed to get random emoji: ${
|
|
329
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
330
|
-
}`,
|
|
331
|
-
)
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// Help and usage information
|
|
336
|
-
function showHelp(): void {
|
|
337
|
-
console.log(`${CONFIG.name} v${CONFIG.version}`)
|
|
338
|
-
console.log(`${CONFIG.description} 💖`)
|
|
339
|
-
console.log('\nUsage:')
|
|
340
|
-
console.log(` ${CONFIG.name} <command> [arguments]`)
|
|
341
|
-
console.log('\nCommands:')
|
|
342
|
-
|
|
343
|
-
COMMANDS.forEach(cmd => {
|
|
344
|
-
const aliasesText =
|
|
345
|
-
cmd.aliases.length > 1 ? ` (${cmd.aliases.join(', ')})` : ''
|
|
346
|
-
console.log(` ${cmd.name}${aliasesText} ${cmd.description}`)
|
|
347
|
-
})
|
|
348
|
-
|
|
349
|
-
console.log('\nExamples:')
|
|
350
|
-
console.log(` ${CONFIG.name} --search "heart"`)
|
|
351
|
-
console.log(` ${CONFIG.name} --get "heart"`)
|
|
352
|
-
console.log(` ${CONFIG.name} --emojify "I love you"`)
|
|
353
|
-
console.log(` ${CONFIG.name} --random`)
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function showVersion(): void {
|
|
357
|
-
console.log(`${CONFIG.name} v${CONFIG.version}`)
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// Main execution
|
|
361
|
-
async function run(): Promise<void> {
|
|
362
|
-
try {
|
|
363
|
-
const args = process.argv.slice(2)
|
|
364
|
-
const { command: commandInput, args: commandArgs, help } = parseArgs(args)
|
|
365
|
-
|
|
366
|
-
// Handle global flags
|
|
367
|
-
if (help || !commandInput) {
|
|
368
|
-
showHelp()
|
|
369
|
-
return
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
if (commandInput === '--version' || commandInput === '-v') {
|
|
373
|
-
showVersion()
|
|
374
|
-
return
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// Resolve and execute command
|
|
378
|
-
const command = resolveCommand(commandInput)
|
|
379
|
-
if (!command) {
|
|
380
|
-
throw new CLIError(
|
|
381
|
-
`Unknown command: ${commandInput}. Use --help for available commands.`,
|
|
382
|
-
1,
|
|
383
|
-
)
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// Validate arguments
|
|
387
|
-
validateArgs(command, commandArgs)
|
|
388
|
-
|
|
389
|
-
// Execute command
|
|
390
|
-
await command.handler(commandArgs[0])
|
|
391
|
-
} catch (error) {
|
|
392
|
-
if (error instanceof CLIError) {
|
|
393
|
-
output.error(error.message)
|
|
394
|
-
process.exit(error.code)
|
|
395
|
-
} else if (error instanceof ValidationError) {
|
|
396
|
-
output.error(error.message)
|
|
397
|
-
output.info('Use --help for usage information')
|
|
398
|
-
process.exit(error.code)
|
|
399
|
-
} else {
|
|
400
|
-
output.error(
|
|
401
|
-
`Unexpected error: ${
|
|
402
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
403
|
-
}`,
|
|
404
|
-
)
|
|
405
|
-
process.exit(1)
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// Execute if this file is run directly
|
|
411
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
412
|
-
run().catch(error => {
|
|
413
|
-
output.error(
|
|
414
|
-
`Failed to run CLI: ${
|
|
415
|
-
error instanceof Error ? error.message : 'Unknown error'
|
|
416
|
-
}`,
|
|
417
|
-
)
|
|
418
|
-
process.exit(1)
|
|
419
|
-
})
|
|
420
|
-
}
|
|
421
|
-
run()
|
|
422
|
-
export default run
|
package/lib/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/emojify.ts","../src/findByName.ts","../src/data.ts","../src/utils.ts","../src/findByCode.ts","../src/find.ts","../src/get.ts","../src/has.ts","../src/random.ts","../src/replace.ts","../src/search.ts","../src/strip.ts","../src/unemojify.ts","../src/which.ts"],"sourcesContent":["export * from './emojify.js'\nexport * from './find.js'\nexport * from './get.js'\nexport * from './has.js'\nexport * from './random.js'\nexport * from './replace.js'\nexport * from './search.js'\nexport * from './strip.js'\nexport * from './unemojify.js'\nexport * from './which.js'\n","import is from '@sindresorhus/is'\n\nimport { findByName } from './findByName.js'\nimport { asFunction, normalizeName } from './utils.js'\n\nexport type EmojifyFormat = (\n name: string,\n part?: string,\n input?: string,\n) => string\n\nexport interface EmojifyOptions {\n /**\n * The string to fallback to if an emoji was not found.\n */\n fallback?: ((part: string) => string) | string\n\n /**\n * Adds a middleware layer to modify each matched emoji after parsing.\n */\n format?: EmojifyFormat\n}\n\n/**\n * Parse all markdown-encoded emojis in a string.\n */\nexport const emojify = (\n input: string,\n { fallback, format = name => name }: EmojifyOptions = {},\n) => {\n const fallbackFunction =\n fallback === undefined ? fallback : asFunction(fallback)\n\n is.assert.string(input)\n is.assert.any([is.default.undefined, is.default.function_], fallbackFunction)\n is.assert.function_(format)\n\n return input.replace(/:[\\w\\-+]+:/g, part => {\n const found = findByName(part)\n if (found) {\n return format(found.emoji, part, input)\n }\n\n if (fallbackFunction) {\n return format(fallbackFunction(normalizeName(part)))\n }\n\n return format(part)\n })\n}\n","import { assert } from '@sindresorhus/is'\n\nimport { emojiCodesByName } from './data.js'\nimport { normalizeName } from './utils.js'\n\nexport const findByName = (name: string) => {\n assert.string(name)\n\n const nameNormalized = normalizeName(name)\n const emoji = emojiCodesByName.get(nameNormalized)\n\n return emoji ? { emoji, key: nameNormalized } : undefined\n}\n","import emojilib from 'emojilib'\n\nimport { normalizeCode } from './utils.js'\n\nexport interface Emoji {\n emoji: string\n key: string\n}\n\nexport const emojiData = Object.entries(emojilib.lib).map(\n ([name, { char: emoji }]) => [name, emoji] as const,\n)\n\nexport const emojiCodesByName = new Map(emojiData)\n\nexport const emojiNamesByCode = new Map(\n emojiData.map(([name, emoji]) => [normalizeCode(emoji), name]),\n)\n","import charRegex from 'char-regex'\n\nexport const charRegexMatcher = charRegex()\n\nexport function asFunction<T extends PropertyKey, Args extends unknown[]>(\n input: ((...args: Args) => T) | T,\n): (...args: Args) => T {\n return typeof input === 'function' ? input : () => input\n}\n\n/**\n * Non spacing mark contained by some emoticons (65039 - '️' - 0xFE0F).\n *\n * It's the 'Variant Form', which provides more information so that emoticons\n * can be rendered as more colorful graphics. FE0E is a unicode text version\n * whereas FE0F should be rendered as a graphical version.\n * The code gracefully degrades.\n */\nconst NON_SPACING_MARK = String.fromCharCode(65039)\n\nconst nonSpacingRegex = new RegExp(NON_SPACING_MARK, 'g')\n\n/**\n * Removes the non-spacing-mark from the emoji code.\n *\n * Never send a stripped version to clients, as it kills graphical emoticons.\n */\nexport function normalizeCode(code: string) {\n return code.replace(nonSpacingRegex, '')\n}\n\nexport function normalizeName(name: string) {\n return /:.+:/.test(name) ? name.slice(1, -1) : name\n}\n\nexport function randomItem<T>(array: T[]) {\n return array[Math.floor(Math.random() * array.length)]\n}\n","import { assert } from '@sindresorhus/is'\n\nimport { emojiNamesByCode } from './data.js'\nimport { normalizeCode } from './utils.js'\n\nexport const findByCode = (code: string) => {\n assert.string(code)\n\n const emojiNormalized = normalizeCode(code)\n const key = emojiNamesByCode.get(emojiNormalized)\n\n return key ? { emoji: emojiNormalized, key } : undefined\n}\n","import { findByCode } from './findByCode.js'\nimport { findByName } from './findByName.js'\n\n/**\n * Get the name and character of an emoji.\n */\nexport const find = (codeOrName: string) => {\n return findByCode(codeOrName) ?? findByName(codeOrName)\n}\n","import { assert } from '@sindresorhus/is'\n\nimport { emojiCodesByName } from './data.js'\nimport { normalizeName } from './utils.js'\n\n/**\n * Get an emoji from an emoji name.\n */\nexport const get = (codeOrName: string) => {\n assert.string(codeOrName)\n\n return emojiCodesByName.get(normalizeName(codeOrName))\n}\n","import { assert } from '@sindresorhus/is'\n\nimport { emojiCodesByName, emojiNamesByCode } from './data.js'\nimport { normalizeCode, normalizeName } from './utils.js'\n\n/**\n * Check if this library supports a specific emoji.\n */\nexport const has = (codeOrName: string) => {\n assert.string(codeOrName)\n\n return (\n emojiCodesByName.has(normalizeName(codeOrName)) ||\n emojiNamesByCode.has(normalizeCode(codeOrName))\n )\n}\n","import { emojiData } from './data.js'\nimport { randomItem } from './utils.js'\n\n/**\n * Get a random emoji.\n */\nexport const random = () => {\n const [name, emoji] = randomItem(emojiData)\n return { emoji, name }\n}\n","import { assert } from '@sindresorhus/is'\n\nimport { Emoji } from './data.js'\nimport { findByCode } from './findByCode.js'\nimport { asFunction, charRegexMatcher } from './utils.js'\n\nexport type ReplaceReplacement = (\n emoji: Emoji,\n index: number,\n string: string,\n) => string\n\n/**\n * Replace the emojis in a string.\n */\nexport const replace = (\n input: string,\n replacement: ReplaceReplacement | string,\n { preserveSpaces = false } = {},\n) => {\n const replace = asFunction(replacement)\n\n assert.string(input)\n assert.function_(replace)\n assert.boolean(preserveSpaces)\n\n const characters = input.match(charRegexMatcher)\n if (characters === null) {\n return input\n }\n\n return characters\n .map((character, index) => {\n const found = findByCode(character)\n if (!found) {\n return character\n }\n\n if (!preserveSpaces && characters[index + 1] === ' ') {\n characters[index + 1] = ''\n }\n\n return replace(found, index, input)\n })\n .join('')\n}\n","import is, { assert } from '@sindresorhus/is'\n\nimport { emojiData } from './data.js'\nimport { normalizeName } from './utils.js'\n\n/**\n * Search for emojis containing the provided name or pattern in their name.\n */\nexport const search = (keyword: RegExp | string) => {\n assert.any([is.default.string, is.default.regExp], keyword)\n\n if (is.default.string(keyword)) {\n keyword = normalizeName(keyword)\n }\n\n if (is.default.regExp(keyword)) {\n const normalizedPattern = normalizeName(keyword.source)\n keyword = new RegExp(normalizedPattern)\n }\n\n return emojiData\n .filter(([name]) => name.match(keyword))\n .map(([name, emoji]) => ({ emoji, name }))\n}\n","import { replace } from './replace.js'\n\nexport interface StripOptions {\n /**\n * Whether to keep the extra space after a stripped emoji.\n */\n preserveSpaces?: boolean\n}\n\n/**\n * Remove all the emojis from a string.\n */\nexport const strip = (input: string, { preserveSpaces }: StripOptions = {}) =>\n replace(input, '', { preserveSpaces })\n","import { assert } from '@sindresorhus/is'\n\nimport { charRegexMatcher } from './utils.js'\nimport { which } from './which.js'\n\n/**\n * Convert all emojis in a string to their markdown-encoded counterparts.\n */\nexport const unemojify = (input: string) => {\n assert.string(input)\n\n const characters = input.match(charRegexMatcher)\n if (characters === null) {\n return input\n }\n\n return characters\n .map(character => which(character, { markdown: true }) ?? character)\n .join('')\n}\n","import { assert } from '@sindresorhus/is'\nimport skinTone from 'skin-tone'\n\nimport { findByCode } from './findByCode.js'\n\nexport interface WhichOptions {\n markdown?: boolean\n}\n\n/**\n * Get an emoji name from an emoji.\n */\nexport const which = (\n emoji: string,\n { markdown = false }: WhichOptions = {},\n) => {\n assert.string(emoji)\n assert.boolean(markdown)\n\n const result = findByCode(skinTone(emoji, 'none'))\n if (result === undefined) {\n return undefined\n }\n\n return markdown ? `:${result.key}:` : result.key\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,aAAe;;;ACAf,gBAAuB;;;ACAvB,sBAAqB;;;ACArB,wBAAsB;AAEf,IAAM,uBAAmB,kBAAAC,SAAU;AAEnC,SAAS,WACd,OACsB;AACtB,SAAO,OAAO,UAAU,aAAa,QAAQ,MAAM;AACrD;AAUA,IAAM,mBAAmB,OAAO,aAAa,KAAK;AAElD,IAAM,kBAAkB,IAAI,OAAO,kBAAkB,GAAG;AAOjD,SAAS,cAAc,MAAc;AAC1C,SAAO,KAAK,QAAQ,iBAAiB,EAAE;AACzC;AAEO,SAAS,cAAc,MAAc;AAC1C,SAAO,OAAO,KAAK,IAAI,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;AACjD;AAEO,SAAS,WAAc,OAAY;AACxC,SAAO,MAAM,KAAK,MAAM,KAAK,OAAO,IAAI,MAAM,MAAM,CAAC;AACvD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AAI,CAAC,WAAAC,QAAG,QAAQ,QAAQ,WAAAA,QAAG,QAAQ,MAAM,GAAG,OAAO;AAE1D,MAAI,WAAAA,QAAG,QAAQ,OAAO,OAAO,GAAG;AAC9B,cAAU,cAAc,OAAO;AAAA,EACjC;AAEA,MAAI,WAAAA,QAAG,QAAQ,OAAO,OAAO,GAAG;AAC9B,UAAM,oBAAoB,cAAc,QAAQ,MAAM;AACtD,cAAU,IAAI,OAAO,iBAAiB;AAAA,EACxC;AAEA,SAAO,UACJ,OAAO,CAAC,CAAC,IAAI,MAAM,KAAK,MAAM,OAAO,CAAC,EACtC,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,EAAE,OAAO,KAAK,EAAE;AAC7C;;;ACXO,IAAM,QAAQ,CAAC,OAAe,EAAE,eAAe,IAAkB,CAAC,MACvE,QAAQ,OAAO,IAAI,EAAE,eAAe,CAAC;;;ACbvC,IAAAC,aAAuB;;;ACAvB,IAAAC,aAAuB;AACvB,uBAAqB;AAWd,IAAM,QAAQ,CACnB,OACA,EAAE,WAAW,MAAM,IAAkB,CAAC,MACnC;AACH,oBAAO,OAAO,KAAK;AACnB,oBAAO,QAAQ,QAAQ;AAEvB,QAAM,SAAS,eAAW,iBAAAC,SAAS,OAAO,MAAM,CAAC;AACjD,MAAI,WAAW,QAAW;AACxB,WAAO;AAAA,EACT;AAEA,SAAO,WAAW,IAAI,OAAO,GAAG,MAAM,OAAO;AAC/C;;;ADjBO,IAAM,YAAY,CAAC,UAAkB;AAC1C,oBAAO,OAAO,KAAK;AAEnB,QAAM,aAAa,MAAM,MAAM,gBAAgB;AAC/C,MAAI,eAAe,MAAM;AACvB,WAAO;AAAA,EACT;AAEA,SAAO,WACJ,IAAI,eAAa,MAAM,WAAW,EAAE,UAAU,KAAK,CAAC,KAAK,SAAS,EAClE,KAAK,EAAE;AACZ;","names":["import_is","charRegex","emojilib","is","import_is","import_is","import_is","import_is","replace","import_is","is","import_is","import_is","skinTone"]}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/emojify.ts","../src/findByName.ts","../src/data.ts","../src/utils.ts","../src/findByCode.ts","../src/find.ts","../src/get.ts","../src/has.ts","../src/random.ts","../src/replace.ts","../src/search.ts","../src/strip.ts","../src/unemojify.ts","../src/which.ts"],"sourcesContent":["import is from '@sindresorhus/is'\n\nimport { findByName } from './findByName.js'\nimport { asFunction, normalizeName } from './utils.js'\n\nexport type EmojifyFormat = (\n name: string,\n part?: string,\n input?: string,\n) => string\n\nexport interface EmojifyOptions {\n /**\n * The string to fallback to if an emoji was not found.\n */\n fallback?: ((part: string) => string) | string\n\n /**\n * Adds a middleware layer to modify each matched emoji after parsing.\n */\n format?: EmojifyFormat\n}\n\n/**\n * Parse all markdown-encoded emojis in a string.\n */\nexport const emojify = (\n input: string,\n { fallback, format = name => name }: EmojifyOptions = {},\n) => {\n const fallbackFunction =\n fallback === undefined ? fallback : asFunction(fallback)\n\n is.assert.string(input)\n is.assert.any([is.default.undefined, is.default.function_], fallbackFunction)\n is.assert.function_(format)\n\n return input.replace(/:[\\w\\-+]+:/g, part => {\n const found = findByName(part)\n if (found) {\n return format(found.emoji, part, input)\n }\n\n if (fallbackFunction) {\n return format(fallbackFunction(normalizeName(part)))\n }\n\n return format(part)\n })\n}\n","import { assert } from '@sindresorhus/is'\n\nimport { emojiCodesByName } from './data.js'\nimport { normalizeName } from './utils.js'\n\nexport const findByName = (name: string) => {\n assert.string(name)\n\n const nameNormalized = normalizeName(name)\n const emoji = emojiCodesByName.get(nameNormalized)\n\n return emoji ? { emoji, key: nameNormalized } : undefined\n}\n","import emojilib from 'emojilib'\n\nimport { normalizeCode } from './utils.js'\n\nexport interface Emoji {\n emoji: string\n key: string\n}\n\nexport const emojiData = Object.entries(emojilib.lib).map(\n ([name, { char: emoji }]) => [name, emoji] as const,\n)\n\nexport const emojiCodesByName = new Map(emojiData)\n\nexport const emojiNamesByCode = new Map(\n emojiData.map(([name, emoji]) => [normalizeCode(emoji), name]),\n)\n","import charRegex from 'char-regex'\n\nexport const charRegexMatcher = charRegex()\n\nexport function asFunction<T extends PropertyKey, Args extends unknown[]>(\n input: ((...args: Args) => T) | T,\n): (...args: Args) => T {\n return typeof input === 'function' ? input : () => input\n}\n\n/**\n * Non spacing mark contained by some emoticons (65039 - '️' - 0xFE0F).\n *\n * It's the 'Variant Form', which provides more information so that emoticons\n * can be rendered as more colorful graphics. FE0E is a unicode text version\n * whereas FE0F should be rendered as a graphical version.\n * The code gracefully degrades.\n */\nconst NON_SPACING_MARK = String.fromCharCode(65039)\n\nconst nonSpacingRegex = new RegExp(NON_SPACING_MARK, 'g')\n\n/**\n * Removes the non-spacing-mark from the emoji code.\n *\n * Never send a stripped version to clients, as it kills graphical emoticons.\n */\nexport function normalizeCode(code: string) {\n return code.replace(nonSpacingRegex, '')\n}\n\nexport function normalizeName(name: string) {\n return /:.+:/.test(name) ? name.slice(1, -1) : name\n}\n\nexport function randomItem<T>(array: T[]) {\n return array[Math.floor(Math.random() * array.length)]\n}\n","import { assert } from '@sindresorhus/is'\n\nimport { emojiNamesByCode } from './data.js'\nimport { normalizeCode } from './utils.js'\n\nexport const findByCode = (code: string) => {\n assert.string(code)\n\n const emojiNormalized = normalizeCode(code)\n const key = emojiNamesByCode.get(emojiNormalized)\n\n return key ? { emoji: emojiNormalized, key } : undefined\n}\n","import { findByCode } from './findByCode.js'\nimport { findByName } from './findByName.js'\n\n/**\n * Get the name and character of an emoji.\n */\nexport const find = (codeOrName: string) => {\n return findByCode(codeOrName) ?? findByName(codeOrName)\n}\n","import { assert } from '@sindresorhus/is'\n\nimport { emojiCodesByName } from './data.js'\nimport { normalizeName } from './utils.js'\n\n/**\n * Get an emoji from an emoji name.\n */\nexport const get = (codeOrName: string) => {\n assert.string(codeOrName)\n\n return emojiCodesByName.get(normalizeName(codeOrName))\n}\n","import { assert } from '@sindresorhus/is'\n\nimport { emojiCodesByName, emojiNamesByCode } from './data.js'\nimport { normalizeCode, normalizeName } from './utils.js'\n\n/**\n * Check if this library supports a specific emoji.\n */\nexport const has = (codeOrName: string) => {\n assert.string(codeOrName)\n\n return (\n emojiCodesByName.has(normalizeName(codeOrName)) ||\n emojiNamesByCode.has(normalizeCode(codeOrName))\n )\n}\n","import { emojiData } from './data.js'\nimport { randomItem } from './utils.js'\n\n/**\n * Get a random emoji.\n */\nexport const random = () => {\n const [name, emoji] = randomItem(emojiData)\n return { emoji, name }\n}\n","import { assert } from '@sindresorhus/is'\n\nimport { Emoji } from './data.js'\nimport { findByCode } from './findByCode.js'\nimport { asFunction, charRegexMatcher } from './utils.js'\n\nexport type ReplaceReplacement = (\n emoji: Emoji,\n index: number,\n string: string,\n) => string\n\n/**\n * Replace the emojis in a string.\n */\nexport const replace = (\n input: string,\n replacement: ReplaceReplacement | string,\n { preserveSpaces = false } = {},\n) => {\n const replace = asFunction(replacement)\n\n assert.string(input)\n assert.function_(replace)\n assert.boolean(preserveSpaces)\n\n const characters = input.match(charRegexMatcher)\n if (characters === null) {\n return input\n }\n\n return characters\n .map((character, index) => {\n const found = findByCode(character)\n if (!found) {\n return character\n }\n\n if (!preserveSpaces && characters[index + 1] === ' ') {\n characters[index + 1] = ''\n }\n\n return replace(found, index, input)\n })\n .join('')\n}\n","import is, { assert } from '@sindresorhus/is'\n\nimport { emojiData } from './data.js'\nimport { normalizeName } from './utils.js'\n\n/**\n * Search for emojis containing the provided name or pattern in their name.\n */\nexport const search = (keyword: RegExp | string) => {\n assert.any([is.default.string, is.default.regExp], keyword)\n\n if (is.default.string(keyword)) {\n keyword = normalizeName(keyword)\n }\n\n if (is.default.regExp(keyword)) {\n const normalizedPattern = normalizeName(keyword.source)\n keyword = new RegExp(normalizedPattern)\n }\n\n return emojiData\n .filter(([name]) => name.match(keyword))\n .map(([name, emoji]) => ({ emoji, name }))\n}\n","import { replace } from './replace.js'\n\nexport interface StripOptions {\n /**\n * Whether to keep the extra space after a stripped emoji.\n */\n preserveSpaces?: boolean\n}\n\n/**\n * Remove all the emojis from a string.\n */\nexport const strip = (input: string, { preserveSpaces }: StripOptions = {}) =>\n replace(input, '', { preserveSpaces })\n","import { assert } from '@sindresorhus/is'\n\nimport { charRegexMatcher } from './utils.js'\nimport { which } from './which.js'\n\n/**\n * Convert all emojis in a string to their markdown-encoded counterparts.\n */\nexport const unemojify = (input: string) => {\n assert.string(input)\n\n const characters = input.match(charRegexMatcher)\n if (characters === null) {\n return input\n }\n\n return characters\n .map(character => which(character, { markdown: true }) ?? character)\n .join('')\n}\n","import { assert } from '@sindresorhus/is'\nimport skinTone from 'skin-tone'\n\nimport { findByCode } from './findByCode.js'\n\nexport interface WhichOptions {\n markdown?: boolean\n}\n\n/**\n * Get an emoji name from an emoji.\n */\nexport const which = (\n emoji: string,\n { markdown = false }: WhichOptions = {},\n) => {\n assert.string(emoji)\n assert.boolean(markdown)\n\n const result = findByCode(skinTone(emoji, 'none'))\n if (result === undefined) {\n return undefined\n }\n\n return markdown ? `:${result.key}:` : result.key\n}\n"],"mappings":";AAAA,OAAO,QAAQ;;;ACAf,SAAS,cAAc;;;ACAvB,OAAO,cAAc;;;ACArB,OAAO,eAAe;AAEf,IAAM,mBAAmB,UAAU;AAEnC,SAAS,WACd,OACsB;AACtB,SAAO,OAAO,UAAU,aAAa,QAAQ,MAAM;AACrD;AAUA,IAAM,mBAAmB,OAAO,aAAa,KAAK;AAElD,IAAM,kBAAkB,IAAI,OAAO,kBAAkB,GAAG;AAOjD,SAAS,cAAc,MAAc;AAC1C,SAAO,KAAK,QAAQ,iBAAiB,EAAE;AACzC;AAEO,SAAS,cAAc,MAAc;AAC1C,SAAO,OAAO,KAAK,IAAI,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;AACjD;AAEO,SAAS,WAAc,OAAY;AACxC,SAAO,MAAM,KAAK,MAAM,KAAK,OAAO,IAAI,MAAM,MAAM,CAAC;AACvD;;;AD5BO,IAAM,YAAY,OAAO,QAAQ,SAAS,GAAG,EAAE;AAAA,EACpD,CA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Q,MAAM,GAAG,OAAO;AAE1D,MAAIA,IAAG,QAAQ,OAAO,OAAO,GAAG;AAC9B,cAAU,cAAc,OAAO;AAAA,EACjC;AAEA,MAAIA,IAAG,QAAQ,OAAO,OAAO,GAAG;AAC9B,UAAM,oBAAoB,cAAc,QAAQ,MAAM;AACtD,cAAU,IAAI,OAAO,iBAAiB;AAAA,EACxC;AAEA,SAAO,UACJ,OAAO,CAAC,CAAC,IAAI,MAAM,KAAK,MAAM,OAAO,CAAC,EACtC,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,EAAE,OAAO,KAAK,EAAE;AAC7C;;;ACXO,IAAM,QAAQ,CAAC,OAAe,EAAE,eAAe,IAAkB,CAAC,MACvE,QAAQ,OAAO,IAAI,EAAE,eAAe,CAAC;;;ACbvC,SAAS,UAAAC,eAAc;;;ACAvB,SAAS,UAAAC,eAAc;AACvB,OAAO,cAAc;AAWd,IAAM,QAAQ,CACnB,OACA,EAAE,WAAW,MAAM,IAAkB,CAAC,MACnC;AACH,EAAAC,QAAO,OAAO,KAAK;AACnB,EAAAA,QAAO,QAAQ,QAAQ;AAEvB,QAAM,SAAS,WAAW,SAAS,OAAO,MAAM,CAAC;AACjD,MAAI,WAAW,QAAW;AACxB,WAAO;AAAA,EACT;AAEA,SAAO,WAAW,IAAI,OAAO,GAAG,MAAM,OAAO;AAC/C;;;ADjBO,IAAM,YAAY,CAAC,UAAkB;AAC1C,EAAAC,QAAO,OAAO,KAAK;AAEnB,QAAM,aAAa,MAAM,MAAM,gBAAgB;AAC/C,MAAI,eAAe,MAAM;AACvB,WAAO;AAAA,EACT;AAEA,SAAO,WACJ,IAAI,eAAa,MAAM,WAAW,EAAE,UAAU,KAAK,CAAC,KAAK,SAAS,EAClE,KAAK,EAAE;AACZ;","names":["assert","assert","assert","assert","assert","assert","assert","replace","assert","is","assert","assert","is","assert","assert","assert","assert"]}
|
|
File without changes
|
|
File without changes
|