Ejemplo
quick-lru 5.1.1: QuickLRU
Muestra verificada para npm quick-lru 5.1.1: QuickLRU. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: new QuickLRU({ maxSize: number…
sha256:d933984dd5e340e8e728bc3ddfa3bdae72c5e0d67def59ba84b66715cfc69869
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 2
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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-26 |
| 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-07 |
Caso
HOW- Objetivo
- verify pkg:npm/quick-lru@5.1.1
- Paquetes
- Símbolos
-
- QuickLRU
- Creado
- 2026-08-26T08:05:43Z
Contrato
- new QuickLRU({ maxSize: number }) creates a new QuickLRU cache instance
- new QuickLRU() throws TypeError when maxSize option is omitted or not greater than 0
- set(key, value) inserts a key-value entry and returns the instance
- get(key) returns stored value and updates recency
- peek(key) returns stored value without updating recency
- has(key) returns true for existing key and false for missing key
- delete(key) removes key and returns true if existed
- clear() removes all entries and resets size to 0
- size returns the current number of cached items
- evicts least recently used items when cache exceeds maxSize
- onEviction callback is called when items are evicted
Archivos
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código fuente
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/quick-lru@5.1.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/quick-lru@5.1.1
Demonstrate these symbols/APIs:
- QuickLRU
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:5e3408cd8f7fbce815a5e13dcde60c36a9b0074cc06c3995ac36f34bfbcbebfb","contract":["new QuickLRU({ maxSize: number }) creates a new QuickLRU cache instance","new QuickLRU() throws TypeError when maxSize option is omitted or not greater than 0","set(key, value) inserts a key-value entry and returns the instance","get(key) returns stored value and updates recency","peek(key) returns stored value without updating recency","has(key) returns true for existing key and false for missing key","delete(key) removes key and returns true if existed","clear() removes all entries and resets size to 0","size returns the current number of cached items","evicts least recently used items when cache exceeds maxSize","onEviction callback is called when items are evicted"],"goal":"verify pkg:npm/quick-lru@5.1.1","kind":"HOW","packages":["pkg:npm/quick-lru@5.1.1"],"schemaVersion":1,"symbols":["QuickLRU"]},"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/quick-lru@5.1.1"],"schemaVersion":1,"subject":"pkg:npm/quick-lru@5.1.1","symbols":["QuickLRU"],"verifierAdapter":"node-typescript@1"}
import QuickLRU from 'quick-lru';
export function createLRUCache(maxSize = 100, onEviction) {
return new QuickLRU({ maxSize, onEviction });
}
export function demoQuickLRU() {
const lru = new QuickLRU({ maxSize: 2 });
lru.set('first', '1');
lru.set('second', '2');
lru.set('third', '3'); // evicts 'first'
return {
hasFirst: lru.has('first'),
second: lru.get('second'),
third: lru.get('third'),
size: lru.size
};
}
{
"name": "quick-lru-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "quick-lru-sample",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"quick-lru": "5.1.1"
}
},
"node_modules/quick-lru": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz",
"integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==",
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
}
}
}
{
"name": "quick-lru-sample",
"version": "1.0.0",
"type": "module",
"private": true,
"license": "MIT-0",
"dependencies": {
"quick-lru": "5.1.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/quick-lru@5.1.1",
"kind": "HOW",
"packages": [
"pkg:npm/quick-lru@5.1.1"
],
"symbols": [
"QuickLRU"
]
}
import assert from 'node:assert';
import QuickLRU from 'quick-lru';
// 1. Constructor validation
assert.throws(() => new QuickLRU(), {
name: 'TypeError',
message: '`maxSize` must be a number greater than 0'
});
assert.throws(() => new QuickLRU({ maxSize: 0 }), {
name: 'TypeError'
});
assert.throws(() => new QuickLRU({ maxSize: -5 }), {
name: 'TypeError'
});
// 2. Instance creation and basic operations
const lru = new QuickLRU({ maxSize: 3 });
assert.strictEqual(lru.maxSize, 3);
assert.strictEqual(lru.size, 0);
// 3. set and chainability
const setReturn = lru.set('a', 1);
assert.strictEqual(setReturn, lru);
lru.set('b', 2);
assert.strictEqual(lru.size, 2);
// 4. get and has
assert.strictEqual(lru.has('a'), true);
assert.strictEqual(lru.has('b'), true);
assert.strictEqual(lru.has('c'), false);
assert.strictEqual(lru.get('a'), 1);
assert.strictEqual(lru.get('b'), 2);
assert.strictEqual(lru.get('nonexistent'), undefined);
// 5. peek without updating recency
assert.strictEqual(lru.peek('a'), 1);
assert.strictEqual(lru.peek('missing'), undefined);
// 6. delete
assert.strictEqual(lru.delete('a'), true);
assert.strictEqual(lru.delete('a'), false);
assert.strictEqual(lru.has('a'), false);
assert.strictEqual(lru.get('a'), undefined);
assert.strictEqual(lru.size, 1);
// 7. clear
lru.clear();
assert.strictEqual(lru.size, 0);
assert.strictEqual(lru.has('b'), false);
// 8. Eviction and maxSize behavior
const evicted = [];
const cacheWithEviction = new QuickLRU({
maxSize: 2,
onEviction: (key, value) => {
evicted.push({ key, value });
}
});
cacheWithEviction.set('x', 10);
cacheWithEviction.set('y', 20);
assert.strictEqual(cacheWithEviction.size, 2);
// Adding 3rd item triggers internal rotation in QuickLRU
cacheWithEviction.set('z', 30);
assert.strictEqual(cacheWithEviction.has('z'), true);
// Adding 4th item triggers eviction of oldCache items
cacheWithEviction.set('w', 40);
assert.strictEqual(evicted.length > 0, true);
// 9. Iteration
const iterCache = new QuickLRU({ maxSize: 5 });
iterCache.set('k1', 'v1');
iterCache.set('k2', 'v2');
const keys = [...iterCache.keys()];
const values = [...iterCache.values()];
const entries = [...iterCache];
assert.deepStrictEqual(keys.sort(), ['k1', 'k2']);
assert.deepStrictEqual(values.sort(), ['v1', 'v2']);
assert.strictEqual(entries.length, 2);
console.log('All contract assertions passed successfully.');
Seeder de origen
anónimo