Ejemplo
ms 2.1.3
Muestra verificada para npm ms 2.1.3. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: ms parses string durations like '2 days', '1d'…
sha256:550ff249e4aa7b6b5a4ed24ca536403dd8755168c2111c58fb1835c94fa9eae8
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
- 2
Entorno declarado
node 22 windows 11 x64 node 22 javascript npm 10
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-19 |
| 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-09-07 |
Caso
HOW- Objetivo
- verify pkg:npm/ms@2.1.3
- Paquetes
- Entorno
- node 22
- Creado
- 2026-08-18T19:19:25Z
Contrato
- ms parses string durations like '2 days', '1d', '10h', '1m', '5s' to milliseconds
- ms parses negative duration strings like '-3 days' and '-1h' to negative milliseconds
- ms formats milliseconds to compact duration strings like '1m' and '2m'
- ms formats milliseconds with long option to human-readable strings like '1 minute' and '2 minutes'
- ms returns undefined for unparseable duration strings
- ms throws Error for empty string or invalid input types
Archivos
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.js
Código fuente
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/ms@2.1.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/ms@2.1.3
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@11.8.0
- runtime: node@24.13.1
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:3cf3a7f10c763a7c6c42b7150621433fe67c34484b782b4d06ff41f4e68d273a","constraints":{"executionContext":"node"},"contract":["ms parses string durations like '2 days', '1d', '10h', '1m', '5s' to milliseconds","ms parses negative duration strings like '-3 days' and '-1h' to negative milliseconds","ms formats milliseconds to compact duration strings like '1m' and '2m'","ms formats milliseconds with long option to human-readable strings like '1 minute' and '2 minutes'","ms returns undefined for unparseable duration strings","ms throws Error for empty string or invalid input types"],"goal":"verify pkg:npm/ms@2.1.3","kind":"HOW","packages":["pkg:npm/ms@2.1.3"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"javascript","moduleSystem":"cjs","os":"windows","osVersionBucket":"11","packageManager":"npm","packageManagerVersion":"10","runtime":"node","runtimeVersion":"22","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/ms@2.1.3"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
const ms = require('ms');
/**
* Parses a string duration to milliseconds or formats milliseconds to a string.
* @param {string|number} value
* @param {object} [options]
* @returns {number|string|undefined}
*/
function parseOrFormat(value, options) {
return ms(value, options);
}
module.exports = {
parseOrFormat,
};
{
"name": "sample-ms",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-ms",
"version": "1.0.0",
"dependencies": {
"ms": "2.1.3"
}
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
}
}
}
{
"name": "sample-ms",
"version": "1.0.0",
"private": true,
"description": "Verification sample for ms",
"main": "index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"ms": "2.1.3"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/ms@2.1.3",
"kind": "HOW",
"packages": [
"pkg:npm/ms@2.1.3"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@11.8.0",
"runtime": "node@24.13.1"
}
}
const assert = require('node:assert/strict');
const ms = require('ms');
const { parseOrFormat } = require('../index.js');
// 1. Parsing string durations to milliseconds
assert.equal(ms('2 days'), 172800000);
assert.equal(ms('1d'), 86400000);
assert.equal(ms('10h'), 36000000);
assert.equal(ms('2.5 hrs'), 9000000);
assert.equal(ms('2h'), 7200000);
assert.equal(ms('1m'), 60000);
assert.equal(ms('5s'), 5000);
assert.equal(ms('1y'), 31557600000);
assert.equal(ms('100'), 100);
assert.equal(ms('-3 days'), -259200000);
assert.equal(ms('-1h'), -3600000);
assert.equal(ms('-200'), -200);
// 2. Formatting milliseconds to short string
assert.equal(ms(60000), '1m');
assert.equal(ms(2 * 60000), '2m');
assert.equal(ms(ms('10 hours')), '10h');
// 3. Formatting milliseconds with long option
assert.equal(ms(60000, { long: true }), '1 minute');
assert.equal(ms(2 * 60000, { long: true }), '2 minutes');
// 4. Verify wrapper function behaves identically
assert.equal(parseOrFormat('1d'), 86400000);
assert.equal(parseOrFormat(60000), '1m');
assert.equal(parseOrFormat(60000, { long: true }), '1 minute');
// 5. Unparseable string returns undefined
assert.equal(ms('invalid-string'), undefined);
// 6. Empty string or non-string/number throws Error
assert.throws(() => ms(''), /val is not a non-empty string/);
assert.throws(() => ms(null), /val is not a non-empty string/);
assert.throws(() => ms(NaN), /val is not a non-empty string/);
console.log('Contract assertions passed for pkg:npm/ms@2.1.3');
Seeder de origen
anónimo