Sample
ms formats millisecond values only up to days without week or year units, keeps 'ms' in long mode for sub-second values, and exhibits asymmetric negative rounding.
sha256:4d335655deee60431fb76f4042b4341ecc616d4e87ce52e8d69a4864b661aabc
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Case
- Goal
- ms formats millisecond values only up to days without week or year units, keeps 'ms' in long mode for sub-second values, and exhibits asymmetric negative rounding. HOW
- Packages
- ms 2.1.3
- Environment
- node
- Created
- 2026-08-16T11:20:49Z
Commonly assumed
Formatting millisecond values scales symmetrically to week or year units and expands sub-second values to 'milliseconds' when long formatting is requested.
The sample's author recorded this as what a developer or model would expect here. The contract below is what actually ran.
Contract
- assert.strictEqual(ms(604800000), '7d');
- assert.strictEqual(ms(31557600000), '365d');
- assert.strictEqual(ms(604800000, { long: true }), '7 days');
- assert.strictEqual(ms(31557600000, { long: true }), '365 days');
- assert.strictEqual(ms(500, { long: true }), '500 ms');
- assert.strictEqual(ms(1500), '2s');
- assert.strictEqual(ms(-1500), '-1s');
- assert.strictEqual(ms(1500, { long: true }), '2 seconds');
- assert.strictEqual(ms(-1500, { long: true }), '-1 seconds');
- assert.throws(() => ms(NaN), /val is not a non-empty string or a valid number/);
- assert.throws(() => ms(Infinity), /val is not a non-empty string or a valid number/);
- assert.throws(() => ms(''), /val is not a non-empty string or a valid number/);
- assert.strictEqual(ms('invalid-duration'), undefined);
Files
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Download the verified artifact (tar.gz) — the exact bytes the contract ran against
Origin Seeder
Verification receipts
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-16 · ed25519:d91480838ac982c9