Sample
emoji-regex 9.2.2
Verified sample for npm emoji-regex 9.2.2. The contract ran on node 22 · linux alpine/x64 · docker and passed: emojiRegex exports a factory function…
sha256:6b22911f11525e526ae40eb644c6939a897de04842e56083889de1b8b81efdf2
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 x64 npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-23 |
Case
HOW- Goal
- verify pkg:npm/emoji-regex@9.2.2
- Packages
- Created
- 2026-08-23T13:41:20Z
Contract
- emojiRegex exports a factory function returning a regular expression
- hasEmoji returns true when string contains standard emojis and false for plain text
- extractEmojis extracts all emoji occurrences from text
- extractEmojis correctly extracts complex emoji sequences including modifiers and zero-width joiners
- replaceEmojis replaces emojis in text with a replacement string or custom replacer function
- countEmojis returns the number of emojis found in text
- RGI_Emoji subpath exports a factory function returning regex for RGI emoji sequences
- text subpath exports a factory function returning regex for text presentation emojis
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Source
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:npm/emoji-regex@9.2.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/emoji-regex@9.2.2
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:2d3a60100aec5f5437ba91b77666fdcfa607a3d10dc5d833574db67d527a7ffe","contract":["emojiRegex exports a factory function returning a regular expression","hasEmoji returns true when string contains standard emojis and false for plain text","extractEmojis extracts all emoji occurrences from text","extractEmojis correctly extracts complex emoji sequences including modifiers and zero-width joiners","replaceEmojis replaces emojis in text with a replacement string or custom replacer function","countEmojis returns the number of emojis found in text","RGI_Emoji subpath exports a factory function returning regex for RGI emoji sequences","text subpath exports a factory function returning regex for text presentation emojis"],"goal":"verify pkg:npm/emoji-regex@9.2.2","kind":"HOW","packages":["pkg:npm/emoji-regex@9.2.2"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/emoji-regex@9.2.2"],"schemaVersion":1,"subject":"pkg:npm/emoji-regex@9.2.2","verifierAdapter":"node-typescript@1"}
{
"name": "sample-emoji-regex",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-emoji-regex",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"emoji-regex": "9.2.2"
}
},
"node_modules/emoji-regex": {
"version": "9.2.2",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
"integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==",
"license": "MIT"
}
}
}
{
"name": "sample-emoji-regex",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for emoji-regex@9.2.2",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"emoji-regex": "9.2.2"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/emoji-regex@9.2.2",
"kind": "HOW",
"packages": [
"pkg:npm/emoji-regex@9.2.2"
]
}
const emojiRegex = require('emoji-regex');
const rgiEmojiRegex = require('emoji-regex/RGI_Emoji.js');
const textEmojiRegex = require('emoji-regex/text.js');
/**
* Creates a regular expression that matches all standard emoji symbols.
*
* @returns {RegExp} A new regular expression instance matching emojis.
*/
function createEmojiRegex() {
return emojiRegex();
}
/**
* Creates a regular expression that matches RGI (Recommended for General Interchange) emoji sequences.
*
* @returns {RegExp} A regular expression instance matching RGI emojis.
*/
function createRgiEmojiRegex() {
return rgiEmojiRegex();
}
/**
* Creates a regular expression that matches emojis in text presentation.
*
* @returns {RegExp} A regular expression instance matching text-presentation emojis.
*/
function createTextEmojiRegex() {
return textEmojiRegex();
}
/**
* Determines whether a string contains any emoji character.
*
* @param {string} text - The input string to check.
* @returns {boolean} True if the string contains at least one emoji, otherwise false.
*/
function hasEmoji(text) {
if (typeof text !== 'string') return false;
return createEmojiRegex().test(text);
}
/**
* Extracts all emoji characters and sequences found in the string.
*
* @param {string} text - The input string to extract emojis from.
* @returns {string[]} An array of matched emoji strings.
*/
function extractEmojis(text) {
if (typeof text !== 'string') return [];
const regex = createEmojiRegex();
const matches = [];
for (const match of text.matchAll(regex)) {
matches.push(match[0]);
}
return matches;
}
/**
* Replaces all emoji occurrences in a string with a replacement string or callback.
*
* @param {string} text - The input string.
* @param {string|Function} replacement - The replacement string or function.
* @returns {string} The modified string with emojis replaced.
*/
function replaceEmojis(text, replacement = '') {
if (typeof text !== 'string') return '';
const regex = createEmojiRegex();
return text.replace(regex, replacement);
}
/**
* Counts the total number of emoji occurrences in the given text.
*
* @param {string} text - The input string.
* @returns {number} Total count of emojis found.
*/
function countEmojis(text) {
return extractEmojis(text).length;
}
module.exports = {
emojiRegex,
rgiEmojiRegex,
textEmojiRegex,
createEmojiRegex,
createRgiEmojiRegex,
createTextEmojiRegex,
hasEmoji,
extractEmojis,
replaceEmojis,
countEmojis
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
emojiRegex,
rgiEmojiRegex,
textEmojiRegex,
createEmojiRegex,
createRgiEmojiRegex,
createTextEmojiRegex,
hasEmoji,
extractEmojis,
replaceEmojis,
countEmojis
} = require('../src/index.js');
async function testAll() {
// 1. emojiRegex exports a factory function returning a regular expression
assert.equal(typeof emojiRegex, 'function', 'emojiRegex default export must be a function');
const standardRegex = createEmojiRegex();
assert.ok(standardRegex instanceof RegExp, 'createEmojiRegex must return a RegExp instance');
assert.ok(standardRegex.global, 'emoji regex must have the global flag enabled');
// 2. hasEmoji returns true when string contains standard emojis and false for plain text
assert.equal(hasEmoji('Hello 😊 World'), true, 'should detect standard emoji in text');
assert.equal(hasEmoji('Hello World'), false, 'should return false for plain ascii text');
assert.equal(hasEmoji('Numbers 12345 and punctuation !@#$'), false, 'should return false for symbols and numbers');
assert.equal(hasEmoji(''), false, 'should return false for empty string');
assert.equal(hasEmoji(null), false, 'should handle non-string values gracefully');
// 3. extractEmojis extracts all emoji occurrences from text
const simpleText = '🚀 Launching rocket to 🌙 moon!';
const simpleExtracted = extractEmojis(simpleText);
assert.deepEqual(simpleExtracted, ['🚀', '🌙'], 'should extract individual emojis in order');
// 4. extractEmojis correctly extracts complex emoji sequences including modifiers and zero-width joiners
const complexText = 'Doctor: 👩⚕️, rainbow flag: 🏳️🌈, dark skin tone: 👨🏿';
const complexExtracted = extractEmojis(complexText);
assert.deepEqual(
complexExtracted,
['👩⚕️', '🏳️🌈', '👨🏿'],
'should extract complex emoji sequences with ZWJ and modifier characters intact'
);
// 5. replaceEmojis replaces emojis in text with a replacement string or custom replacer function
const replacedWithTag = replaceEmojis('Hello 👋 World 🌍!', '[EMOJI]');
assert.equal(replacedWithTag, 'Hello [EMOJI] World [EMOJI]!', 'should replace emojis with placeholder string');
const stripped = replaceEmojis('Hello 🚀 World 🌟!');
assert.equal(stripped, 'Hello World !', 'should remove emojis when replacement defaults to empty string');
const customReplaced = replaceEmojis('Rating: ⭐⭐⭐', (match) => `(${match})`);
assert.equal(customReplaced, 'Rating: (⭐)(⭐)(⭐)', 'should support replacer function');
// 6. countEmojis returns the number of emojis found in text
assert.equal(countEmojis('🎉 Congratulations 🥳 on your achievement! 👏'), 3, 'should count 3 emojis correctly');
assert.equal(countEmojis('No emojis here.'), 0, 'should return 0 when no emojis are present');
assert.equal(countEmojis('👩👩👧👦'), 1, 'should count multi-codepoint family emoji as 1 emoji');
// 7. RGI_Emoji subpath exports a factory function returning regex for RGI emoji sequences
assert.equal(typeof rgiEmojiRegex, 'function', 'RGI_Emoji export must be a function');
const rgiRegex = createRgiEmojiRegex();
assert.ok(rgiRegex instanceof RegExp, 'createRgiEmojiRegex must return a RegExp instance');
assert.ok(rgiRegex.test('🧑🚀'), 'RGI regex should match valid astronaut emoji');
// 8. text subpath exports a factory function returning regex for text presentation emojis
assert.equal(typeof textEmojiRegex, 'function', 'text export must be a function');
const textRegex = createTextEmojiRegex();
assert.ok(textRegex instanceof RegExp, 'createTextEmojiRegex must return a RegExp instance');
console.log('All emoji-regex contract assertions passed successfully.');
}
testAll().catch((err) => {
console.error('Contract test failure:', err);
process.exit(1);
});
Origin Seeder
anonymous