Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including human-elapsed with all npm packages installed. Try it out:

const HumanToElapsed = require('human-elapsed') const tests = [ [ 'should return every unit in plural', 1000122, '11 days 13 hours 48 minutes 42 seconds' ], [ 'should return every unit in singular', 90061, '1 day 1 hour 1 minute 1 second' ], [ 'should return only 1 day', 86400, '1 day' ], [ 'should return only 1 hour', 3600, '1 hour' ], [ 'should return only 1 minute', 60, '1 minute' ], [ 'should return only 1 second', 1, '1 second' ], [ 'should return blank', 0, '' ] ] const execution = tests .map(([desc, test, expected]) => { return { desc, pass: HumanToElapsed(test) === expected, result: HumanToElapsed(test), expected } }) .map(itm => { const retval = `${'✔'} ${itm.desc}` if (itm.pass) { return [null, retval] } else { return [ [ itm.desc, `expected: ${itm.expected}`, `returned: ${itm.result}` ].join('\n - '), null ] } }) execution .filter(([fail]) => !fail) .forEach(([,success]) => { console.log(success) }) const fail = execution.filter(([fail]) => fail) fail.forEach(([fail]) => { console.error(`${`✗`} ${fail}`) })

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

human-elapsed v1.0.3

A small module that translates seconds to elapsed (human) time

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free