Beispiel
semver 6.3.1: maxSatisfying
Verifiziertes Beispiel für npm semver 6.3.1: maxSatisfying. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.
sha256:8807006571f3989d88d5ca75d838b8b00f8fced177bd0e2c2795c8c8e86403b6
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
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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-28 |
Fall
HOW- Ziel
- verify semver.maxSatisfying in pkg:npm/semver@6.3.1
- Pakete
- Symbole
-
- semver.maxSatisfying
- Umgebung
- node 22.23.2
- Erstellt
- 2026-08-28T02:31:54Z
Contract
- assert semver.maxSatisfying returns the highest version in an array satisfying a caret range
- assert semver.maxSatisfying returns the highest version matching a bounded comparison range
- assert semver.maxSatisfying returns null when no version satisfies the specified range
- assert semver.maxSatisfying returns null for an empty array of versions
- assert semver.maxSatisfying respects the includePrerelease option to match prerelease versions
- assert semver.maxSatisfying respects the loose option for loose version string formats
Dateien
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- 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 semver.maxSatisfying in pkg:npm/semver@6.3.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/semver@6.3.1
Demonstrate these symbols/APIs:
- semver.maxSatisfying
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.
{"case":{"caseId":"case:sha256:96c0f1a505fbad0f8b71e44a6ea7d669004518616050c09ddf89b98a28568844","constraints":{"executionContext":"node"},"contract":["assert semver.maxSatisfying returns the highest version in an array satisfying a caret range","assert semver.maxSatisfying returns the highest version matching a bounded comparison range","assert semver.maxSatisfying returns null when no version satisfies the specified range","assert semver.maxSatisfying returns null for an empty array of versions","assert semver.maxSatisfying respects the includePrerelease option to match prerelease versions","assert semver.maxSatisfying respects the loose option for loose version string formats"],"goal":"verify semver.maxSatisfying in pkg:npm/semver@6.3.1","kind":"HOW","packages":["pkg:npm/semver@6.3.1"],"schemaVersion":1,"symbols":["semver.maxSatisfying"]},"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/semver@6.3.1"],"schemaVersion":1,"subject":"pkg:npm/semver@6.3.1","symbols":["semver.maxSatisfying"],"verifierAdapter":"node-typescript@1"}
const semver = require('semver');
/**
* Finds the maximum satisfying version from a list of versions against a range.
*
* @param {string[]} versions - Array of version strings.
* @param {string} range - Semver range string.
* @param {object} [options] - Options object (e.g., includePrerelease, loose).
* @returns {string|null} The highest satisfying version string, or null if none match.
*/
function findMaxSatisfying(versions, range, options) {
return semver.maxSatisfying(versions, range, options);
}
module.exports = {
findMaxSatisfying,
semver,
};
{
"name": "sample-semver-max-satisfying",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-semver-max-satisfying",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"semver": "6.3.1"
}
},
"node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
}
}
}
}
{
"name": "sample-semver-max-satisfying",
"version": "1.0.0",
"description": "Clean-room sample verifying semver.maxSatisfying functionality",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"semver": "6.3.1"
}
}
{
"schemaVersion": 1,
"goal": "verify semver.maxSatisfying in pkg:npm/semver@6.3.1",
"kind": "HOW",
"packages": [
"pkg:npm/semver@6.3.1"
],
"symbols": [
"semver.maxSatisfying"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert';
import semver from 'semver';
import { findMaxSatisfying } from '../index.js';
// 1. Returns the highest version in an array satisfying a caret range
const versions1 = ['1.2.0', '1.2.3', '1.3.0', '2.0.0', '1.2.9'];
const max1 = findMaxSatisfying(versions1, '^1.2.0');
assert.strictEqual(max1, '1.3.0', 'semver.maxSatisfying must return the highest version satisfying ^1.2.0');
const directMax1 = semver.maxSatisfying(versions1, '^1.2.0');
assert.strictEqual(directMax1, '1.3.0', 'semver.maxSatisfying direct call must return 1.3.0');
// 2. Returns the highest version matching a bounded comparison range
const versions2 = ['1.0.0', '1.4.9', '1.5.0', '1.8.2', '2.0.1'];
const max2 = findMaxSatisfying(versions2, '>=1.0.0 <1.5.0');
assert.strictEqual(max2, '1.4.9', 'semver.maxSatisfying must return highest within range >=1.0.0 <1.5.0');
// 3. Returns null when no version satisfies the specified range
const versions3 = ['1.0.0', '1.2.0', '1.3.0'];
const max3 = findMaxSatisfying(versions3, '^2.0.0');
assert.strictEqual(max3, null, 'semver.maxSatisfying must return null when no version matches');
// 4. Returns null for an empty array of versions
const max4 = findMaxSatisfying([], '^1.0.0');
assert.strictEqual(max4, null, 'semver.maxSatisfying must return null for an empty versions array');
// 5. Respects the includePrerelease option to match prerelease versions
const versions5 = ['1.2.0', '1.2.4-alpha.1', '1.2.4-beta.0'];
const maxNoPrerelease = findMaxSatisfying(versions5, '^1.2.3');
assert.strictEqual(maxNoPrerelease, null, 'semver.maxSatisfying without includePrerelease must return null for prereleases');
const maxWithPrerelease = findMaxSatisfying(versions5, '^1.2.3', { includePrerelease: true });
assert.strictEqual(maxWithPrerelease, '1.2.4-beta.0', 'semver.maxSatisfying with includePrerelease must return the highest matching prerelease');
// 6. Respects the loose option for loose version string formats
const looseVersions = ['v1.2.0', 'v1.3.0', '2.0.0'];
const maxLoose = findMaxSatisfying(looseVersions, '^1.0.0', { loose: true });
assert.strictEqual(maxLoose, 'v1.3.0', 'semver.maxSatisfying with loose option must parse loose version strings');
console.log('All contract assertions passed.');
Ursprungs-Seeder
anonym