mobiletto-orm-scan-typedef 1.0.6 → 1.0.8
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/esm/constants.d.ts +5 -0
- package/lib/esm/constants.js +22 -0
- package/package.json +2 -2
package/lib/esm/constants.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { MobilettoClock } from "./types.js";
|
|
2
2
|
export declare const DEFAULT_CLOCK: MobilettoClock;
|
|
3
3
|
export declare const sleep: (ms: number) => Promise<unknown>;
|
|
4
|
+
export declare const DEFAULT_NAP_CHECK = 1000;
|
|
5
|
+
export type NapAlarm = {
|
|
6
|
+
wake?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const nap: (clock: MobilettoClock, alarm: NapAlarm, ms: number, check?: number) => Promise<unknown>;
|
package/lib/esm/constants.js
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
export const DEFAULT_CLOCK = {
|
|
2
11
|
now: () => Date.now(),
|
|
3
12
|
};
|
|
4
13
|
// adapted from https://stackoverflow.com/a/39914235
|
|
5
14
|
export const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
15
|
+
export const DEFAULT_NAP_CHECK = 1000;
|
|
16
|
+
const _nap = (resolve, clock, alarm, ms, check) => () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
try {
|
|
18
|
+
const start = clock.now();
|
|
19
|
+
while (!alarm.wake && clock.now() - start < ms) {
|
|
20
|
+
yield sleep(check);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
resolve();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
export const nap = (clock, alarm, ms, check) => new Promise((r) => _nap(r, clock, alarm, ms, check || DEFAULT_NAP_CHECK)());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobiletto-orm-scan-typedef",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Mobiletto-orm typedefs and constants for mobiletto-orm-scan",
|
|
6
6
|
"keywords": [
|
|
@@ -51,6 +51,6 @@
|
|
|
51
51
|
"typescript": "^5.1.6"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"mobiletto-orm-typedef": "^2.4.
|
|
54
|
+
"mobiletto-orm-typedef": "^2.4.5"
|
|
55
55
|
}
|
|
56
56
|
}
|