@libp2p/utils 6.6.7-7eed3b40d → 6.6.7

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/README.md CHANGED
@@ -24,22 +24,7 @@ repo and examine the changes made.
24
24
 
25
25
  -->
26
26
 
27
- The libp2p ecosystem has lots of repos with it comes several problems like:
28
-
29
- - Domain logic dedupe - all modules shared a lot of logic like validation, streams handling, etc.
30
- - Dependencies management - it's really easy with so many repos for dependencies to go out of control, they become outdated, different repos use different modules to do the same thing (like merging defaults options), browser bundles ends up with multiple versions of the same package, bumping versions is cumbersome to do because we need to go through several repos, etc.
31
-
32
- These problems are the motivation for this package, having shared logic in this package avoids creating cyclic dependencies, centralizes common use modules/functions (exactly like aegir does for the tooling), semantic versioning for 3rd party dependencies is handled in one single place (a good example is going from streams 2 to 3) and maintainers should only care about having `libp2p-utils` updated.
33
-
34
- ## Example
35
-
36
- Each function should be imported directly.
37
-
38
- ```TypeScript
39
- import { ipPortToMultiaddr } from '@libp2p/utils/ip-port-to-multiaddr'
40
-
41
- const ma = ipPortToMultiaddr('127.0.0.1', 9000)
42
- ```
27
+ This module contains utility functions used by libp2p modules.
43
28
 
44
29
  # Install
45
30
 
