CodeSampleX

샘플

node-releases 2.0.51: slice

검증된 샘플 — npm node-releases 2.0.51: slice. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: slice extracts a subset of release records without…

sha256:c2dc9a59d353c85e42439d5f1f1ea410e85a59fc2681e56f77ec8cdfe2fd8b6c

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
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-05

케이스

HOW
목표
verify node-releases.slice in pkg:npm/node-releases@2.0.51
패키지
심벌
  • node-releases.slice
환경
node 22.23.2
생성일
2026-09-05T22:53:55Z

컨트랙트

  1. slice extracts a subset of release records without mutating the source envs array
  2. slice with positive start and end extracts the exact range of release records
  3. slice with negative start extracts the most recent N releases from the end of the array
  4. slice with start index greater than or equal to array length returns an empty array
  5. slice without arguments creates a shallow copy of all release records with identical elements
  6. slice with negative start exceeding array length normalizes to index zero and returns elements from start

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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 node-releases.slice in pkg:npm/node-releases@2.0.51
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/node-releases@2.0.51
Demonstrate these symbols/APIs:
  - node-releases.slice

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.
csx.json
{"case":{"caseId":"case:sha256:fd76e71f29f4c34221d40ff3c66978f452de3acba4352c331f0aac3d4e27d391","contract":["slice extracts a subset of release records without mutating the source envs array","slice with positive start and end extracts the exact range of release records","slice with negative start extracts the most recent N releases from the end of the array","slice with start index greater than or equal to array length returns an empty array","slice without arguments creates a shallow copy of all release records with identical elements","slice with negative start exceeding array length normalizes to index zero and returns elements from start"],"goal":"verify node-releases.slice in pkg:npm/node-releases@2.0.51","kind":"HOW","packages":["pkg:npm/node-releases@2.0.51"],"schemaVersion":1,"symbols":["node-releases.slice"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/node-releases@2.0.51"],"schemaVersion":1,"subject":"pkg:npm/node-releases@2.0.51","symbols":["node-releases.slice"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-node-releases-slice",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-node-releases-slice",
      "version": "1.0.0",
      "dependencies": {
        "node-releases": "2.0.51"
      }
    },
    "node_modules/node-releases": {
      "version": "2.0.51",
      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.51.tgz",
      "integrity": "sha512-wRNIrw4DmVLKQlbgOMdkMx27Wrpzes2hh5Jtbi2bjPd+4wJstWIqP5A+lscnqbm0xxmT5Bpg8Lec5ItEBwx6BQ==",
      "license": "MIT",
      "engines": {
        "node": ">=18"
      }
    }
  }
}
package.json
{
  "name": "sample-node-releases-slice",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "node-releases": "2.0.51"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify node-releases.slice in pkg:npm/node-releases@2.0.51",
  "kind": "HOW",
  "packages": [
    "pkg:npm/node-releases@2.0.51"
  ],
  "symbols": [
    "node-releases.slice"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import envs from 'node-releases/data/processed/envs.json' with { type: 'json' };

// Ensure source data is valid array
assert.ok(Array.isArray(envs), 'envs must be an array');
const initialLength = envs.length;
assert.ok(initialLength > 0, 'envs must contain records');

// 1. slice extracts a subset of release records without mutating the source envs array
const firstTen = envs.slice(0, 10);
assert.equal(firstTen.length, 10, 'Sliced length should be 10');
assert.equal(envs.length, initialLength, 'Original envs length must remain unchanged');
assert.deepEqual(firstTen[0], envs[0], 'First element of slice must match original');
assert.deepEqual(firstTen[9], envs[9], 'Tenth element of slice must match original');

// 2. slice with positive start and end extracts the exact range of release records
const range = envs.slice(5, 15);
assert.equal(range.length, 10, 'Range slice length should be 10');
assert.deepEqual(range[0], envs[5], 'First element of range must equal envs[5]');
assert.deepEqual(range[9], envs[14], 'Last element of range must equal envs[14]');

// 3. slice with negative start extracts the most recent N releases from the end of the array
const recentFive = envs.slice(-5);
assert.equal(recentFive.length, 5, 'Negative start slice should have 5 items');
assert.deepEqual(recentFive[0], envs[initialLength - 5], 'First element of negative slice must match corresponding tail index');
assert.deepEqual(recentFive[4], envs[initialLength - 1], 'Last element of negative slice must match last release');

// 4. slice with start index greater than or equal to array length returns an empty array
const emptySlice = envs.slice(initialLength + 10);
assert.ok(Array.isArray(emptySlice), 'Empty slice must be an array');
assert.equal(emptySlice.length, 0, 'Empty slice length must be 0');

// 5. slice without arguments creates a shallow copy of all release records with identical elements
const fullCopy = envs.slice();
assert.notEqual(fullCopy, envs, 'Slice shallow copy must have different reference');
assert.equal(fullCopy.length, initialLength, 'Shallow copy must have same length as source');
assert.deepEqual(fullCopy[0], envs[0], 'First element of copy must match source');
assert.deepEqual(fullCopy[initialLength - 1], envs[initialLength - 1], 'Last element of copy must match source');

// 6. slice with negative start exceeding array length normalizes to index zero and returns elements from start
const clampedSlice = envs.slice(-1000, 3);
assert.equal(clampedSlice.length, 3, 'Slice with large negative start should start at index 0');
assert.deepEqual(clampedSlice[0], envs[0], 'Element at index 0 should match source[0]');

// CommonJS compatibility check
const require = createRequire(import.meta.url);
const cjsEnvs = require('node-releases/data/processed/envs.json');
assert.ok(Array.isArray(cjsEnvs), 'CJS envs must be an array');
const cjsSlice = cjsEnvs.slice(0, 5);
assert.equal(cjsSlice.length, 5, 'CJS slice should return 5 elements');
assert.deepEqual(cjsSlice[0], cjsEnvs[0], 'CJS slice first element must match');

오리진 시더

익명