codekingpro/portable-devtools
114k
1'use strict'
2
3/**
4 * Checks if the given value is a valid LastEventId.
5 * @param {string} value
6 * @returns {boolean}
7 */
8function isValidLastEventId (value) {
9 // LastEventId should not contain U+0000 NULL
10 return value.indexOf('\u0000') === -1
11}
12
13/**
14 * Checks if the given value is a base 10 digit.
15 * @param {string} value
16 * @returns {boolean}
17 */
18function isASCIINumber (value) {
19 if (value.length === 0) return false
20 for (let i = 0; i < value.length; i++) {
21 if (value.charCodeAt(i) < 0x30 || value.charCodeAt(i) > 0x39) return false
22 }
23 return true
24}
25
26// https://github.com/nodejs/undici/issues/2664
27function delay (ms) {
28 return new Promise((resolve) => {
29 setTimeout(resolve, ms).unref()
30 })
31}
32
33module.exports = {
34 isValidLastEventId,
35 isASCIINumber,
36 delay
37}
38 