@@ -20,12 +20,6 @@ export interface RepeatingTask {
20
20
  * running, that run will not be interrupted.
21
21
  */
22
22
  setTimeout(ms: number): void;
23
- /**
24
- * Schedule the task to be run immediately - if the task is not running it
25
- * will run after a short delay in order to debounce multiple `.run()`
26
- * invocations.
27
- */
28
- run(): void;
29
23
  /**
30
24
  * Start the task running
31
25
  */
@@ -47,13 +41,6 @@ export interface RepeatingTaskOptions {
47
41
  * @default false
48
42
  */
49
43
  runImmediately?: boolean;
50
- /**
51
- * When `.run()` is called to run the task outside of the current interval,
52
- * debounce repeated calls to `.run()` by this amount.
53
- *
54
- * @default 100
55
- */
56
- debounce?: number;
57
44
  }
58
45
  export declare function repeatingTask(fn: (options?: AbortOptions) => void | Promise<void>, interval: number, options?: RepeatingTaskOptions): RepeatingTask;
59
46
  //# sourceMappingURL=repeating-task.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"repeating-task.d.ts","sourceRoot":"","sources":["../../src/repeating-task.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IAE7B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IAE5B;;;;OAIG;IACH,GAAG,IAAI,IAAI,CAAA;IAEX;;OAEG;IACH,KAAK,IAAI,IAAI,CAAA;IAEb;;OAEG;IACH,IAAI,IAAI,IAAI,CAAA;CACb;AAED,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IAExB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,wBAAgB,aAAa,CAAE,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,aAAa,CA4FpJ"}
1
+ {"version":3,"file":"repeating-task.d.ts","sourceRoot":"","sources":["../../src/repeating-task.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IAE7B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IAE5B;;OAEG;IACH,KAAK,IAAI,IAAI,CAAA;IAEb;;OAEG;IACH,IAAI,IAAI,IAAI,CAAA;CACb;AAED,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,wBAAgB,aAAa,CAAE,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,aAAa,CA6EpJ"}
@@ -1,10 +1,8 @@
1
1
  import { anySignal } from 'any-signal';
2
2
  import { setMaxListeners } from 'main-event';
3
- import { debounce } from "./debounce.js";
4
3
  export function repeatingTask(fn, interval, options) {
5
4
  let timeout;
6
5
  let shutdownController;
7
- let running = false;
8
6
  function runTask() {
9
7
  const opts = {
10
8
  signal: shutdownController.signal
@@ -14,13 +12,11 @@ export function repeatingTask(fn, interval, options) {
14
12
  setMaxListeners(Infinity, signal);
15
13
  opts.signal = signal;
16
14
  }
17
- running = true;
18
15
  Promise.resolve().then(async () => {
19
16
  await fn(opts);
20
17
  })
21
18
  .catch(() => { })
22
19
  .finally(() => {
23
- running = false;
24
20
  if (shutdownController.signal.aborted) {
25
21
  // task has been cancelled, bail
26
22
  return;
@@ -29,7 +25,6 @@ export function repeatingTask(fn, interval, options) {
29
25
  timeout = setTimeout(runTask, interval);
30
26
  });
31
27
  }
32
- const runTaskDebounced = debounce(runTask, options?.debounce ?? 100);
33
28
  let started = false;
34
29
  return {
35
30
  setInterval: (ms) => {
@@ -48,13 +43,6 @@ export function repeatingTask(fn, interval, options) {
48
43
  options ??= {};
49
44
  options.timeout = ms;
50
45
  },
51
- run: () => {
52
- if (running) {
53
- return;
54
- }
55
- clearTimeout(timeout);
56
- runTaskDebounced();
57
- },
58
46
  start: () => {
59
47
  if (started) {
60
48
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"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.io/js-libp2p/functions/_libp2p_utils.abort-options.createTimeoutOptions.html",
3
+ "./abort-options:createTimeoutOptions": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.abort-options.createTimeoutOptions.html",
4
+ "AbstractStream": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.abstract-stream.AbstractStream.html",
5
+ "./abstract-stream:AbstractStream": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.abstract-stream.AbstractStream.html",
6
+ "AbstractStreamInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.abstract-stream.AbstractStreamInit.html",
7
+ "./abstract-stream:AbstractStreamInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.abstract-stream.AbstractStreamInit.html",
8
+ "AdaptiveTimeout": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.adaptive-timeout.AdaptiveTimeout.html",
9
+ "./adaptive-timeout:AdaptiveTimeout": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.adaptive-timeout.AdaptiveTimeout.html",
10
+ "AdaptiveTimeoutInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.adaptive-timeout.AdaptiveTimeoutInit.html",
11
+ "./adaptive-timeout:AdaptiveTimeoutInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.adaptive-timeout.AdaptiveTimeoutInit.html",
12
+ "AdaptiveTimeoutSignal": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.adaptive-timeout.AdaptiveTimeoutSignal.html",
13
+ "./adaptive-timeout:AdaptiveTimeoutSignal": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.adaptive-timeout.AdaptiveTimeoutSignal.html",
14
+ "GetTimeoutSignalOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.adaptive-timeout.GetTimeoutSignalOptions.html",
15
+ "./adaptive-timeout:GetTimeoutSignalOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.adaptive-timeout.GetTimeoutSignalOptions.html",
16
+ "DEFAULT_FAILURE_MULTIPLIER": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive-timeout.DEFAULT_FAILURE_MULTIPLIER.html",
17
+ "./adaptive-timeout:DEFAULT_FAILURE_MULTIPLIER": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive-timeout.DEFAULT_FAILURE_MULTIPLIER.html",
18
+ "DEFAULT_INTERVAL": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive-timeout.DEFAULT_INTERVAL.html",
19
+ "./adaptive-timeout:DEFAULT_INTERVAL": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive-timeout.DEFAULT_INTERVAL.html",
20
+ "DEFAULT_MAX_TIMEOUT": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive-timeout.DEFAULT_MAX_TIMEOUT.html",
21
+ "./adaptive-timeout:DEFAULT_MAX_TIMEOUT": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive-timeout.DEFAULT_MAX_TIMEOUT.html",
22
+ "DEFAULT_MIN_TIMEOUT": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive-timeout.DEFAULT_MIN_TIMEOUT.html",
23
+ "./adaptive-timeout:DEFAULT_MIN_TIMEOUT": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive-timeout.DEFAULT_MIN_TIMEOUT.html",
24
+ "DEFAULT_TIMEOUT_MULTIPLIER": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive-timeout.DEFAULT_TIMEOUT_MULTIPLIER.html",
25
+ "./adaptive-timeout:DEFAULT_TIMEOUT_MULTIPLIER": "https://libp2p.github.io/js-libp2p/variables/_libp2p_utils.adaptive-timeout.DEFAULT_TIMEOUT_MULTIPLIER.html",
26
+ "arrayEquals": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.array-equals.arrayEquals.html",
27
+ "./array-equals:arrayEquals": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.array-equals.arrayEquals.html",
28
+ "SafelyCloseConnectionOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.close.SafelyCloseConnectionOptions.html",
29
+ "./close:SafelyCloseConnectionOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.close.SafelyCloseConnectionOptions.html",
30
+ "safelyCloseConnectionIfUnused": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.close.safelyCloseConnectionIfUnused.html",
31
+ "./close:safelyCloseConnectionIfUnused": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.close.safelyCloseConnectionIfUnused.html",
32
+ "safelyCloseStream": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.close.safelyCloseStream.html",
33
+ "./close:safelyCloseStream": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.close.safelyCloseStream.html",
34
+ "closeSource": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.close-source.closeSource.html",
35
+ "./close-source:closeSource": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.close-source.closeSource.html",
36
+ "DebouncedFunction": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.debounce.DebouncedFunction.html",
37
+ "./debounce:DebouncedFunction": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.debounce.DebouncedFunction.html",
38
+ "debounce": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.debounce.debounce.html",
39
+ "./debounce:debounce": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.debounce.debounce.html",
40
+ "BloomFilter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.filters.BloomFilter.html",
41
+ "Bucket": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.filters.Bucket.html",
42
+ "CuckooFilter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.filters.CuckooFilter.html",
43
+ "Fingerprint": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.filters.Fingerprint.html",
44
+ "ScalableCuckooFilter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.filters.ScalableCuckooFilter.html",
45
+ "BloomFilterOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.filters.BloomFilterOptions.html",
46
+ "CuckooFilterInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.filters.CuckooFilterInit.html",
47
+ "Filter": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.filters.Filter.html",
48
+ "./filters:Filter": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.filters.Filter.html",
49
+ "Hash": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.filters.Hash.html",
50
+ "ScalableCuckooFilterInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.filters.ScalableCuckooFilterInit.html",
51
+ "createBloomFilter": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.filters.createBloomFilter.html",
52
+ "createCuckooFilter": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.filters.createCuckooFilter.html",
53
+ "createScalableCuckooFilter": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.filters.createScalableCuckooFilter.html",
54
+ "getThinWaistAddresses": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.get-thin-waist-addresses.getThinWaistAddresses.html",
55
+ "./get-thin-waist-addresses:getThinWaistAddresses": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.get-thin-waist-addresses.getThinWaistAddresses.html",
56
+ "isGlobalUnicastIp": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.global-unicast-ip.isGlobalUnicastIp.html",
57
+ "./global-unicast-ip:isGlobalUnicastIp": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.global-unicast-ip.isGlobalUnicastIp.html",
58
+ "ipPortToMultiaddr": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.ip-port-to-multiaddr.ipPortToMultiaddr.html",
59
+ "./ip-port-to-multiaddr:ipPortToMultiaddr": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.ip-port-to-multiaddr.ipPortToMultiaddr.html",
60
+ "isAsyncGenerator": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.is-async-generator.isAsyncGenerator.html",
61
+ "./is-async-generator:isAsyncGenerator": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.is-async-generator.isAsyncGenerator.html",
62
+ "isGenerator": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.is-generator.isGenerator.html",
63
+ "./is-generator:isGenerator": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.is-generator.isGenerator.html",
64
+ "isPromise": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.is-promise.isPromise.html",
65
+ "./is-promise:isPromise": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.is-promise.isPromise.html",
66
+ "isLinkLocalIp": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.link-local-ip.isLinkLocalIp.html",
67
+ "./link-local-ip:isLinkLocalIp": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.link-local-ip.isLinkLocalIp.html",
68
+ "mergeOptions": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.merge-options.mergeOptions.html",
69
+ "./merge-options:mergeOptions": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.merge-options.mergeOptions.html",
70
+ "MovingAverage": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.moving-average.MovingAverage.html",
71
+ "./moving-average:MovingAverage": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.moving-average.MovingAverage.html",
72
+ "isGlobalUnicast": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is-global-unicast.isGlobalUnicast.html",
73
+ "./multiaddr/is-global-unicast:isGlobalUnicast": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is-global-unicast.isGlobalUnicast.html",
74
+ "isIpBased": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is-ip-based.isIpBased.html",
75
+ "./multiaddr/is-ip-based:isIpBased": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is-ip-based.isIpBased.html",
76
+ "isLinkLocal": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is-link-local.isLinkLocal.html",
77
+ "./multiaddr/is-link-local:isLinkLocal": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is-link-local.isLinkLocal.html",
78
+ "isLoopback": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is-loopback.isLoopback.html",
79
+ "./multiaddr/is-loopback:isLoopback": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is-loopback.isLoopback.html",
80
+ "isNetworkAddress": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is-network-address.isNetworkAddress.html",
81
+ "./multiaddr/is-network-address:isNetworkAddress": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is-network-address.isNetworkAddress.html",
82
+ "isPrivate": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is-private.isPrivate.html",
83
+ "./multiaddr/is-private:isPrivate": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.multiaddr_is-private.isPrivate.html",
84
+ "PeerQueue": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.peer-queue.PeerQueue.html",
85
+ "./peer-queue:PeerQueue": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.peer-queue.PeerQueue.html",
86
+ "PeerQueueJobOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.peer-queue.PeerQueueJobOptions.html",
87
+ "./peer-queue:PeerQueueJobOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.peer-queue.PeerQueueJobOptions.html",
88
+ "PriorityQueue": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.priority-queue.PriorityQueue.html",
89
+ "./priority-queue:PriorityQueue": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.priority-queue.PriorityQueue.html",
90
+ "PriorityQueueJobOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.priority-queue.PriorityQueueJobOptions.html",
91
+ "./priority-queue:PriorityQueueJobOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.priority-queue.PriorityQueueJobOptions.html",
92
+ "isPrivateIp": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.private-ip.isPrivateIp.html",
93
+ "./private-ip:isPrivateIp": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.private-ip.isPrivateIp.html",
94
+ "Job": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.queue.Job.html",
95
+ "JobRecipient": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.queue.JobRecipient.html",
96
+ "Queue": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.queue.Queue.html",
97
+ "./queue:Queue": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.queue.Queue.html",
98
+ "Comparator": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.Comparator.html",
99
+ "./queue:Comparator": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.Comparator.html",
100
+ "JobMatcher": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.JobMatcher.html",
101
+ "./queue:JobMatcher": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.JobMatcher.html",
102
+ "JobTimeline": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.JobTimeline.html",
103
+ "QueueEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueEvents.html",
104
+ "./queue:QueueEvents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueEvents.html",
105
+ "QueueInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueInit.html",
106
+ "./queue:QueueInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueInit.html",
107
+ "QueueJobFailure": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueJobFailure.html",
108
+ "./queue:QueueJobFailure": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueJobFailure.html",
109
+ "QueueJobSuccess": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueJobSuccess.html",
110
+ "./queue:QueueJobSuccess": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.QueueJobSuccess.html",
111
+ "RunFunction": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.RunFunction.html",
112
+ "./queue:RunFunction": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.queue.RunFunction.html",
113
+ "JobStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_utils.queue.JobStatus.html",
114
+ "./queue:JobStatus": "https://libp2p.github.io/js-libp2p/types/_libp2p_utils.queue.JobStatus.html",
115
+ "MemoryStorage": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.rate-limiter.MemoryStorage.html",
116
+ "./rate-limiter:MemoryStorage": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.rate-limiter.MemoryStorage.html",
117
+ "RateLimiter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.rate-limiter.RateLimiter.html",
118
+ "./rate-limiter:RateLimiter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_utils.rate-limiter.RateLimiter.html",
119
+ "GetKeySecDurationOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate-limiter.GetKeySecDurationOptions.html",
120
+ "./rate-limiter:GetKeySecDurationOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate-limiter.GetKeySecDurationOptions.html",
121
+ "RateLimiterInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate-limiter.RateLimiterInit.html",
122
+ "./rate-limiter:RateLimiterInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate-limiter.RateLimiterInit.html",
123
+ "RateLimiterResult": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate-limiter.RateLimiterResult.html",
124
+ "./rate-limiter:RateLimiterResult": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate-limiter.RateLimiterResult.html",
125
+ "RateRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate-limiter.RateRecord.html",
126
+ "./rate-limiter:RateRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.rate-limiter.RateRecord.html",
127
+ "RepeatingTask": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.repeating-task.RepeatingTask.html",
128
+ "./repeating-task:RepeatingTask": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.repeating-task.RepeatingTask.html",
129
+ "RepeatingTaskOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.repeating-task.RepeatingTaskOptions.html",
130
+ "./repeating-task:RepeatingTaskOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.repeating-task.RepeatingTaskOptions.html",
131
+ "repeatingTask": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.repeating-task.repeatingTask.html",
132
+ "./repeating-task:repeatingTask": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.repeating-task.repeatingTask.html",
133
+ "StreamProperties": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.stream-to-ma-conn.StreamProperties.html",
134
+ "./stream-to-ma-conn:StreamProperties": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.stream-to-ma-conn.StreamProperties.html",
135
+ "streamToMaConnection": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.stream-to-ma-conn.streamToMaConnection.html",
136
+ "./stream-to-ma-conn:streamToMaConnection": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.stream-to-ma-conn.streamToMaConnection.html",
137
+ "CreateTrackedListInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.tracked-list.CreateTrackedListInit.html",
138
+ "./tracked-list:CreateTrackedListInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.tracked-list.CreateTrackedListInit.html",
139
+ "trackedList": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.tracked-list.trackedList.html",
140
+ "./tracked-list:trackedList": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.tracked-list.trackedList.html",
141
+ "CreateTrackedMapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.tracked-map.CreateTrackedMapInit.html",
142
+ "./tracked-map:CreateTrackedMapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.tracked-map.CreateTrackedMapInit.html",
143
+ "TrackedMapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.tracked-map.TrackedMapInit.html",
144
+ "./tracked-map:TrackedMapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_utils.tracked-map.TrackedMapInit.html",
145
+ "trackedMap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.tracked-map.trackedMap.html",
146
+ "./tracked-map:trackedMap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_utils.tracked-map.trackedMap.html"
147
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/utils",
3
- "version": "6.6.7-7eed3b40d",
3
+ "version": "6.6.7",
4
4
  "description": "Package to aggregate shared logic and dependencies for the libp2p ecosystem",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/utils#readme",
@@ -191,9 +191,9 @@
191
191
  "dependencies": {
192
192
  "@chainsafe/is-ip": "^2.1.0",
193
193
  "@chainsafe/netmask": "^2.0.0",
194
- "@libp2p/crypto": "5.1.6-7eed3b40d",
195
- "@libp2p/interface": "2.10.4-7eed3b40d",
196
- "@libp2p/logger": "5.1.20-7eed3b40d",
194
+ "@libp2p/crypto": "^5.1.6",
195
+ "@libp2p/interface": "^2.10.4",
196
+ "@libp2p/logger": "^5.1.20",
197
197
  "@multiformats/multiaddr": "^12.4.4",
198
198
  "@sindresorhus/fnv1a": "^3.1.0",
199
199
  "any-signal": "^4.1.1",
@@ -214,7 +214,7 @@
214
214
  "uint8arrays": "^5.1.0"
215
215
  },
216
216
  "devDependencies": {
217
- "@libp2p/peer-id": "5.1.7-7eed3b40d",
217
+ "@libp2p/peer-id": "^5.1.7",
218
218
  "@types/netmask": "^2.0.5",
219
219
  "aegir": "^47.0.14",
220
220
  "benchmark": "^2.1.4",
@@ -1,6 +1,5 @@
1
1
  import { anySignal } from 'any-signal'
2
2
  import { setMaxListeners } from 'main-event'
3
- import { debounce } from './debounce.ts'
4
3
  import type { AbortOptions } from '@libp2p/interface'
5
4
 
6
5
  export interface RepeatingTask {
@@ -26,13 +25,6 @@ export interface RepeatingTask {
26
25
  */
27
26
  setTimeout(ms: number): void
28
27
 
29
- /**
30
- * Schedule the task to be run immediately - if the task is not running it
31
- * will run after a short delay in order to debounce multiple `.run()`
32
- * invocations.
33
- */
34
- run(): void
35
-
36
28
  /**
37
29
  * Start the task running
38
30
  */
@@ -57,20 +49,11 @@ export interface RepeatingTaskOptions {
57
49
  * @default false
58
50
  */
59
51
  runImmediately?: boolean
60
-
61
- /**
62
- * When `.run()` is called to run the task outside of the current interval,
63
- * debounce repeated calls to `.run()` by this amount.
64
- *
65
- * @default 100
66
- */
67
- debounce?: number
68
52
  }
69
53
 
70
54
  export function repeatingTask (fn: (options?: AbortOptions) => void | Promise<void>, interval: number, options?: RepeatingTaskOptions): RepeatingTask {
71
55
  let timeout: ReturnType<typeof setTimeout>
72
56
  let shutdownController: AbortController
73
- let running = false
74
57
 
75
58
  function runTask (): void {
76
59
  const opts: AbortOptions = {
@@ -84,15 +67,11 @@ export function repeatingTask (fn: (options?: AbortOptions) => void | Promise<vo
84
67
  opts.signal = signal
85
68
  }
86
69
 
87
- running = true
88
-
89
70
  Promise.resolve().then(async () => {
90
71
  await fn(opts)
91
72
  })
92
73
  .catch(() => {})
93
74
  .finally(() => {
94
- running = false
95
-
96
75
  if (shutdownController.signal.aborted) {
97
76
  // task has been cancelled, bail
98
77
  return
@@ -103,8 +82,6 @@ export function repeatingTask (fn: (options?: AbortOptions) => void | Promise<vo
103
82
  })
104
83
  }
105
84
 
106
- const runTaskDebounced = debounce(runTask, options?.debounce ?? 100)
107
-
108
85
  let started = false
109
86
 
110
87
  return {
@@ -126,14 +103,6 @@ export function repeatingTask (fn: (options?: AbortOptions) => void | Promise<vo
126
103
  options ??= {}
127
104
  options.timeout = ms
128
105
  },
129
- run: (): void => {
130
- if (running) {
131
- return
132
- }
133
-
134
- clearTimeout(timeout)
135
- runTaskDebounced()
136
- },
137
106
  start: (): void => {
138
107
  if (started) {
139
108
  return