hron-wasm 0.6.0 → 1.0.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/README.md +27 -8
- package/hron_wasm.d.ts +5 -0
- package/hron_wasm_bg.js +41 -15
- package/hron_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,31 +13,50 @@ npm install hron-wasm
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```javascript
|
|
16
|
-
import { Schedule, fromCron } from "hron-wasm";
|
|
16
|
+
import { Schedule, fromCron, explainCron } from "hron-wasm";
|
|
17
17
|
|
|
18
18
|
// Parse an expression
|
|
19
19
|
const schedule = Schedule.parse("every weekday at 9:00 in America/New_York");
|
|
20
20
|
|
|
21
|
-
// Next occurrence (ISO string
|
|
22
|
-
const
|
|
21
|
+
// Next occurrence from a given datetime (ISO 8601 string)
|
|
22
|
+
const now = new Date().toISOString();
|
|
23
|
+
const next = schedule.nextFrom(now);
|
|
23
24
|
|
|
24
25
|
// Next N occurrences
|
|
25
|
-
const nextFive = schedule.
|
|
26
|
+
const nextFive = schedule.nextNFrom(now, 5);
|
|
26
27
|
|
|
27
|
-
//
|
|
28
|
+
// Previous occurrence before a given datetime
|
|
29
|
+
const prev = schedule.previousFrom(now);
|
|
30
|
+
|
|
31
|
+
// Check if a datetime matches
|
|
32
|
+
const isMatch = schedule.matches(now);
|
|
33
|
+
|
|
34
|
+
// Lazy iteration: occurrences after `from`, limited to `limit` results
|
|
35
|
+
const occ = schedule.occurrences(now, 10);
|
|
36
|
+
|
|
37
|
+
// Bounded range: occurrences where from < t <= to
|
|
38
|
+
const range = schedule.between("2026-01-01T00:00:00Z", "2026-12-31T23:59:59Z");
|
|
39
|
+
|
|
40
|
+
// Convert to cron (if expressible)
|
|
28
41
|
const cron = schedule.toCron();
|
|
29
42
|
|
|
30
43
|
// Convert from cron
|
|
31
44
|
const fromCronSchedule = fromCron("0 9 * * *");
|
|
32
45
|
|
|
33
|
-
//
|
|
46
|
+
// Explain a cron expression in human-readable form
|
|
47
|
+
const explanation = explainCron("0 9 * * 1-5");
|
|
48
|
+
|
|
49
|
+
// Structured JSON representation
|
|
34
50
|
const json = schedule.toJSON();
|
|
35
51
|
|
|
36
|
-
// Canonical string
|
|
52
|
+
// Canonical string (roundtrip-safe)
|
|
37
53
|
const str = schedule.toString();
|
|
38
54
|
|
|
39
|
-
// Validate
|
|
55
|
+
// Validate without parsing
|
|
40
56
|
const valid = Schedule.validate("every day at 9:00");
|
|
57
|
+
|
|
58
|
+
// Timezone getter
|
|
59
|
+
const tz = schedule.timezone; // "America/New_York" or undefined
|
|
41
60
|
```
|
|
42
61
|
|
|
43
62
|
## License
|
package/hron_wasm.d.ts
CHANGED
|
@@ -60,6 +60,11 @@ export class Schedule {
|
|
|
60
60
|
readonly timezone: string | undefined;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Explain a cron expression in human-readable form.
|
|
65
|
+
*/
|
|
66
|
+
export function explainCron(cron_expr: string): string;
|
|
67
|
+
|
|
63
68
|
/**
|
|
64
69
|
* Parse a cron expression and return an hron Schedule.
|
|
65
70
|
*/
|
package/hron_wasm_bg.js
CHANGED
|
@@ -210,6 +210,32 @@ export class Schedule {
|
|
|
210
210
|
}
|
|
211
211
|
if (Symbol.dispose) Schedule.prototype[Symbol.dispose] = Schedule.prototype.free;
|
|
212
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Explain a cron expression in human-readable form.
|
|
215
|
+
* @param {string} cron_expr
|
|
216
|
+
* @returns {string}
|
|
217
|
+
*/
|
|
218
|
+
export function explainCron(cron_expr) {
|
|
219
|
+
let deferred3_0;
|
|
220
|
+
let deferred3_1;
|
|
221
|
+
try {
|
|
222
|
+
const ptr0 = passStringToWasm0(cron_expr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
223
|
+
const len0 = WASM_VECTOR_LEN;
|
|
224
|
+
const ret = wasm.explainCron(ptr0, len0);
|
|
225
|
+
var ptr2 = ret[0];
|
|
226
|
+
var len2 = ret[1];
|
|
227
|
+
if (ret[3]) {
|
|
228
|
+
ptr2 = 0; len2 = 0;
|
|
229
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
230
|
+
}
|
|
231
|
+
deferred3_0 = ptr2;
|
|
232
|
+
deferred3_1 = len2;
|
|
233
|
+
return getStringFromWasm0(ptr2, len2);
|
|
234
|
+
} finally {
|
|
235
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
213
239
|
/**
|
|
214
240
|
* Parse a cron expression and return an hron Schedule.
|
|
215
241
|
* @param {string} cron_expr
|
|
@@ -224,50 +250,50 @@ export function fromCron(cron_expr) {
|
|
|
224
250
|
}
|
|
225
251
|
return Schedule.__wrap(ret[0]);
|
|
226
252
|
}
|
|
227
|
-
export function
|
|
253
|
+
export function __wbg_Error_25ba92dc73c79ff8(arg0, arg1) {
|
|
228
254
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
229
255
|
return ret;
|
|
230
256
|
}
|
|
231
|
-
export function
|
|
257
|
+
export function __wbg_Number_70eda1af1f0de797(arg0) {
|
|
232
258
|
const ret = Number(arg0);
|
|
233
259
|
return ret;
|
|
234
260
|
}
|
|
235
|
-
export function
|
|
261
|
+
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
236
262
|
const ret = String(arg1);
|
|
237
263
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
238
264
|
const len1 = WASM_VECTOR_LEN;
|
|
239
265
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
240
266
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
241
267
|
}
|
|
242
|
-
export function
|
|
268
|
+
export function __wbg___wbindgen_is_string_dfb64101caa98453(arg0) {
|
|
243
269
|
const ret = typeof(arg0) === 'string';
|
|
244
270
|
return ret;
|
|
245
271
|
}
|
|
246
|
-
export function
|
|
272
|
+
export function __wbg___wbindgen_throw_f1861aae416df39d(arg0, arg1) {
|
|
247
273
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
248
274
|
}
|
|
249
|
-
export function
|
|
275
|
+
export function __wbg_new_1b4edd8807f9a802() {
|
|
250
276
|
const ret = new Object();
|
|
251
277
|
return ret;
|
|
252
278
|
}
|
|
253
|
-
export function
|
|
254
|
-
const ret = new
|
|
279
|
+
export function __wbg_new_8189744b546559b4() {
|
|
280
|
+
const ret = new Map();
|
|
255
281
|
return ret;
|
|
256
282
|
}
|
|
257
|
-
export function
|
|
258
|
-
const ret = new
|
|
283
|
+
export function __wbg_new_dcf435def74b2b31() {
|
|
284
|
+
const ret = new Array();
|
|
259
285
|
return ret;
|
|
260
286
|
}
|
|
261
|
-
export function
|
|
287
|
+
export function __wbg_set_411d76b94557fe0d(arg0, arg1, arg2) {
|
|
262
288
|
const ret = arg0.set(arg1, arg2);
|
|
263
289
|
return ret;
|
|
264
290
|
}
|
|
265
|
-
export function
|
|
266
|
-
arg0[arg1] = arg2;
|
|
267
|
-
}
|
|
268
|
-
export function __wbg_set_f43e577aea94465b(arg0, arg1, arg2) {
|
|
291
|
+
export function __wbg_set_58d19822a2826a42(arg0, arg1, arg2) {
|
|
269
292
|
arg0[arg1 >>> 0] = arg2;
|
|
270
293
|
}
|
|
294
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
295
|
+
arg0[arg1] = arg2;
|
|
296
|
+
}
|
|
271
297
|
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
272
298
|
// Cast intrinsic for `F64 -> Externref`.
|
|
273
299
|
const ret = arg0;
|
package/hron_wasm_bg.wasm
CHANGED
|
Binary file
|