mirror of
https://github.com/cupcakearmy/uhrwerk.git
synced 2024-12-23 07:56:24 +00:00
Compare commits
2 Commits
ec25164cba
...
99d35a9ade
Author | SHA1 | Date | |
---|---|---|---|
99d35a9ade | |||
8679a04346 |
21
README.md
21
README.md
@ -1,22 +1,19 @@
|
||||
# uhrwerk 🕰
|
||||
|
||||
![dependencies](https://badgen.net/david/dep/cupcakearmy/uhrwerk)
|
||||
![downloads badge](https://badgen.net/npm/dt/uhrwerk)
|
||||
![types badge](https://badgen.net/npm/types/uhrwerk)
|
||||
![version badge](https://badgen.net/npm/v/uhrwerk)
|
||||
![minzip size badge](https://badgen.net/bundlephobia/minzip/uhrwerk)
|
||||
![package size](https://img.shields.io/bundlephobia/min/uhrwerk?style=flat)
|
||||
![downloads badge](https://img.shields.io/npm/dt/uhrwerk)
|
||||
![types badge](https://img.shields.io/npm/types/uhrwerk)
|
||||
![version badge](https://img.shields.io/npm/v/uhrwerk)
|
||||
|
||||
Minimal time duration utility. Replacement for MomentJS Durations. If you are looking into the time component of MomentJS check out this awesome library [dayjs](https://github.com/iamkun/dayjs).
|
||||
|
||||
📦 It's **tiny**: [1.6kB](https://bundlephobia.com/result?p=uhrwerk@1.0.0) vs moment js [231.7kb](https://bundlephobia.com/result?p=moment@latest)
|
||||
📦 It's **tiny**: [2kB](https://bundlephobia.com/package/uhrwerk@latest) vs moment js [295kB](https://bundlephobia.com/result?p=moment@latest)
|
||||
|
||||
**Typescript typings included**
|
||||
🌈 No dependencies, types included.
|
||||
|
||||
## Quickstart 🚀
|
||||
|
||||
```typescript
|
||||
// Whatever import you prefer
|
||||
// const { Duration } = require('uhrwerk')
|
||||
import { Duration } from 'uhrwerk'
|
||||
|
||||
const d = new Duration(10, 'days')
|
||||
@ -51,7 +48,7 @@ d.humanize() // 'a few minutes'
|
||||
const a = new Duration(1, 'day')
|
||||
const b = new Duration(2, 'days')
|
||||
const c = new Duration(0.5, 'year')
|
||||
const d = new Duration (Date.now(), 'ms')
|
||||
const d = new Duration(Date.now(), 'ms')
|
||||
```
|
||||
|
||||
#### `.add(amount, interval)`
|
||||
@ -144,8 +141,8 @@ The order of the array is important. The first match will return, like in a stan
|
||||
|
||||
```javascript
|
||||
const humanizer = [
|
||||
[d => d.days() > 1, d => `${d.days()} days`],
|
||||
[d => d.days() > 0, d => `1 day`],
|
||||
[(d) => d.days() > 1, (d) => `${d.days()} days`],
|
||||
[(d) => d.days() > 0, (d) => `1 day`],
|
||||
[() => true, () => 'catch all, below 1 day'],
|
||||
]
|
||||
|
||||
|
11
package.json
11
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "uhrwerk",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"description": "time utility",
|
||||
"author": "Niccolo Borgioli",
|
||||
"license": "MIT",
|
||||
@ -25,12 +25,13 @@
|
||||
"keywords": [
|
||||
"time",
|
||||
"interval",
|
||||
"humand-readable",
|
||||
"human-readable",
|
||||
"utility"
|
||||
],
|
||||
"devDependencies": {
|
||||
"mocha": "~10.0.0",
|
||||
"tsup": "^6.1.3",
|
||||
"typescript": "~4.7.4"
|
||||
"@tsconfig/strictest": "^2.0.3",
|
||||
"mocha": "^10.3.0",
|
||||
"tsup": "^8.0.2",
|
||||
"typescript": "^5.3.3"
|
||||
}
|
||||
}
|
||||
|
1189
pnpm-lock.yaml
generated
1189
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,23 +1,10 @@
|
||||
{
|
||||
"extends": "@tsconfig/strictest/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "es2020",
|
||||
"module": "commonjs",
|
||||
"target": "es2022",
|
||||
"module": "es2022",
|
||||
"declaration": true,
|
||||
"outDir": "./lib",
|
||||
"rootDir": "./src",
|
||||
"removeComments": true,
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictBindCallApply": true,
|
||||
"strictPropertyInitialization": true,
|
||||
"noImplicitThis": true,
|
||||
"alwaysStrict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user