Beispiel
pathe 2.0.3: basename
Verifiziertes Beispiel für npm pathe 2.0.3: basename. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand: pathe.basename extracts the last…
sha256:9a61e1cea052e0b26db8099b519f01ba33667c51d46190d6b1f131f042ae559c
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 npm
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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-04 |
Fall
HOW- Ziel
- verify pathe.basename in pkg:npm/pathe@2.0.3
- Pakete
- Symbole
-
- pathe.basename
- Erstellt
- 2026-09-04T13:16:30Z
Contract
- pathe.basename extracts the last portion of a POSIX path
- pathe.basename strips a specified file extension or suffix from the filename
- pathe.basename normalizes Windows backslashes and extracts filename from Windows path
- pathe.basename handles trailing slashes by ignoring them and returning directory basename
- pathe.basename returns an empty string for root or empty path inputs
- pathe.basename returns the input unchanged when given a bare filename without path separators
Dateien
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Quelltext
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 pathe.basename in pkg:npm/pathe@2.0.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/pathe@2.0.3
Demonstrate these symbols/APIs:
- pathe.basename
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:20de455ed2020fa60d7572d724464c7c313b9d4922b700588f51d7f5d9f03f00","contract":["pathe.basename extracts the last portion of a POSIX path","pathe.basename strips a specified file extension or suffix from the filename","pathe.basename normalizes Windows backslashes and extracts filename from Windows path","pathe.basename handles trailing slashes by ignoring them and returning directory basename","pathe.basename returns an empty string for root or empty path inputs","pathe.basename returns the input unchanged when given a bare filename without path separators"],"goal":"verify pathe.basename in pkg:npm/pathe@2.0.3","kind":"HOW","packages":["pkg:npm/pathe@2.0.3"],"schemaVersion":1,"symbols":["pathe.basename"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/pathe@2.0.3"],"schemaVersion":1,"subject":"pkg:npm/pathe@2.0.3","symbols":["pathe.basename"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-pathe-basename",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-pathe-basename",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"pathe": "2.0.3"
}
},
"node_modules/pathe": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
"integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",
"license": "MIT"
}
}
}
{
"name": "sample-pathe-basename",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of pathe.basename in pkg:npm/pathe@2.0.3",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"pathe": "2.0.3"
}
}
{
"schemaVersion": 1,
"goal": "verify pathe.basename in pkg:npm/pathe@2.0.3",
"kind": "HOW",
"packages": [
"pkg:npm/pathe@2.0.3"
],
"symbols": [
"pathe.basename"
]
}
const { basename } = require('pathe');
/**
* Returns the last portion of a path, similar to the Unix basename command.
* Trailing directory separators are ignored, and Windows backslashes are normalized to forward slashes.
*
* @param {string} path - The path to evaluate.
* @param {string} [ext] - An optional extension to remove from the result.
* @returns {string} The last portion of the given path.
*/
function getBasename(path, ext) {
return basename(path, ext);
}
/**
* Extracts the filename without the specified extension.
*
* @param {string} path - The path to evaluate.
* @param {string} ext - The extension to strip.
* @returns {string} The filename without extension.
*/
function getFilenameWithoutExtension(path, ext) {
return basename(path, ext);
}
module.exports = {
basename,
getBasename,
getFilenameWithoutExtension
};
import assert from 'node:assert';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { basename, getBasename, getFilenameWithoutExtension } = require('../src/index.js');
// 1. pathe.basename extracts the last portion of a POSIX path
assert.strictEqual(basename('/path/to/file.ext'), 'file.ext');
assert.strictEqual(basename('path/to/file.ext'), 'file.ext');
assert.strictEqual(basename('/a/b/c'), 'c');
assert.strictEqual(getBasename('/path/to/file.ext'), 'file.ext');
// 2. pathe.basename strips a specified file extension or suffix from the filename
assert.strictEqual(basename('/path/to/file.ext', '.ext'), 'file');
assert.strictEqual(basename('script.test.js', '.js'), 'script.test');
assert.strictEqual(basename('document.pdf', '.txt'), 'document.pdf');
assert.strictEqual(basename('/path/to/file.ext', 'ext'), 'file.');
assert.strictEqual(getFilenameWithoutExtension('/path/to/file.ext', '.ext'), 'file');
// 3. pathe.basename normalizes Windows backslashes and extracts filename from Windows path
assert.strictEqual(basename('foo\\bar\\file.txt'), 'file.txt');
assert.strictEqual(basename('dir\\subdir\\test.json'), 'test.json');
assert.strictEqual(basename('dir\\subdir\\test.json', '.json'), 'test');
assert.strictEqual(getBasename('foo\\bar\\file.txt'), 'file.txt');
// 4. pathe.basename handles trailing slashes by ignoring them and returning directory basename
assert.strictEqual(basename('/dir/subdir/'), 'subdir');
assert.strictEqual(basename('a/b/c/'), 'c');
assert.strictEqual(basename('dir\\subdir\\'), 'subdir');
assert.strictEqual(getBasename('/dir/subdir/'), 'subdir');
// 5. pathe.basename returns an empty string for root or empty path inputs
assert.strictEqual(basename(''), '');
assert.strictEqual(basename('/'), '');
assert.strictEqual(basename('///'), '');
assert.strictEqual(getBasename(''), '');
// 6. pathe.basename returns the input unchanged when given a bare filename without path separators
assert.strictEqual(basename('file.txt'), 'file.txt');
assert.strictEqual(basename('filename'), 'filename');
assert.strictEqual(getBasename('file.txt'), 'file.txt');
console.log('Contract tests passed successfully.');
Ursprungs-Seeder
anonym