hron-wasm 0.2.0 → 0.3.2

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/hron_wasm.d.ts CHANGED
@@ -9,14 +9,17 @@ export class Schedule {
9
9
  free(): void;
10
10
  [Symbol.dispose](): void;
11
11
  /**
12
- * Get the next occurrence as an ISO string.
13
- * Uses UTC as the default timezone in WASM.
12
+ * Check if a datetime matches this schedule.
14
13
  */
15
- next(): string | undefined;
14
+ matches(datetime: string): boolean;
16
15
  /**
17
- * Get the next N occurrences as an array of ISO strings.
16
+ * Compute the next occurrence after `now`.
18
17
  */
19
- nextN(n: number): any;
18
+ nextFrom(now: string): string | undefined;
19
+ /**
20
+ * Compute the next `n` occurrences after `now`.
21
+ */
22
+ nextNFrom(now: string, n: number): any;
20
23
  /**
21
24
  * Parse an hron expression string.
22
25
  */
@@ -37,6 +40,10 @@ export class Schedule {
37
40
  * Validate an expression (returns true if valid).
38
41
  */
39
42
  static validate(input: string): boolean;
43
+ /**
44
+ * Get the timezone, if specified.
45
+ */
46
+ readonly timezone: string | undefined;
40
47
  }
41
48
 
42
49
  /**
package/hron_wasm_bg.js CHANGED
@@ -20,29 +20,48 @@ export class Schedule {
20
20
  wasm.__wbg_schedule_free(ptr, 0);
21
21
  }
22
22
  /**
23
- * Get the next occurrence as an ISO string.
24
- * Uses UTC as the default timezone in WASM.
23
+ * Check if a datetime matches this schedule.
24
+ * @param {string} datetime
25
+ * @returns {boolean}
26
+ */
27
+ matches(datetime) {
28
+ const ptr0 = passStringToWasm0(datetime, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
29
+ const len0 = WASM_VECTOR_LEN;
30
+ const ret = wasm.schedule_matches(this.__wbg_ptr, ptr0, len0);
31
+ if (ret[2]) {
32
+ throw takeFromExternrefTable0(ret[1]);
33
+ }
34
+ return ret[0] !== 0;
35
+ }
36
+ /**
37
+ * Compute the next occurrence after `now`.
38
+ * @param {string} now
25
39
  * @returns {string | undefined}
26
40
  */
27
- next() {
28
- const ret = wasm.schedule_next(this.__wbg_ptr);
41
+ nextFrom(now) {
42
+ const ptr0 = passStringToWasm0(now, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
43
+ const len0 = WASM_VECTOR_LEN;
44
+ const ret = wasm.schedule_nextFrom(this.__wbg_ptr, ptr0, len0);
29
45
  if (ret[3]) {
30
46
  throw takeFromExternrefTable0(ret[2]);
31
47
  }
32
- let v1;
48
+ let v2;
33
49
  if (ret[0] !== 0) {
34
- v1 = getStringFromWasm0(ret[0], ret[1]).slice();
50
+ v2 = getStringFromWasm0(ret[0], ret[1]).slice();
35
51
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
36
52
  }
37
- return v1;
53
+ return v2;
38
54
  }
39
55
  /**
40
- * Get the next N occurrences as an array of ISO strings.
56
+ * Compute the next `n` occurrences after `now`.
57
+ * @param {string} now
41
58
  * @param {number} n
42
59
  * @returns {any}
43
60
  */
44
- nextN(n) {
45
- const ret = wasm.schedule_nextN(this.__wbg_ptr, n);
61
+ nextNFrom(now, n) {
62
+ const ptr0 = passStringToWasm0(now, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
63
+ const len0 = WASM_VECTOR_LEN;
64
+ const ret = wasm.schedule_nextNFrom(this.__wbg_ptr, ptr0, len0, n);
46
65
  if (ret[2]) {
47
66
  throw takeFromExternrefTable0(ret[1]);
48
67
  }
@@ -62,6 +81,19 @@ export class Schedule {
62
81
  }
63
82
  return Schedule.__wrap(ret[0]);
64
83
  }
84
+ /**
85
+ * Get the timezone, if specified.
86
+ * @returns {string | undefined}
87
+ */
88
+ get timezone() {
89
+ const ret = wasm.schedule_timezone(this.__wbg_ptr);
90
+ let v1;
91
+ if (ret[0] !== 0) {
92
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
93
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
94
+ }
95
+ return v1;
96
+ }
65
97
  /**
66
98
  * Convert this schedule to a cron expression (if possible).
67
99
  * @returns {string}
@@ -169,18 +201,10 @@ export function __wbg___wbindgen_string_get_72fb696202c56729(arg0, arg1) {
169
201
  export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
170
202
  throw new Error(getStringFromWasm0(arg0, arg1));
171
203
  }
172
- export function __wbg_getTime_1e3cd1391c5c3995(arg0) {
173
- const ret = arg0.getTime();
174
- return ret;
175
- }
176
204
  export function __wbg_get_b3ed3ad4be2bc8ac() { return handleError(function (arg0, arg1) {
177
205
  const ret = Reflect.get(arg0, arg1);
178
206
  return ret;
179
207
  }, arguments); }
180
- export function __wbg_new_0_73afc35eb544e539() {
181
- const ret = new Date();
182
- return ret;
183
- }
184
208
  export function __wbg_new_361308b2356cecd0() {
185
209
  const ret = new Object();
186
210
  return ret;
package/hron_wasm_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "hron-wasm",
3
3
  "type": "module",
4
4
  "description": "WASM bindings for hron — human-readable cron",
5
- "version": "0.2.0",
5
+ "version": "0.3.2",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",