Now that Temporal has been standardized and ships in most browsers and will likely ship in a future version of Node.js, we should see if it could replace ms.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal#browser_compatibility
A few examples:
Temporal.Duration.from({ seconds: 5 }).total({ unit: 'milliseconds' }); // 5000
Temporal.Duration.from({ minutes: 3 }).total({ unit: 'milliseconds' }); // 180000
Temporal.Duration.from({ hours: 2 }).total({ unit: 'milliseconds' }); // 7200000
Temporal.Duration.from({ days: 1 }).total({ unit: 'milliseconds' }); // 86400000
There is even short hand string syntax (ISO 8601) such as:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Duration#iso_8601_duration_format
Temporal.Duration.from('PT5S').total({ unit: 'milliseconds' }); // 5000
Temporal.Duration.from('PT3M').total({ unit: 'milliseconds' }); // 180000
Temporal.Duration.from('PT2H').total({ unit: 'milliseconds' }); // 7200000
Temporal.Duration.from('P1D').total({ unit: 'milliseconds' }); // 86400000
There are still other features to consider and it only makes sense if we can make ms smaller than it already is.
In an ideal world, you wouldn't need to install ms at all 😄
Now that
Temporalhas been standardized and ships in most browsers and will likely ship in a future version of Node.js, we should see if it could replacems.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal#browser_compatibility
A few examples:
There is even short hand string syntax (ISO 8601) such as:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Duration#iso_8601_duration_format
There are still other features to consider and it only makes sense if we can make
mssmaller than it already is.In an ideal world, you wouldn't need to install
msat all 😄