Пример
natural-compare 1.4.0
Проверенный пример — npm natural-compare 1.4.0. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: naturalCompare returns 0 for identical…
sha256:d12664cfaec501fbb2a0c93f1e2bfbdaf99e565cfb9b86e8167c0f1b1d2be386
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-20 |
Кейс
HOW- Цель
- verify pkg:npm/natural-compare@1.4.0
- Пакеты
- Окружение
- node 22.23.2
- Создан
- 2026-08-20T18:43:23Z
Контракт
- naturalCompare returns 0 for identical strings and empty strings
- naturalCompare sorts multi-digit numbers embedded in strings in natural numerical order
- naturalCompare orders alphabetical strings in ascending lexicographical order
- naturalCompare places uppercase characters before lowercase characters in default sorting order
- naturalCompare works as a comparator with Array.prototype.sort to naturally order string lists
- naturalCompare coerces non-string arguments to strings before performing comparison
- naturalCompare supports custom character precedence configured on String.alphabet
Файлы
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Исходный код
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/natural-compare@1.4.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/natural-compare@1.4.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- 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:ce4def86c72fdc703c2b91c785893112fbd732a4a5fb75911255c05dbdd49c0b","constraints":{"executionContext":"node"},"contract":["naturalCompare returns 0 for identical strings and empty strings","naturalCompare sorts multi-digit numbers embedded in strings in natural numerical order","naturalCompare orders alphabetical strings in ascending lexicographical order","naturalCompare places uppercase characters before lowercase characters in default sorting order","naturalCompare works as a comparator with Array.prototype.sort to naturally order string lists","naturalCompare coerces non-string arguments to strings before performing comparison","naturalCompare supports custom character precedence configured on String.alphabet"],"goal":"verify pkg:npm/natural-compare@1.4.0","kind":"HOW","packages":["pkg:npm/natural-compare@1.4.0"],"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","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/natural-compare@1.4.0"],"schemaVersion":1,"subject":"pkg:npm/natural-compare@1.4.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-natural-compare",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-natural-compare",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"natural-compare": "1.4.0"
}
},
"node_modules/natural-compare": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
"license": "MIT"
}
}
}
{
"name": "sample-natural-compare",
"version": "1.0.0",
"description": "verify pkg:npm/natural-compare@1.4.0",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"natural-compare": "1.4.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/natural-compare@1.4.0",
"kind": "HOW",
"packages": [
"pkg:npm/natural-compare@1.4.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"runtime": "node@22.23.2"
}
}
'use strict';
const naturalCompare = require('natural-compare');
/**
* Compare two strings in natural sort order.
*
* @param {string|number} a - First value to compare.
* @param {string|number} b - Second value to compare.
* @returns {number} -1 if a < b, 1 if a > b, 0 if equal.
*/
function compare(a, b) {
return naturalCompare(a, b);
}
module.exports = {
naturalCompare,
compare
};
'use strict';
const assert = require('assert');
const { naturalCompare, compare } = require('../src/index');
// 1. Module export verification
{
assert.strictEqual(typeof naturalCompare, 'function');
assert.strictEqual(typeof compare, 'function');
}
// 2. naturalCompare returns 0 for identical strings and empty strings
{
assert.strictEqual(naturalCompare('alpha', 'alpha'), 0);
assert.strictEqual(naturalCompare('', ''), 0);
assert.strictEqual(naturalCompare('item42', 'item42'), 0);
assert.strictEqual(compare('abc', 'abc'), 0);
}
// 3. naturalCompare sorts multi-digit numbers embedded in strings in natural numerical order
{
assert.strictEqual(naturalCompare('file2.txt', 'file10.txt'), -1);
assert.strictEqual(naturalCompare('file10.txt', 'file2.txt'), 1);
assert.strictEqual(naturalCompare('item1', 'item2'), -1);
assert.strictEqual(naturalCompare('img100.png', 'img20.png'), 1);
}
// 4. naturalCompare orders alphabetical strings in ascending lexicographical order
{
assert.strictEqual(naturalCompare('a', 'b'), -1);
assert.strictEqual(naturalCompare('b', 'a'), 1);
assert.strictEqual(naturalCompare('foo', 'bar'), 1);
assert.strictEqual(naturalCompare('bar', 'foo'), -1);
}
// 5. naturalCompare places uppercase characters before lowercase characters in default sorting order
{
assert.strictEqual(naturalCompare('A', 'a'), -1);
assert.strictEqual(naturalCompare('a', 'A'), 1);
assert.strictEqual(naturalCompare('Z', 'a'), -1);
}
// 6. naturalCompare works as a comparator with Array.prototype.sort to naturally order string lists
{
const files = ['file10.txt', 'file2.txt', 'file1.txt', 'file20.txt'];
files.sort(naturalCompare);
assert.deepStrictEqual(files, ['file1.txt', 'file2.txt', 'file10.txt', 'file20.txt']);
const versions = ['v1.10.0', 'v1.2.0', 'v1.1.0'];
versions.sort(naturalCompare);
assert.deepStrictEqual(versions, ['v1.1.0', 'v1.2.0', 'v1.10.0']);
}
// 7. naturalCompare coerces non-string arguments to strings before performing comparison
{
assert.strictEqual(naturalCompare(2, 10), -1);
assert.strictEqual(naturalCompare(10, 2), 1);
assert.strictEqual(naturalCompare(5, 5), 0);
}
// 8. naturalCompare supports custom character precedence configured on String.alphabet
{
String.alphabet = 'BAb';
assert.strictEqual(naturalCompare('B', 'A'), -1);
assert.strictEqual(naturalCompare('A', 'B'), 1);
delete String.alphabet;
}
console.log('All natural-compare contract tests passed.');
Исходный сидер
аноним