CodeSampleX

Exemple

filelist 1.0.6

Échantillon vérifié pour npm filelist 1.0.6. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : FileList instance includes string…

sha256:74e0b73db78506aeadb79713c3d4afd6932ce67c833fa0ff110a4b956c4929e7

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 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

Cas

HOW
Objectif
verify pkg:npm/filelist@1.0.6
Paquets
Environnement
node 22.23.2
Créé
2026-08-26T07:25:55Z

Contrat

  1. FileList instance includes string filenames and array of filenames
  2. exclude(string) removes exact matching files from the resolved file list
  3. exclude(RegExp) removes pattern matching files from the resolved file list
  4. exclude(Function) removes files that satisfy the predicate function
  5. shouldExclude(filename) returns true for excluded paths and false otherwise
  6. clearInclusions() resets pending additions before resolution
  7. clearExclusions() clears active exclusion patterns
  8. length() returns the number of resolved files in the list
  9. Array methods like map() return a new FileList instance with transformed items
  10. FileList.clone(fl) creates a cloned copy of the FileList

Fichiers

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

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 pkg:npm/filelist@1.0.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/filelist@1.0.6

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:8e54586697e18c168b6aa6352b1349cd8ff088ef0d304e256912e56fc5f4af42","contract":["FileList instance includes string filenames and array of filenames","exclude(string) removes exact matching files from the resolved file list","exclude(RegExp) removes pattern matching files from the resolved file list","exclude(Function) removes files that satisfy the predicate function","shouldExclude(filename) returns true for excluded paths and false otherwise","clearInclusions() resets pending additions before resolution","clearExclusions() clears active exclusion patterns","length() returns the number of resolved files in the list","Array methods like map() return a new FileList instance with transformed items","FileList.clone(fl) creates a cloned copy of the FileList"],"goal":"verify pkg:npm/filelist@1.0.6","kind":"HOW","packages":["pkg:npm/filelist@1.0.6"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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/filelist@1.0.6"],"schemaVersion":1,"subject":"pkg:npm/filelist@1.0.6","verifierAdapter":"node-typescript@1"}
index.js
'use strict';

const { FileList } = require('filelist');

function createFileList(...items) {
  const fl = new FileList();
  if (items.length > 0) {
    fl.include(...items);
  }
  return fl;
}

module.exports = {
  FileList,
  createFileList,
};
package-lock.json
{
  "name": "sample-1138045718",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-1138045718",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "filelist": "1.0.6"
      }
    },
    "node_modules/balanced-match": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
      "license": "MIT"
    },
    "node_modules/brace-expansion": {
      "version": "2.1.4",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
      "integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^1.0.0"
      }
    },
    "node_modules/filelist": {
      "version": "1.0.6",
      "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.6.tgz",
      "integrity": "sha512-5giy2PkLYY1cP39p17Ech+2xlpTRL9HLspOfEgm0L6CwBXBTgsK5ou0JtzYuepxkaQ/tvhCFIJ5uXo0OrM2DxA==",
      "license": "Apache-2.0",
      "dependencies": {
        "minimatch": "^5.0.1"
      }
    },
    "node_modules/minimatch": {
      "version": "5.1.9",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz",
      "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==",
      "license": "ISC",
      "dependencies": {
        "brace-expansion": "^2.0.1"
      },
      "engines": {
        "node": ">=10"
      }
    }
  }
}
package.json
{
  "name": "sample-1138045718",
  "version": "1.0.0",
  "description": "Minimal sample verifying filelist@1.0.6",
  "main": "index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "keywords": [],
  "author": "",
  "license": "MIT-0",
  "dependencies": {
    "filelist": "1.0.6"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/filelist@1.0.6",
  "kind": "HOW",
  "packages": [
    "pkg:npm/filelist@1.0.6"
  ]
}
test/contract.js
'use strict';

const assert = require('assert');
const { FileList, createFileList } = require('../index.js');

function runContract() {
  // 1. FileList instance includes string filenames and array of filenames
  const fl1 = createFileList('foo.txt', 'bar.js');
  fl1.include(['baz.md', 'temp.tmp']);
  assert.deepStrictEqual(fl1.toArray(), ['foo.txt', 'bar.js', 'baz.md', 'temp.tmp']);

  // 2. exclude(string) removes exact matching files from the resolved file list
  const fl2 = new FileList();
  fl2.include('foo.txt', 'bar.js', 'baz.txt');
  fl2.exclude('bar.js');
  assert.deepStrictEqual(fl2.toArray(), ['foo.txt', 'baz.txt']);

  // 3. exclude(RegExp) removes pattern matching files from the resolved file list
  const fl3 = new FileList();
  fl3.include('app.js', 'app.test.js', 'server.js');
  fl3.exclude(/\.test\.js$/);
  assert.deepStrictEqual(fl3.toArray(), ['app.js', 'server.js']);

  // 4. exclude(Function) removes files that satisfy the predicate function
  const fl4 = new FileList();
  fl4.include('doc.md', 'temp1.tmp', 'temp2.tmp');
  fl4.exclude((item) => item.endsWith('.tmp'));
  assert.deepStrictEqual(fl4.toArray(), ['doc.md']);

  // 5. shouldExclude(filename) returns true for excluded paths and false otherwise
  const fl5 = new FileList();
  fl5.exclude(/\.tmp$/);
  fl5.exclude((item) => item.startsWith('ignore-'));
  assert.strictEqual(fl5.shouldExclude('data.tmp'), true);
  assert.strictEqual(fl5.shouldExclude('ignore-me.txt'), true);
  assert.strictEqual(fl5.shouldExclude('valid.txt'), false);

  // 6. clearInclusions() resets pending additions before resolution
  const fl6 = new FileList();
  fl6.include('first.txt');
  fl6.clearInclusions();
  fl6.include('second.txt');
  assert.deepStrictEqual(fl6.toArray(), ['second.txt']);

  // 7. clearExclusions() clears active exclusion patterns
  const fl7 = new FileList();
  fl7.include('item1.js', 'item2.js');
  fl7.exclude('item1.js');
  fl7.clearExclusions();
  assert.deepStrictEqual(fl7.toArray(), ['item1.js', 'item2.js']);

  // 8. length() returns the number of resolved files in the list
  const fl8 = new FileList();
  fl8.include('a.txt', 'b.txt', 'c.txt');
  fl8.exclude('c.txt');
  assert.strictEqual(fl8.length(), 2);

  // 9. Array methods like map() return a new FileList instance with transformed items
  const fl9 = new FileList();
  fl9.include('a.txt', 'b.txt');
  const mapped = fl9.map((f) => f.toUpperCase());
  assert.ok(mapped instanceof FileList);
  assert.deepStrictEqual(mapped.toArray(), ['A.TXT', 'B.TXT']);

  // 10. FileList.clone(fl) creates a cloned copy of the FileList
  const fl10 = new FileList();
  fl10.include('alpha.txt', 'beta.txt');
  const cloned = FileList.clone(fl10);
  assert.ok(cloned instanceof FileList);
  assert.deepStrictEqual(cloned.toArray(), ['alpha.txt', 'beta.txt']);

  console.log('Contract tests passed.');
}

runContract();

Seeder d'origine

anonyme