Exemple
chalk 6.0.0: Pinpoint Chalk's malformed `hex()` input behavior when nullish values and malformed strings are provided.
Échantillon vérifié pour npm chalk 6.0.0: Pinpoint Chalk's malformed `hex()` input behavior when nullish values and malformed strings are provided. Le…
sha256:8a0531ffe818e26b9036a49be7c8f41af3ee24f2802f62aa006deb0ac042b7dd
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 2
- Clés de signature qui l’ont compilé
- 2
Environnement déclaré
node linux x64 node node npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-17 |
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-18 |
Cas
HOW- Objectif
- Pinpoint Chalk's malformed `hex()` input behavior when nullish values and malformed strings are provided.
- Paquets
- Symboles
-
- chalk.hex
- Environnement
- node
- Créé
- 2026-08-17T03:15:58Z
Contrat
- With `chalk.level = 3`, calling `chalk.hex('not-a-color')('x')` returns `x` wrapped in `\u001b[38;2;0;0;0m` and `\u001b[39m` and does not throw.
- `chalk.hex('')('x')` also returns black 24-bit ANSI output instead of an error.
- Nullish inputs are the only values that fail here: `chalk.hex(null)('x')` and `chalk.hex(undefined)('x')` throw TypeError while malformed strings do not.
Fichiers
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Code source
search_known_solution returned existing hits for Chalk level/ANSI behavior (`sha256:525f14e9ff41964b2cf8700329f042389c75335c2b13dc4d12796c1cbb8e0f28` and related downsample cases), so this sample uses a different trap: malformed `hex()` input handling.
For this trap, malformed non-null strings are silently treated as black ANSI output, while nullish values fail loudly with `TypeError`.
{"case":{"believed":"A caller should get the same kind of rejection for all obviously malformed `chalk.hex(...)` inputs.","caseId":"case:sha256:30b96d62fc271aaf7efafecd44b134b8098d22c74efb89b426d281b56e473b32","contract":["With `chalk.level = 3`, calling `chalk.hex('not-a-color')('x')` returns `x` wrapped in `\\u001b[38;2;0;0;0m` and `\\u001b[39m` and does not throw.","`chalk.hex('')('x')` also returns black 24-bit ANSI output instead of an error.","Nullish inputs are the only values that fail here: `chalk.hex(null)('x')` and `chalk.hex(undefined)('x')` throw TypeError while malformed strings do not."],"goal":"Pinpoint Chalk's malformed `hex()` input behavior when nullish values and malformed strings are provided.","kind":"HOW","packages":["pkg:npm/chalk@6.0.0"],"schemaVersion":1,"symbols":["chalk.hex"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/chalk@6.0.0"],"schemaVersion":1,"symbols":["chalk.hex"],"verifierAdapter":"node-typescript@1"}
{
"name": "npm-chalk-d2",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "npm-chalk-d2",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"chalk": "6.0.0"
}
},
"node_modules/chalk": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-6.0.0.tgz",
"integrity": "sha512-2uNTXIuTTxk7ciZgAU1BQcgnchcG0xXnrs6jzkQfj9SsRa9M2s5zE8WT96hS6KmG4MzWHSrvH43DF1m4XRkrFg==",
"license": "MIT",
"engines": {
"node": ">=22"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
}
}
}
{
"name": "npm-chalk-d2",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"chalk": "6.0.0"
}
}
import assert from 'node:assert/strict';
import chalkPkg from 'chalk';
const chalk = chalkPkg.default ?? chalkPkg;
chalk.level = 3;
assert.equal(typeof chalk.hex, 'function');
assert.equal(
chalk.hex('not-a-color')('x'),
'\u001b[38;2;0;0;0m' + 'x' + '\u001b[39m'
);
assert.equal(
chalk.hex('')('x'),
'\u001b[38;2;0;0;0m' + 'x' + '\u001b[39m'
);
assert.throws(() => chalk.hex(null)('x'), {
name: 'TypeError',
message: /Cannot read properties of null/
});
assert.throws(() => chalk.hex(undefined)('x'), {
name: 'TypeError',
message: /Cannot read properties of undefined/
});