샘플
lru-cache 10.4.3: LRUCache
검증된 샘플 — npm lru-cache 10.4.3: LRUCache. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: assert LRUCache instantiates with options and performs…
sha256:31b23d141194aa1eba5ff161dec7e142bd479909033830e82c4854877d95f827
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-07 |
케이스
HOW- 목표
- verify lru-cache.LRUCache in pkg:npm/lru-cache@10.4.3
- 패키지
- 심벌
-
- lru-cache.LRUCache
- 환경
- node 22.23.2
- 생성일
- 2026-08-23T05:16:31Z
컨트랙트
- assert LRUCache instantiates with options and performs set and get operations
- assert LRUCache evicts least recently used items when max capacity is reached
- assert LRUCache peek reads values without updating recency order
- assert LRUCache supports item deletion and clear operations
- assert LRUCache supports ttl expiration for cached entries
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- 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 lru-cache.LRUCache in pkg:npm/lru-cache@10.4.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/lru-cache@10.4.3
Demonstrate these symbols/APIs:
- lru-cache.LRUCache
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.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:819931733a12c835847bd0bfe51248ac0cdffe8dc13a96403713298a29e3c887","constraints":{"executionContext":"node"},"contract":["assert LRUCache instantiates with options and performs set and get operations","assert LRUCache evicts least recently used items when max capacity is reached","assert LRUCache peek reads values without updating recency order","assert LRUCache supports item deletion and clear operations","assert LRUCache supports ttl expiration for cached entries"],"goal":"verify lru-cache.LRUCache in pkg:npm/lru-cache@10.4.3","kind":"HOW","packages":["pkg:npm/lru-cache@10.4.3"],"schemaVersion":1,"symbols":["lru-cache.LRUCache"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/lru-cache@10.4.3"],"schemaVersion":1,"subject":"pkg:npm/lru-cache@10.4.3","symbols":["lru-cache.LRUCache"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-lru-cache-lrucache",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-lru-cache-lrucache",
"version": "1.0.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-lrucache",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of lru-cache LRUCache",
"main": "src/index.js",
"dependencies": {
"lru-cache": "10.4.3"
}
}
{
"schemaVersion": 1,
"goal": "verify lru-cache.LRUCache in pkg:npm/lru-cache@10.4.3",
"kind": "HOW",
"packages": [
"pkg:npm/lru-cache@10.4.3"
],
"symbols": [
"lru-cache.LRUCache"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const { LRUCache } = require('lru-cache');
/**
* Create a new LRUCache instance with given options.
* @param {object} options
* @returns {LRUCache}
*/
function createCache(options = {}) {
return new LRUCache(options);
}
module.exports = {
LRUCache,
createCache,
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { LRUCache, createCache } = require('../src/index.js');
// 1. assert LRUCache instantiates with options and performs set and get operations
{
const cache = createCache({ max: 10 });
assert.ok(cache instanceof LRUCache, 'cache should be an instance of LRUCache');
cache.set('key1', 'value1');
assert.equal(cache.get('key1'), 'value1', 'get should retrieve the stored value');
assert.equal(cache.has('key1'), true, 'has should return true for stored key');
assert.equal(cache.size, 1, 'size should reflect number of stored items');
}
// 2. assert LRUCache evicts least recently used items when max capacity is reached
{
const cache = new LRUCache({ max: 2 });
cache.set('a', 1);
cache.set('b', 2);
cache.get('a'); // 'a' accessed, so 'b' becomes least recently used
cache.set('c', 3); // causes 'b' to be evicted
assert.equal(cache.get('a'), 1, 'key a should remain in cache');
assert.equal(cache.get('c'), 3, 'key c should be stored in cache');
assert.equal(cache.has('b'), false, 'key b should be evicted');
assert.equal(cache.get('b'), undefined, 'get on evicted key b should return undefined');
assert.equal(cache.size, 2, 'cache size should not exceed max');
}
// 3. assert LRUCache peek reads values without updating recency order
{
const cache = new LRUCache({ max: 2 });
cache.set('a', 1);
cache.set('b', 2);
// peek 'a' does not refresh 'a' recency, so 'a' remains older than 'b'
const peekVal = cache.peek('a');
assert.equal(peekVal, 1, 'peek should return the value');
cache.set('c', 3); // 'a' is evicted because it was not refreshed by peek
assert.equal(cache.has('a'), false, 'key a should have been evicted');
assert.equal(cache.has('b'), true, 'key b should remain in cache');
assert.equal(cache.has('c'), true, 'key c should remain in cache');
}
// 4. assert LRUCache supports item deletion and clear operations
{
const cache = new LRUCache({ max: 5 });
cache.set('x', 10);
cache.set('y', 20);
assert.equal(cache.size, 2);
const deleted = cache.delete('x');
assert.equal(deleted, true, 'delete should return true for deleted key');
assert.equal(cache.has('x'), false, 'has should return false after delete');
assert.equal(cache.size, 1);
cache.clear();
assert.equal(cache.size, 0, 'size should be 0 after clear');
assert.equal(cache.has('y'), false, 'all keys should be removed after clear');
}
// 5. assert LRUCache supports ttl expiration for cached entries
{
const cache = new LRUCache({ max: 5, ttl: 50 });
cache.set('temp', 'temporary-val');
assert.equal(cache.get('temp'), 'temporary-val', 'value should be available immediately');
// Wait for TTL expiration
await new Promise((resolve) => setTimeout(resolve, 80));
assert.equal(cache.get('temp'), undefined, 'expired item should return undefined');
assert.equal(cache.has('temp'), false, 'has should return false for expired item');
}
console.log('All LRUCache contract assertions passed successfully.');
오리진 시더
익명