샘플
ms 2.1.3
검증된 샘플 — npm ms 2.1.3. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: ms parses string durations like '2 days', '1d', '10h', '1m', '5s' to…
sha256:550ff249e4aa7b6b5a4ed24ca536403dd8755168c2111c58fb1835c94fa9eae8
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 2
선언된 환경
node 22 windows 11 x64 node 22 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify pkg:npm/ms@2.1.3
- 패키지
- 환경
- node 22
- 생성일
- 2026-08-18T19:19:25Z
컨트랙트
- 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
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- 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/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');
오리진 시더
익명