hron-ts 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/index.cjs +1988 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +167 -0
- package/dist/index.d.ts +167 -0
- package/dist/index.js +1959 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Prasanna Ram Venkatachalam
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# hron-js (TypeScript)
|
|
2
|
+
|
|
3
|
+
Native TypeScript implementation of [hron](https://github.com/prasrvenkat/hron) — human-readable cron expressions.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install hron-js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Schedule, Temporal } from "hron-js";
|
|
15
|
+
|
|
16
|
+
// Parse an expression
|
|
17
|
+
const schedule = Schedule.parse("every weekday at 9:00 in America/New_York");
|
|
18
|
+
|
|
19
|
+
// Compute next occurrence
|
|
20
|
+
const now = Temporal.Now.zonedDateTimeISO();
|
|
21
|
+
const next = schedule.nextFrom(now);
|
|
22
|
+
|
|
23
|
+
// Compute next N occurrences
|
|
24
|
+
const nextFive = schedule.nextNFrom(now, 5);
|
|
25
|
+
|
|
26
|
+
// Check if a datetime matches
|
|
27
|
+
const matches = schedule.matches(now);
|
|
28
|
+
|
|
29
|
+
// Convert to cron (expressible subset only)
|
|
30
|
+
const cron = Schedule.parse("every day at 9:00").toCron();
|
|
31
|
+
|
|
32
|
+
// Convert from cron
|
|
33
|
+
const fromCron = Schedule.fromCron("0 9 * * *");
|
|
34
|
+
|
|
35
|
+
// Canonical string (roundtrip-safe)
|
|
36
|
+
console.log(schedule.toString());
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Temporal Polyfill
|
|
40
|
+
|
|
41
|
+
This package uses the [Temporal API](https://tc39.es/proposal-temporal/) via `@js-temporal/polyfill`. Once Temporal ships natively in runtimes, performance improves automatically. For performance-critical use cases, consider the WASM package (`hron-wasm`).
|
|
42
|
+
|
|
43
|
+
## Tests
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
pnpm test
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Uses vitest. Conformance tests driven by `spec/tests.json`.
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
MIT
|