CodeSampleX

Ejemplo

normalize-path 3.0.0: normalize-path

Muestra verificada para npm normalize-path 3.0.0: normalize-path. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó.

sha256:b1be00664597e49ac87ffc036ec3f0dc18c2cf15a24c6c0a520289243b9d6da1

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
2
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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
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

Caso

HOW
Objetivo
verify normalize-path in pkg:npm/normalize-path@3.0.0
Paquetes
Símbolos
  • normalize-path
Entorno
node 22.23.2
Creado
2026-08-26T11:13:02Z

Contrato

  1. assert normalize-path converts Windows backslashes to forward slashes
  2. assert normalize-path collapses duplicate consecutive slashes
  3. assert normalize-path strips trailing slash by default
  4. assert normalize-path preserves trailing slash when stripTrailing is false
  5. assert normalize-path preserves Win32 extended-length namespace prefix
  6. assert normalize-path throws TypeError when passed a non-string argument

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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 normalize-path in pkg:npm/normalize-path@3.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/normalize-path@3.0.0
Demonstrate these symbols/APIs:
  - normalize-path

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:63e6f67640f14b5150e15624d7a265f1f8a09b3a3c728e2de1bfe6282ba86e5c","contract":["assert normalize-path converts Windows backslashes to forward slashes","assert normalize-path collapses duplicate consecutive slashes","assert normalize-path strips trailing slash by default","assert normalize-path preserves trailing slash when stripTrailing is false","assert normalize-path preserves Win32 extended-length namespace prefix","assert normalize-path throws TypeError when passed a non-string argument"],"goal":"verify normalize-path in pkg:npm/normalize-path@3.0.0","kind":"HOW","packages":["pkg:npm/normalize-path@3.0.0"],"schemaVersion":1,"symbols":["normalize-path"]},"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/normalize-path@3.0.0"],"schemaVersion":1,"subject":"pkg:npm/normalize-path@3.0.0","symbols":["normalize-path"],"verifierAdapter":"node-typescript@1"}
index.js
const normalizePath = require('normalize-path');

/**
 * Normalizes file paths to use forward slashes.
 *
 * @param {string} path - The path string to normalize.
 * @param {boolean} [stripTrailing=true] - Whether to remove trailing slashes.
 * @returns {string} The normalized path.
 */
function normalize(path, stripTrailing) {
  return normalizePath(path, stripTrailing);
}

module.exports = {
  normalize,
  normalizePath,
};
package-lock.json
{
  "name": "sample-normalize-path",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-normalize-path",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "normalize-path": "3.0.0"
      }
    },
    "node_modules/normalize-path": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
      "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    }
  }
}
package.json
{
  "name": "sample-normalize-path",
  "version": "1.0.0",
  "description": "Clean-room sample verifying normalize-path functionality",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "normalize-path": "3.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify normalize-path in pkg:npm/normalize-path@3.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/normalize-path@3.0.0"
  ],
  "symbols": [
    "normalize-path"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import normalizePath from 'normalize-path';
import { normalize } from '../index.js';

// 1. Converts Windows backslashes to forward slashes
assert.strictEqual(
  normalize('foo\\bar\\baz'),
  'foo/bar/baz',
  'normalize-path must convert Windows backslashes to forward slashes'
);
assert.strictEqual(
  normalize('sub\\path\\to\\file.txt'),
  'sub/path/to/file.txt',
  'normalize-path must normalize Windows style path'
);

// 2. Collapses duplicate consecutive slashes
assert.strictEqual(
  normalize('foo//bar///baz'),
  'foo/bar/baz',
  'normalize-path must collapse multiple consecutive slashes'
);
assert.strictEqual(
  normalize('foo\\\\bar\\\\\\baz'),
  'foo/bar/baz',
  'normalize-path must collapse multiple consecutive backslashes'
);

// 3. Strips trailing slash by default
assert.strictEqual(
  normalize('foo/bar/'),
  'foo/bar',
  'normalize-path must strip trailing slash by default'
);
assert.strictEqual(
  normalize('foo\\bar\\'),
  'foo/bar',
  'normalize-path must strip trailing backslash by default'
);
assert.strictEqual(
  normalize('/'),
  '/',
  'normalize-path must preserve root slash'
);
assert.strictEqual(
  normalize('\\'),
  '/',
  'normalize-path must normalize single backslash to root slash'
);

// 4. Preserves trailing slash when stripTrailing is false
assert.strictEqual(
  normalize('foo/bar/', false),
  'foo/bar/',
  'normalize-path must preserve trailing slash when stripTrailing is false'
);
assert.strictEqual(
  normalize('foo\\bar\\', false),
  'foo/bar/',
  'normalize-path must convert backslash and preserve trailing slash when stripTrailing is false'
);

// 5. Preserves Win32 extended-length namespace prefix
assert.strictEqual(
  normalize('\\\\?\\dev\\foo\\bar'),
  '//?/dev/foo/bar',
  'normalize-path must handle Win32 ? namespace prefix'
);
assert.strictEqual(
  normalize('\\\\.\\dev\\foo\\bar'),
  '//./dev/foo/bar',
  'normalize-path must handle Win32 . namespace prefix'
);

// 6. Throws TypeError when passed a non-string argument
assert.throws(
  () => normalize(123),
  {
    name: 'TypeError',
    message: 'expected path to be a string',
  },
  'normalize-path must throw TypeError when argument is not a string'
);
assert.throws(
  () => normalize(null),
  {
    name: 'TypeError',
    message: 'expected path to be a string',
  },
  'normalize-path must throw TypeError for null input'
);

console.log('All contract assertions passed.');

Seeder de origen

anónimo