CodeSampleX

Exemple

fill-range 7.1.1: fill-range

Échantillon vérifié pour npm fill-range 7.1.1: fill-range. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.

sha256:ae392d5816c600a656fcca041f30719787351a53cb764c7c39c9ed84e30e6590

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
1
Clés de signature qui l’ont compilé
1
Environnement déclaré node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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-02

Cas

HOW
Objectif
verify fill-range in pkg:npm/fill-range@7.1.1
Paquets
Symboles
  • fill-range
Environnement
node 22.23.2
Créé
2026-09-02T00:46:46Z

Contrat

  1. fill expands numerical integer ranges in ascending and descending order
  2. fill expands numerical ranges with custom step increments
  3. fill expands alphabetical character ranges in ascending and descending order
  4. fill preserves zero-padding format when string inputs have leading zeros
  5. fill transforms output values using a custom transform function
  6. fill converts number ranges to string arrays when stringify option is enabled
  7. fill generates regex range patterns when toRegex option is enabled
  8. fill handles single-argument and invalid range options

Fichiers

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

Télécharger l’artefact source (tar.gz)

Code source

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 fill-range in pkg:npm/fill-range@7.1.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/fill-range@7.1.1
Demonstrate these symbols/APIs:
  - fill-range
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.
csx.json
{"case":{"caseId":"case:sha256:c9bad71e17ac0ad3dcc480b2a4898fb369e9c84a07b66fed3e338791c7854a9b","constraints":{"executionContext":"node"},"contract":["fill expands numerical integer ranges in ascending and descending order","fill expands numerical ranges with custom step increments","fill expands alphabetical character ranges in ascending and descending order","fill preserves zero-padding format when string inputs have leading zeros","fill transforms output values using a custom transform function","fill converts number ranges to string arrays when stringify option is enabled","fill generates regex range patterns when toRegex option is enabled","fill handles single-argument and invalid range options"],"goal":"verify fill-range in pkg:npm/fill-range@7.1.1","kind":"HOW","packages":["pkg:npm/fill-range@7.1.1"],"schemaVersion":1,"symbols":["fill-range"]},"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/fill-range@7.1.1"],"schemaVersion":1,"subject":"pkg:npm/fill-range@7.1.1","symbols":["fill-range"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-fill-range",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-fill-range",
      "version": "1.0.0",
      "dependencies": {
        "fill-range": "7.1.1"
      }
    },
    "node_modules/fill-range": {
      "version": "7.1.1",
      "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
      "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
      "license": "MIT",
      "dependencies": {
        "to-regex-range": "^5.0.1"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/is-number": {
      "version": "7.0.0",
      "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
      "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
      "license": "MIT",
      "engines": {
        "node": ">=0.12.0"
      }
    },
    "node_modules/to-regex-range": {
      "version": "5.0.1",
      "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
      "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
      "license": "MIT",
      "dependencies": {
        "is-number": "^7.0.0"
      },
      "engines": {
        "node": ">=8.0"
      }
    }
  }
}
package.json
{
  "name": "sample-fill-range",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "fill-range": "7.1.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify fill-range in pkg:npm/fill-range@7.1.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/fill-range@7.1.1"
  ],
  "symbols": [
    "fill-range"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import fill from 'fill-range';

// 1. fill expands numerical integer ranges in ascending and descending order
{
  assert.deepEqual(fill(1, 5), [1, 2, 3, 4, 5]);
  assert.deepEqual(fill(5, 1), [5, 4, 3, 2, 1]);
  assert.deepEqual(fill(-2, 2), [-2, -1, 0, 1, 2]);
  assert.deepEqual(fill(0, 0), [0]);
}

// 2. fill expands numerical ranges with custom step increments
{
  assert.deepEqual(fill(1, 10, 2), [1, 3, 5, 7, 9]);
  assert.deepEqual(fill(10, 1, 2), [10, 8, 6, 4, 2]);
  assert.deepEqual(fill(1, 10, 3), [1, 4, 7, 10]);
  assert.deepEqual(fill(0, 20, 5), [0, 5, 10, 15, 20]);
}

// 3. fill expands alphabetical character ranges in ascending and descending order
{
  assert.deepEqual(fill('a', 'e'), ['a', 'b', 'c', 'd', 'e']);
  assert.deepEqual(fill('e', 'a'), ['e', 'd', 'c', 'b', 'a']);
  assert.deepEqual(fill('A', 'E', 2), ['A', 'C', 'E']);
  assert.deepEqual(fill('z', 'v', 2), ['z', 'x', 'v']);
}

// 4. fill preserves zero-padding format when string inputs have leading zeros
{
  assert.deepEqual(fill('01', '05'), ['01', '02', '03', '04', '05']);
  assert.deepEqual(fill('001', '005'), ['001', '002', '003', '004', '005']);
  assert.deepEqual(fill('01', '10', 2), ['01', '03', '05', '07', '09']);
  assert.deepEqual(fill('05', '01'), ['05', '04', '03', '02', '01']);
}

// 5. fill transforms output values using a custom transform function
{
  const result1 = fill(1, 3, (val) => String.fromCharCode(val + 64));
  assert.deepEqual(result1, ['A', 'B', 'C']);

  const result2 = fill(1, 3, (val) => val * 10);
  assert.deepEqual(result2, [10, 20, 30]);

  const result3 = fill(1, 3, { transform: (val, index) => `${index}:${val}` });
  assert.deepEqual(result3, ['0:1', '1:2', '2:3']);
}

// 6. fill converts number ranges to string arrays when stringify option is enabled
{
  assert.deepEqual(fill(1, 5, { stringify: true }), ['1', '2', '3', '4', '5']);
  assert.deepEqual(fill(-2, 2, { stringify: true }), ['-2', '-1', '0', '1', '2']);
}

// 7. fill generates regex range patterns when toRegex option is enabled
{
  assert.equal(fill(1, 5, { toRegex: true }), '[1-5]');
  assert.equal(fill('a', 'e', { toRegex: true }), '[a-e]');
  assert.equal(fill(1, 10, 2, { toRegex: true }), '1|3|5|7|9');
  assert.equal(fill('01', '05', { toRegex: true }), '0?[1-5]');
}

// 8. fill handles single-argument and invalid range options
{
  assert.deepEqual(fill(1), [1]);
  assert.deepEqual(fill('a'), ['a']);
  assert.deepEqual(fill(1, 'foo'), []);
  assert.throws(
    () => fill(1, 'foo', { strictRanges: true }),
    /^RangeError: Invalid range arguments:/
  );
  assert.throws(
    () => fill(1, 5, 'invalid_step', { strictRanges: true }),
    /^TypeError: Expected step "invalid_step" to be a number/
  );
}

Seeder d'origine

anonyme