create daemon
This commit is contained in:
32
thrower_daemon/node_modules/nostr-tools/lib/esm/nip30.js
generated
vendored
Normal file
32
thrower_daemon/node_modules/nostr-tools/lib/esm/nip30.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// nip30.ts
|
||||
var EMOJI_SHORTCODE_REGEX = /:(\w+):/;
|
||||
var regex = () => new RegExp(`\\B${EMOJI_SHORTCODE_REGEX.source}\\B`, "g");
|
||||
function* matchAll(content) {
|
||||
const matches = content.matchAll(regex());
|
||||
for (const match of matches) {
|
||||
try {
|
||||
const [shortcode, name] = match;
|
||||
yield {
|
||||
shortcode,
|
||||
name,
|
||||
start: match.index,
|
||||
end: match.index + shortcode.length
|
||||
};
|
||||
} catch (_e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
function replaceAll(content, replacer) {
|
||||
return content.replaceAll(regex(), (shortcode, name) => {
|
||||
return replacer({
|
||||
shortcode,
|
||||
name
|
||||
});
|
||||
});
|
||||
}
|
||||
export {
|
||||
EMOJI_SHORTCODE_REGEX,
|
||||
matchAll,
|
||||
regex,
|
||||
replaceAll
|
||||
};
|
||||
Reference in New Issue
Block a user