@nxtedition/scheduler 1.0.5 → 1.0.6

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/lib/index.d.ts CHANGED
@@ -8,5 +8,5 @@ export declare class Scheduler {
8
8
  constructor(opts?: SharedArrayBuffer | {
9
9
  concurrency?: number;
10
10
  });
11
- schedule(fn: (next: Function) => any, priority?: 1): any;
11
+ schedule(fn: (next: Function) => any, priority?: 0 | 1 | 2 | "low" | "normal" | "high"): any;
12
12
  }
package/lib/index.js CHANGED
@@ -43,16 +43,24 @@ export class Scheduler {
43
43
  }
44
44
  }
45
45
 
46
- schedule(fn , priority = Scheduler.NORMAL) {
46
+ schedule(fn , priority = Scheduler.NORMAL) {
47
47
  if (typeof fn !== 'function') {
48
48
  throw new TypeError('First argument must be a function')
49
49
  }
50
50
 
51
51
  if (priority == null) {
52
52
  priority = Scheduler.NORMAL
53
- }
54
-
55
- if (!Number.isInteger(priority)) {
53
+ } else if (typeof priority === 'string') {
54
+ if (priority === 'low') {
55
+ priority = Scheduler.LOW
56
+ } else if (priority === 'normal') {
57
+ priority = Scheduler.NORMAL
58
+ } else if (priority === 'high') {
59
+ priority = Scheduler.HIGH
60
+ } else {
61
+ throw new Error('Invalid priority')
62
+ }
63
+ } else if (!Number.isInteger(priority)) {
56
64
  throw new Error('Invalid priority')
57
65
  }
58
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/scheduler",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -20,5 +20,5 @@
20
20
  "rimraf": "^6.1.2",
21
21
  "typescript": "^5.9.3"
22
22
  },
23
- "gitHead": "8317f7c58c48ff5a16b3380f3b9f4c87c56e8500"
23
+ "gitHead": "1c0ae17fb7bb015b6f352befd2c629bc5ad0ea64"
24
24
  }