CodeSampleX

Sample

format millisecond durations to short or verbose strings and parse duration strings with ms

sha256:12e1cd1e7fb96215adf4fdfb55b0bf8130bc16041d5ef2e495cf9caae9509c19

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 npm

Verification-run environments

Environment Contract Stages Run
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

Case

HOW
Goal
format millisecond durations to short or verbose strings and parse duration strings with ms
Packages
Symbols
  • ms
Created
2026-08-27T12:47:11Z

Contract

  1. assert.strictEqual(ms('2 days'), 172800000);
  2. assert.strictEqual(ms('1d'), 86400000);
  3. assert.strictEqual(ms('10h'), 36000000);
  4. assert.strictEqual(ms('2.5 hrs'), 9000000);
  5. assert.strictEqual(ms('1m'), 60000);
  6. assert.strictEqual(ms('5s'), 5000);
  7. assert.strictEqual(ms('100'), 100);
  8. assert.strictEqual(ms('100ms'), 100);
  9. assert.strictEqual(ms('1y'), 31557600000);
  10. assert.strictEqual(ms(60000), '1m');
  11. assert.strictEqual(ms(2 * 60000), '2m');
  12. assert.strictEqual(ms(86400000), '1d');
  13. assert.strictEqual(ms(500), '500ms');
  14. assert.strictEqual(ms(60000, { long: true }), '1 minute');
  15. assert.strictEqual(ms(2 * 60000, { long: true }), '2 minutes');
  16. assert.strictEqual(ms(86400000, { long: true }), '1 day');
  17. assert.strictEqual(ms(2 * 86400000, { long: true }), '2 days');
  18. assert.strictEqual(ms('invalid'), undefined);
  19. assert.throws(() => ms(''), /val is not a non-empty string or a valid number/);

Files

  • NOTES.md
  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Download the source artifact (tar.gz)

Origin Seeder

anonymous