@sha1n/about-time 0.0.13 → 0.1.0

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.js CHANGED
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
5
  }) : (function(o, m, k, k2) {
10
6
  if (k2 === undefined) k2 = k;
11
7
  o[k2] = m[k];
package/dist/lib/delay.js CHANGED
@@ -11,7 +11,7 @@ const toMilliseconds_1 = require("./toMilliseconds");
11
11
  */
12
12
  function sleep(time, options) {
13
13
  return new Promise(resolve => {
14
- const timeout = setTimeout(resolve, (0, toMilliseconds_1.toMilliseconds)(time, options === null || options === void 0 ? void 0 : options.units));
14
+ const timeout = setTimeout(resolve, toMilliseconds_1.toMilliseconds(time, options === null || options === void 0 ? void 0 : options.units));
15
15
  if (options === null || options === void 0 ? void 0 : options.unref) {
16
16
  timeout.unref();
17
17
  }
@@ -12,8 +12,8 @@ const types_1 = require("./types");
12
12
  */
13
13
  async function until(condition, options) {
14
14
  const defaultInterval = 50;
15
- const deadline = (options === null || options === void 0 ? void 0 : options.deadline) ? Date.now() + (0, toMilliseconds_1.toMilliseconds)(options.deadline, options.units) : Number.MAX_VALUE;
16
- const interval = (options === null || options === void 0 ? void 0 : options.interval) ? (0, toMilliseconds_1.toMilliseconds)(options.interval, options.units) : defaultInterval;
15
+ const deadline = (options === null || options === void 0 ? void 0 : options.deadline) ? Date.now() + toMilliseconds_1.toMilliseconds(options.deadline, options.units) : Number.MAX_VALUE;
16
+ const interval = (options === null || options === void 0 ? void 0 : options.interval) ? toMilliseconds_1.toMilliseconds(options.interval, options.units) : defaultInterval;
17
17
  return new Promise((resolve, reject) => {
18
18
  const handle = setInterval(() => {
19
19
  if (Date.now() > deadline) {
package/dist/lib/retry.js CHANGED
@@ -7,7 +7,7 @@ const types_1 = require("./types");
7
7
  class SimpleRetryPolicy {
8
8
  constructor(count, interval, units) {
9
9
  this.count = count;
10
- this.interval = (0, toMilliseconds_1.toMilliseconds)(interval, units);
10
+ this.interval = toMilliseconds_1.toMilliseconds(interval, units);
11
11
  }
12
12
  *intervals() {
13
13
  let count = this.count;
@@ -38,7 +38,7 @@ class ExponentialBackoffRetryPolicy {
38
38
  class FixedRetryPolicy {
39
39
  constructor(intervals, units) {
40
40
  this._intervals = intervals.reduceRight((result, v) => {
41
- result.push((0, toMilliseconds_1.toMilliseconds)(v, units));
41
+ result.push(toMilliseconds_1.toMilliseconds(v, units));
42
42
  return result;
43
43
  }, []);
44
44
  }
@@ -74,7 +74,7 @@ async function retryAround(action, policy, predicate = () => true) {
74
74
  if (next.done || !predicate(e)) {
75
75
  throw e;
76
76
  }
77
- await (0, delay_1.sleep)(next.value);
77
+ await delay_1.sleep(next.value);
78
78
  }
79
79
  } while (!next.done);
80
80
  throw new Error('Unexpected error. This is most likely a bug.');
@@ -22,7 +22,7 @@ async function timeoutAround(action, options) {
22
22
  const race = new Promise((resolve, reject) => {
23
23
  const timer = setTimeout(() => {
24
24
  reject(new types_1.TimeoutError());
25
- }, (0, toMilliseconds_1.toMilliseconds)(options.time, options.units));
25
+ }, toMilliseconds_1.toMilliseconds(options.time, options.units));
26
26
  if (options.unref) {
27
27
  timer.unref();
28
28
  }
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "@sha1n/about-time",
3
- "version": "0.0.13",
3
+ "version": "0.1.0",
4
+ "type": "commonjs",
4
5
  "description": "A set of essential time related utilities",
5
6
  "repository": "https://github.com/sha1n/about-time",
6
7
  "author": "Shai Nagar",
7
8
  "license": "MIT",
8
- "types": "./dist/types",
9
9
  "main": "./dist",
10
- "exports": "./dist/index.js",
10
+ "types": "./dist/types/index.d.ts",
11
+ "exports": [
12
+ "./dist/index.js",
13
+ "./dist/types/index.d.ts"
14
+ ],
11
15
  "keywords": [
12
16
  "time",
13
17
  "wait",
@@ -54,7 +58,10 @@
54
58
  "prettier": "^2.6.2",
55
59
  "ts-jest": "^27.1.4",
56
60
  "ts-node": "^10.7.0",
57
- "typescript": "^4.6.3"
61
+ "typescript": "~4.0.0"
58
62
  },
59
- "packageManager": "yarn@3.2.0"
63
+ "packageManager": "yarn@3.2.0",
64
+ "dependencies": {
65
+ "@typescript-eslint/typescript-estree": "^5.30.3"
66
+ }
60
67
  }