サンプル
semver 5.7.2: eq
検証済みサンプル — npm semver 5.7.2: eq. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: semver.eq returns true for identical semantic version strings…
sha256:7d9bb92fbd8d6a6561aed447d48e11761fddcc8db760600a3d209d447ad37029
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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-27 |
ケース
HOW- ゴール
- verify semver.eq in pkg:npm/semver@5.7.2
- パッケージ
- シンボル
-
- semver.eq
- 環境
- node 22.23.2
- 作成日
- 2026-08-27T19:59:39Z
コントラクト
- semver.eq returns true for identical semantic version strings and versions with leading v prefix
- semver.eq returns true when versions differ only by build metadata
- semver.eq returns false for different major, minor, or patch versions
- semver.eq returns false when prerelease identifiers differ
- semver.eq returns true for SemVer class instances with identical versions
- semver.eq parses non-standard prefixed version strings when loose mode is enabled
- semver.eq throws TypeError when an invalid version string is passed
ファイル
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
ソース
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.eq in pkg:npm/semver@5.7.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/semver@5.7.2
Demonstrate these symbols/APIs:
- semver.eq
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:44b6781e1b15a29fa7922c29fbbb8a0564adcea375f3d1dda8395596c178267e","contract":["semver.eq returns true for identical semantic version strings and versions with leading v prefix","semver.eq returns true when versions differ only by build metadata","semver.eq returns false for different major, minor, or patch versions","semver.eq returns false when prerelease identifiers differ","semver.eq returns true for SemVer class instances with identical versions","semver.eq parses non-standard prefixed version strings when loose mode is enabled","semver.eq throws TypeError when an invalid version string is passed"],"goal":"verify semver.eq in pkg:npm/semver@5.7.2","kind":"HOW","packages":["pkg:npm/semver@5.7.2"],"schemaVersion":1,"symbols":["semver.eq"]},"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@5.7.2"],"schemaVersion":1,"subject":"pkg:npm/semver@5.7.2","symbols":["semver.eq"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-semver-eq",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-semver-eq",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"semver": "5.7.2"
}
},
"node_modules/semver": {
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
"integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
"license": "ISC",
"bin": {
"semver": "bin/semver"
}
}
}
}
{
"name": "sample-semver-eq",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of semver.eq semantic version equality comparison",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"semver": "5.7.2"
}
}
{
"schemaVersion": 1,
"goal": "verify semver.eq in pkg:npm/semver@5.7.2",
"kind": "HOW",
"packages": [
"pkg:npm/semver@5.7.2"
],
"symbols": [
"semver.eq"
]
}
const semver = require('semver');
/**
* Compares two semantic version strings for equality.
*
* @param {string|semver.SemVer} v1 - First version string or SemVer instance.
* @param {string|semver.SemVer} v2 - Second version string or SemVer instance.
* @param {boolean} [loose] - Whether to allow non-standard versions like '=1.2.3'.
* @returns {boolean} True if versions are semantically equal, false otherwise.
*/
function isEqual(v1, v2, loose) {
return semver.eq(v1, v2, loose);
}
module.exports = {
semver,
isEqual,
eq: semver.eq
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { semver, isEqual, eq } = require('../src/index.js');
// 1. Export verification
assert.ok(typeof semver === 'function' || typeof semver === 'object', 'semver module must be exported');
assert.equal(typeof isEqual, 'function', 'isEqual helper must be exported');
assert.equal(typeof eq, 'function', 'eq method must be exported');
// 2. semver.eq returns true for identical semantic version strings and versions with leading v prefix
{
assert.equal(eq('1.2.3', '1.2.3'), true, 'identical versions must be equal');
assert.equal(isEqual('v1.2.3', '1.2.3'), true, 'version with leading v prefix must match without prefix');
assert.equal(eq('v1.2.3', 'v1.2.3'), true, 'both versions with leading v prefix must be equal');
assert.equal(eq('0.0.4', '0.0.4'), true, 'zero-based versions must be equal');
}
// 3. semver.eq returns true when versions differ only by build metadata
{
assert.equal(eq('1.2.3+build1', '1.2.3+build2'), true, 'build metadata should be ignored in equality comparison');
assert.equal(isEqual('1.2.3+20130313144700', '1.2.3'), true, 'timestamp build metadata should be ignored');
assert.equal(eq('1.2.3-alpha+001', '1.2.3-alpha+002'), true, 'prerelease build metadata differences must be ignored');
}
// 4. semver.eq returns false for different major, minor, or patch versions
{
assert.equal(eq('1.2.3', '1.2.4'), false, 'different patch versions must not be equal');
assert.equal(eq('1.2.3', '1.3.3'), false, 'different minor versions must not be equal');
assert.equal(isEqual('1.2.3', '2.2.3'), false, 'different major versions must not be equal');
}
// 5. semver.eq returns false when prerelease identifiers differ
{
assert.equal(eq('1.2.3-alpha', '1.2.3-alpha'), true, 'identical prerelease versions must be equal');
assert.equal(eq('1.2.3-alpha', '1.2.3-beta'), false, 'different prerelease identifiers must not be equal');
assert.equal(isEqual('1.2.3-alpha.1', '1.2.3-alpha.2'), false, 'different prerelease numeric parts must not be equal');
assert.equal(eq('1.2.3', '1.2.3-alpha'), false, 'release version and prerelease version must not be equal');
}
// 6. semver.eq returns true for SemVer class instances with identical versions
{
const v1 = new semver.SemVer('1.2.3');
const v2 = new semver.SemVer('1.2.3');
const v3 = new semver.SemVer('1.2.4');
assert.equal(eq(v1, v2), true, 'two SemVer instances with same version must be equal');
assert.equal(isEqual(v1, '1.2.3'), true, 'SemVer instance and string version must be equal');
assert.equal(eq('1.2.3', v1), true, 'string version and SemVer instance must be equal');
assert.equal(eq(v1, v3), false, 'two SemVer instances with different versions must not be equal');
}
// 7. semver.eq parses non-standard prefixed version strings when loose mode is enabled
{
assert.equal(eq('=1.2.3', '1.2.3', true), true, 'equals-prefixed version must parse in loose mode');
assert.equal(isEqual(' =v1.2.3 ', '1.2.3', true), true, 'spaced equals-v-prefixed version must parse in loose mode');
}
// 8. semver.eq throws TypeError when an invalid version string is passed
{
assert.throws(() => eq('=1.2.3', '1.2.3', false), TypeError, 'strict mode must throw TypeError on equals-prefix');
assert.throws(() => eq('invalid.version', '1.2.3'), TypeError, 'invalid version must throw TypeError');
assert.throws(() => isEqual('1.2.3', 'invalid.version'), TypeError, 'invalid second version must throw TypeError');
assert.throws(() => eq(null, '1.2.3'), TypeError, 'null version must throw TypeError');
assert.throws(() => eq(undefined, '1.2.3'), TypeError, 'undefined version must throw TypeError');
}
console.log('Contract assertions passed.');
オリジンシーダー
匿名