Comparing version 1.0.5 to 1.0.6
@@ -1,2 +0,2 @@ | ||
"use strict";const e=36e5,t=24*e,n={year:315576e5,month:30*t,week:7*t,day:t,hour:e,minute:6e4,second:1e3};exports.datePlus=(e,t=new Date)=>new Date(t.getTime()+(e=>{if(+e)return+e;const[,t,r]=e.match(/^([^ ]+) +(\w\w*?)s?$/)||[];return+t*(n[r]||1)})(e)); | ||
"use strict";const e=36e5,t=24*e,n={year:315576e5,month:30*t,week:7*t,day:t,hour:e,minute:6e4,second:1e3,m:1};exports.datePlus=(e,t=new Date)=>new Date(t.getTime()+(e=>{if(+e)return+e;const[,t,r]=e.match(/^([^ ]+) +(\w\w*?)s?$/)||[];return+t*(n[r]||1)})(e)); | ||
//# sourceMappingURL=datePlus.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";const e=36e5,t=24*e,o={year:315576e5,month:30*t,week:7*t,day:t,hour:e,minute:6e4,second:1e3};exports.duration=(e,{parts:t=9,join:n=", "}={})=>{let r,s=[];for(let[i,u]of Object.entries(o))e>u&&t-- >0&&(e-=(r=e/u|0)*u,t&&"second"!=i||(r+=e/u),r>1&&(i+="s"),s.push(n?r+" "+i:[i,r]));return n?s.join(n):s}; | ||
"use strict";const e=36e5,t=24*e,o={year:315576e5,month:30*t,week:7*t,day:t,hour:e,minute:6e4,second:1e3,m:1};exports.duration=(e,{parts:t=9,join:r=", "}={})=>{let n,s=[];for(let[i,u]of Object.entries(o))e>=u&&t-- >0&&(e-=(n=e/u|0)*u,t||(n+=e/u),1==n&&"m"!=i||(i+="s"),s.push(r?n+" "+i:[i,n]));return r?s.join(r):s}; | ||
//# sourceMappingURL=duration.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";const e=36e5,t=24*e,s={year:315576e5,month:30*t,week:7*t,day:t,hour:e,minute:6e4,second:1e3},r=e=>{if(+e)return+e;const[,t,r]=e.match(/^([^ ]+) +(\w\w*?)s?$/)||[];return+t*(s[r]||1)};exports.datePlus=(e,t=new Date)=>new Date(t.getTime()+r(e)),exports.duration=(e,{parts:t=9,join:r=", "}={})=>{let n,o=[];for(let[u,a]of Object.entries(s))e>a&&t-- >0&&(e-=(n=e/a|0)*a,t&&"second"!=u||(n+=e/a),n>1&&(u+="s"),o.push(r?n+" "+u:[u,n]));return r?o.join(r):o},exports.ms=r,exports.seconds=e=>r(e)/1e3; | ||
"use strict";const e=36e5,t=24*e,s={year:315576e5,month:30*t,week:7*t,day:t,hour:e,minute:6e4,second:1e3,m:1},r=e=>{if(+e)return+e;const[,t,r]=e.match(/^([^ ]+) +(\w\w*?)s?$/)||[];return+t*(s[r]||1)};exports.datePlus=(e,t=new Date)=>new Date(t.getTime()+r(e)),exports.duration=(e,{parts:t=9,join:r=", "}={})=>{let n,o=[];for(let[u,a]of Object.entries(s))e>=a&&t-- >0&&(e-=(n=e/a|0)*a,t||(n+=e/a),1==n&&"m"!=u||(u+="s"),o.push(r?n+" "+u:[u,n]));return r?o.join(r):o},exports.ms=r,exports.seconds=e=>r(e)/1e3; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";const e=36e5,t=24*e,r={year:315576e5,month:30*t,week:7*t,day:t,hour:e,minute:6e4,second:1e3};exports.ms=e=>{if(+e)return+e;const[,t,s]=e.match(/^([^ ]+) +(\w\w*?)s?$/)||[];return+t*(r[s]||1)}; | ||
"use strict";const e=36e5,t=24*e,r={year:315576e5,month:30*t,week:7*t,day:t,hour:e,minute:6e4,second:1e3,m:1};exports.ms=e=>{if(+e)return+e;const[,t,s]=e.match(/^([^ ]+) +(\w\w*?)s?$/)||[];return+t*(r[s]||1)}; | ||
//# sourceMappingURL=ms.js.map |
{ | ||
"name": "itty-time", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Ultra-small (~390 bytes) library for TTL date math and converting ms durations to and from strings.", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -15,3 +15,3 @@ <br /> | ||
### [v1 Documentation](https://itty.dev/itty-time) | [Discord](https://discord.gg/53vyrZAu9u) | ||
### [v1 Documentation](https://itty.dev/itty-time) | [Discord](https://discord.gg/53vyrZAu9u) | ||
@@ -32,3 +32,3 @@ --- | ||
| --- | :-: | :-: | :-: | :-: | | ||
| [itty-time](https://www.npmjs.com/package/itty-time) | ✅ | ✅ | ✅ | 386b | | ||
| [itty-time](https://www.npmjs.com/package/itty-time) | ✅ | ✅ | ✅ | 391b | | ||
| [@lukeed/ms](https://www.npmjs.com/package/@lukeed/ms) | ✅ | ✅ | ❌ | 435b | | ||
@@ -43,7 +43,7 @@ | [ms](https://www.npmjs.com/package/ms) | ✅ | ❌ | ❌ | 938b | | ||
The only function most folks care about in terms of raw performance is string to ms conversion. In this, itty stacks up pretty well, being significantly faster than [ms](https://www.npmjs.com/package/ms), but falling to the insanely-optimized [@lukeed/ms](https://www.npmjs.com/package/@lukeed/ms). | ||
The only function most folks care about in terms of raw performance is string to ms conversion. In this, itty stacks up pretty well, being significantly faster than [ms](https://www.npmjs.com/package/ms), but falling to the insanely-optimized [@lukeed/ms](https://www.npmjs.com/package/@lukeed/ms). | ||
![image](https://github.com/kwhitley/itty-time/assets/865416/71170005-7962-4bc8-9a66-f4ad5713e545) | ||
Moral of the story, probably don't use [ms](https://www.npmjs.com/package/ms). | ||
Moral of the story, probably don't use [ms](https://www.npmjs.com/package/ms). | ||
@@ -84,3 +84,3 @@ Use Luke's if you want the absolute fastest parsing, or itty if you want some of the other functions as well. If you're byte-counting, itty wins again, but if you're byte-counting that hard, you're probably better off with raw ms math if you can stomach it. | ||
Of course, we sometimes need to go the other direction. Want to tell a user how long ago something happened? How much time they have left? | ||
Of course, we sometimes need to go the other direction. Want to tell a user how long ago something happened? How much time they have left? | ||
@@ -87,0 +87,0 @@ You could build it yourself, or import the fantastic [humanize-duration](https://www.npmjs.com/package/humanize-duration) library that inspired this, but at 6.3kB<sup>1</sup>, it's over 20x the size of this 280 byte function. |
@@ -1,2 +0,2 @@ | ||
"use strict";const e=36e5,t=24*e,s={year:315576e5,month:30*t,week:7*t,day:t,hour:e,minute:6e4,second:1e3};exports.seconds=e=>(e=>{if(+e)return+e;const[,t,n]=e.match(/^([^ ]+) +(\w\w*?)s?$/)||[];return+t*(s[n]||1)})(e)/1e3; | ||
"use strict";const e=36e5,t=24*e,s={year:315576e5,month:30*t,week:7*t,day:t,hour:e,minute:6e4,second:1e3,m:1};exports.seconds=e=>(e=>{if(+e)return+e;const[,t,n]=e.match(/^([^ ]+) +(\w\w*?)s?$/)||[];return+t*(s[n]||1)})(e)/1e3; | ||
//# sourceMappingURL=seconds.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
19183