サンプル
lru-cache 10.4.3
検証済みサンプル — npm lru-cache 10.4.3. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: LRUCache basic set, get, has, and delete operations manage…
sha256:65309ec6cafbc9663e1c24ef1092516275944c6f33cf2996bb924fa7f5cda513
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 2
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 npm
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-21 |
| 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 |
ケース
HOW- ゴール
- verify pkg:npm/lru-cache@10.4.3
- パッケージ
- 作成日
- 2026-08-21T13:46:37Z
コントラクト
- LRUCache basic set, get, has, and delete operations manage cached values
- LRUCache evicts the least recently used item when cache capacity max is exceeded
- LRUCache expires cached entries after ttl duration
- LRUCache enforces maxSize using sizeCalculation and evicts entries exceeding size limit
- LRUCache peek retrieves value without altering LRU order
- LRUCache supports iteration over keys, values, and entries and clear resets cache size
ファイル
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
ソース
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/lru-cache@10.4.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/lru-cache@10.4.3
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:bcc8101e276003eae935e76b83d0bc4144997111fe65736a0a754906f9d9919d","contract":["LRUCache basic set, get, has, and delete operations manage cached values","LRUCache evicts the least recently used item when cache capacity max is exceeded","LRUCache expires cached entries after ttl duration","LRUCache enforces maxSize using sizeCalculation and evicts entries exceeding size limit","LRUCache peek retrieves value without altering LRU order","LRUCache supports iteration over keys, values, and entries and clear resets cache size"],"goal":"verify pkg:npm/lru-cache@10.4.3","kind":"HOW","packages":["pkg:npm/lru-cache@10.4.3"],"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/lru-cache@10.4.3"],"schemaVersion":1,"subject":"pkg:npm/lru-cache@10.4.3","verifierAdapter":"node-typescript@1"}
import { LRUCache } from 'lru-cache';
export function createCache(options) {
return new LRUCache(options);
}
export { LRUCache };
{
"name": "sample-lru-cache",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-lru-cache",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"lru-cache": "10.4.3"
}
},
"node_modules/lru-cache": {
"version": "10.4.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
"integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==",
"license": "ISC"
}
}
}
{
"name": "sample-lru-cache",
"version": "1.0.0",
"description": "Clean-room verification sample for lru-cache",
"type": "module",
"private": true,
"dependencies": {
"lru-cache": "10.4.3"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/lru-cache@10.4.3",
"kind": "HOW",
"packages": [
"pkg:npm/lru-cache@10.4.3"
]
}
import assert from 'node:assert/strict';
import { LRUCache, createCache } from '../index.mjs';
// 1. Basic set, get, has, and delete operations
{
const cache = createCache({ max: 5 });
cache.set('a', 1);
cache.set('b', 2);
assert.equal(cache.get('a'), 1);
assert.equal(cache.get('b'), 2);
assert.equal(cache.has('a'), true);
assert.equal(cache.has('missing'), false);
assert.equal(cache.delete('a'), true);
assert.equal(cache.has('a'), false);
assert.equal(cache.get('a'), undefined);
}
// 2. LRU eviction when exceeding max items
{
const cache = new LRUCache({ max: 2 });
cache.set('a', 1);
cache.set('b', 2);
assert.equal(cache.get('a'), 1); // access 'a' so 'b' is least recently used
cache.set('c', 3);
assert.equal(cache.has('b'), false);
assert.equal(cache.has('a'), true);
assert.equal(cache.has('c'), true);
assert.equal(cache.size, 2);
}
// 3. TTL expiration of cached entries
{
const cache = new LRUCache({ max: 5, ttl: 50 });
cache.set('temp', 'val');
assert.equal(cache.get('temp'), 'val');
await new Promise((resolve) => setTimeout(resolve, 80));
assert.equal(cache.get('temp'), undefined);
assert.equal(cache.has('temp'), false);
}
// 4. maxSize and sizeCalculation eviction
{
const cache = new LRUCache({
maxSize: 10,
sizeCalculation: (value) => value.length,
});
cache.set('k1', 'abcd');
cache.set('k2', 'efgh');
assert.equal(cache.calculatedSize, 8);
cache.set('k3', 'ijkl');
assert.equal(cache.has('k1'), false);
assert.equal(cache.has('k2'), true);
assert.equal(cache.has('k3'), true);
assert.equal(cache.calculatedSize, 8);
}
// 5. peek retrieves value without updating LRU order
{
const cache = new LRUCache({ max: 2 });
cache.set('x', 10);
cache.set('y', 20);
assert.equal(cache.peek('x'), 10);
cache.set('z', 30);
assert.equal(cache.has('x'), false);
assert.equal(cache.has('y'), true);
assert.equal(cache.has('z'), true);
}
// 6. Iteration over keys, values, and entries
{
const cache = new LRUCache({ max: 5 });
cache.set('1', 'one');
cache.set('2', 'two');
assert.deepEqual([...cache.keys()], ['2', '1']);
assert.deepEqual([...cache.values()], ['two', 'one']);
assert.deepEqual([...cache.entries()], [['2', 'two'], ['1', 'one']]);
cache.clear();
assert.equal(cache.size, 0);
}
console.log('All LRUCache@10.4.3 contract assertions passed.');
オリジンシーダー
匿名