@tb-dev/utils 1.7.2 → 1.7.4

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/dist/index.cjs CHANGED
@@ -37,7 +37,7 @@ exports.todo = panic.todo;
37
37
  exports.unimplemented = panic.unimplemented;
38
38
  exports.unreachable = panic.unreachable;
39
39
  exports.splitWhitespace = string.splitWhitespace;
40
- exports.flush = promise.flush;
40
+ exports.flushPromises = promise.flushPromises;
41
41
  exports.sleep = promise.sleep;
42
42
  exports.isEmpty = isEmpty;
43
43
  exports.isNullish = isNullish;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { regex } from "./regex.js";
2
2
  import { toArray, trimArray, upsert } from "./array.js";
3
3
  import { panic, todo, unimplemented, unreachable } from "./panic.js";
4
4
  import { splitWhitespace } from "./string.js";
5
- import { flush, sleep } from "./promise.js";
5
+ import { flushPromises, sleep } from "./promise.js";
6
6
  function isEmpty(value) {
7
7
  if (isNullish(value)) {
8
8
  return true;
@@ -27,7 +27,7 @@ function toPixel(value) {
27
27
  return value;
28
28
  }
29
29
  export {
30
- flush,
30
+ flushPromises,
31
31
  isEmpty,
32
32
  isNullish,
33
33
  noop,
package/dist/promise.cjs CHANGED
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function flush() {
4
- return new Promise((resolve) => void setTimeout(resolve, 0));
3
+ const scheduler = typeof setImmediate === "function" ? setImmediate : setTimeout;
4
+ function flushPromises() {
5
+ return new Promise((resolve) => void scheduler(resolve, 0));
5
6
  }
6
7
  function sleep(ms) {
7
8
  return new Promise((resolve) => void setTimeout(resolve, ms));
8
9
  }
9
- exports.flush = flush;
10
+ exports.flushPromises = flushPromises;
10
11
  exports.sleep = sleep;
package/dist/promise.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare function flush(): Promise<void>;
1
+ export declare function flushPromises(): Promise<void>;
2
2
  export declare function sleep(ms: number): Promise<void>;
package/dist/promise.js CHANGED
@@ -1,10 +1,11 @@
1
- function flush() {
2
- return new Promise((resolve) => void setTimeout(resolve, 0));
1
+ const scheduler = typeof setImmediate === "function" ? setImmediate : setTimeout;
2
+ function flushPromises() {
3
+ return new Promise((resolve) => void scheduler(resolve, 0));
3
4
  }
4
5
  function sleep(ms) {
5
6
  return new Promise((resolve) => void setTimeout(resolve, ms));
6
7
  }
7
8
  export {
8
- flush,
9
+ flushPromises,
9
10
  sleep
10
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/utils",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "TypeScript utils",
5
5
  "license": "MIT",
6
6
  "type": "module",