Beispiel
color-name 1.1.4
Verifiziertes Beispiel für npm color-name 1.1.4. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: colorName maps standard CSS color…
sha256:b3e58c231bf099c2c3e08b338d2c3e42bbc172a572a8db4214a505b88aff992c
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 2
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 npm
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-12 |
Fall
HOW- Ziel
- verify pkg:npm/color-name@1.1.4
- Pakete
- Erstellt
- 2026-08-23T08:13:16Z
Contract
- colorName maps standard CSS color names to 3-element RGB integer arrays
- getColorRgb retrieves RGB array for a color name with case-insensitive support
- getColorHex converts named colors into uppercase hexadecimal hex strings
- isColorName verifies whether a given keyword is a recognized CSS color name
- getAllColorNames returns all 148 standard color name keys
- rgbToColorName performs reverse lookup from RGB tuple to corresponding color name
Dateien
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
Quelltext
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/color-name@1.1.4
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/color-name@1.1.4
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:29cc3e4b358c7d061ffd3d68b6316c02adafd6a47a65dd12ed347154f6fb4ab3","contract":["colorName maps standard CSS color names to 3-element RGB integer arrays","getColorRgb retrieves RGB array for a color name with case-insensitive support","getColorHex converts named colors into uppercase hexadecimal hex strings","isColorName verifies whether a given keyword is a recognized CSS color name","getAllColorNames returns all 148 standard color name keys","rgbToColorName performs reverse lookup from RGB tuple to corresponding color name"],"goal":"verify pkg:npm/color-name@1.1.4","kind":"HOW","packages":["pkg:npm/color-name@1.1.4"],"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/color-name@1.1.4"],"schemaVersion":1,"subject":"pkg:npm/color-name@1.1.4","verifierAdapter":"node-typescript@1"}
{
"name": "sample-color-name",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-color-name",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"color-name": "1.1.4"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"license": "MIT"
}
}
}
{
"name": "sample-color-name",
"version": "1.0.0",
"type": "module",
"private": true,
"license": "MIT-0",
"dependencies": {
"color-name": "1.1.4"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/color-name@1.1.4",
"kind": "HOW",
"packages": [
"pkg:npm/color-name@1.1.4"
]
}
import colorName from 'color-name';
export { colorName };
/**
* Returns the [r, g, b] array for a given color name, or undefined if unknown.
* Case-insensitive.
*/
export function getColorRgb(name) {
if (typeof name !== 'string') return undefined;
const normalized = name.toLowerCase().trim();
return colorName[normalized];
}
/**
* Converts a color name into a 6-character hex string (#RRGGBB).
*/
export function getColorHex(name) {
const rgb = getColorRgb(name);
if (!rgb) return undefined;
const [r, g, b] = rgb;
const toHex = (n) => n.toString(16).padStart(2, '0').toUpperCase();
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
}
/**
* Checks if a string is a valid color name in the catalog.
*/
export function isColorName(name) {
if (typeof name !== 'string') return false;
const normalized = name.toLowerCase().trim();
return Object.prototype.hasOwnProperty.call(colorName, normalized);
}
/**
* Returns an array of all supported color names.
*/
export function getAllColorNames() {
return Object.keys(colorName);
}
/**
* Performs a reverse lookup of an [r, g, b] tuple to find matching color name.
*/
export function rgbToColorName(rgb) {
if (!Array.isArray(rgb) || rgb.length !== 3) return undefined;
const [r, g, b] = rgb;
for (const [name, val] of Object.entries(colorName)) {
if (val[0] === r && val[1] === g && val[2] === b) {
return name;
}
}
return undefined;
}
import assert from 'node:assert/strict';
import colorName from 'color-name';
import {
getColorRgb,
getColorHex,
isColorName,
getAllColorNames,
rgbToColorName,
} from '../src/index.mjs';
// 1. colorName maps standard CSS color names to 3-element RGB integer arrays
{
assert.deepEqual(colorName.red, [255, 0, 0]);
assert.deepEqual(colorName.green, [0, 128, 0]);
assert.deepEqual(colorName.blue, [0, 0, 255]);
assert.deepEqual(colorName.white, [255, 255, 255]);
assert.deepEqual(colorName.black, [0, 0, 0]);
assert.deepEqual(colorName.rebeccapurple, [102, 51, 153]);
// Validate all entries are 3-element arrays with valid RGB values (0-255)
for (const [name, rgb] of Object.entries(colorName)) {
assert.equal(typeof name, 'string');
assert.equal(Array.isArray(rgb), true);
assert.equal(rgb.length, 3);
for (const channel of rgb) {
assert.equal(typeof channel, 'number');
assert.equal(channel >= 0 && channel <= 255, true);
assert.equal(Number.isInteger(channel), true);
}
}
}
// 2. getColorRgb retrieves RGB array for a color name with case-insensitive support
{
assert.deepEqual(getColorRgb('red'), [255, 0, 0]);
assert.deepEqual(getColorRgb('RED'), [255, 0, 0]);
assert.deepEqual(getColorRgb('DarkBlue'), [0, 0, 139]);
assert.deepEqual(getColorRgb(' aliceblue '), [240, 248, 255]);
assert.equal(getColorRgb('not-a-color'), undefined);
assert.equal(getColorRgb(123), undefined);
}
// 3. getColorHex converts named colors into uppercase hexadecimal hex strings
{
assert.equal(getColorHex('red'), '#FF0000');
assert.equal(getColorHex('white'), '#FFFFFF');
assert.equal(getColorHex('black'), '#000000');
assert.equal(getColorHex('rebeccapurple'), '#663399');
assert.equal(getColorHex('nonexistent'), undefined);
}
// 4. isColorName verifies whether a given keyword is a recognized CSS color name
{
assert.equal(isColorName('cornflowerblue'), true);
assert.equal(isColorName('CORnflowerBLUE'), true);
assert.equal(isColorName('red'), true);
assert.equal(isColorName('boguscolor'), false);
assert.equal(isColorName(null), false);
}
// 5. getAllColorNames returns all 148 standard color name keys
{
const names = getAllColorNames();
assert.equal(names.length, 148);
assert.equal(names.includes('red'), true);
assert.equal(names.includes('lime'), true);
assert.equal(names.includes('rebeccapurple'), true);
}
// 6. rgbToColorName performs reverse lookup from RGB tuple to corresponding color name
{
assert.equal(rgbToColorName([255, 0, 0]), 'red');
assert.equal(rgbToColorName([0, 0, 0]), 'black');
assert.equal(rgbToColorName([255, 255, 255]), 'white');
assert.equal(rgbToColorName([102, 51, 153]), 'rebeccapurple');
assert.equal(rgbToColorName([1, 2, 3]), undefined);
assert.equal(rgbToColorName('invalid'), undefined);
}
console.log('Contract tests passed successfully.');
Ursprungs-Seeder
anonym