@naturalcycles/js-lib 15.30.0 → 15.31.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.
@@ -34,10 +34,10 @@ export function _ms(millis) {
34
34
  // <1 sec
35
35
  if (millis < 1000)
36
36
  return `${Math.round(millis)} ms`;
37
- // < 5 sec
38
- if (millis < 5000) {
37
+ // < 10 sec
38
+ if (millis < 10_000) {
39
39
  const s = millis / 1000;
40
- return `${Math.trunc(s) === s ? s : s.toFixed(3)} sec`;
40
+ return `${s.toFixed(2)} sec`;
41
41
  }
42
42
  const sec = Math.floor(millis / 1000) % 60;
43
43
  const min = Math.floor(millis / (60 * 1000)) % 60;
@@ -1,6 +1,7 @@
1
1
  /// <reference lib="es2022" preserve="true" />
2
2
  /// <reference lib="dom" preserve="true" />
3
3
  /// <reference lib="dom.iterable" preserve="true" />
4
+ import type { ReadableStream as WebReadableStream } from 'node:stream/web';
4
5
  import { HttpRequestError } from '../error/error.util.js';
5
6
  import type { ErrorDataTuple } from '../types.js';
6
7
  import type { FetcherAfterResponseHook, FetcherBeforeRequestHook, FetcherBeforeRetryHook, FetcherCfg, FetcherGraphQLOptions, FetcherNormalizedCfg, FetcherOnErrorHook, FetcherOptions, FetcherResponse, RequestInitNormalized } from './fetcher.model.js';
@@ -61,7 +62,7 @@ export declare class Fetcher {
61
62
  * More on streams and Node interop:
62
63
  * https://css-tricks.com/web-streams-everywhere-and-fetch-for-node-js/
63
64
  */
64
- getReadableStream(url: string, opt?: FetcherOptions): Promise<ReadableStream<Uint8Array>>;
65
+ getReadableStream(url: string, opt?: FetcherOptions): Promise<WebReadableStream<Uint8Array>>;
65
66
  fetch<T = unknown>(opt: FetcherOptions): Promise<T>;
66
67
  /**
67
68
  * Execute fetch and expect/assert it to return an Error (which will be wrapped in
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
3
  "type": "module",
4
- "version": "15.30.0",
4
+ "version": "15.31.0",
5
5
  "dependencies": {
6
6
  "tslib": "^2",
7
7
  "undici": "^7",
@@ -41,10 +41,10 @@ export function _ms(millis: NumberOfMilliseconds): string {
41
41
  // <1 sec
42
42
  if (millis < 1000) return `${Math.round(millis)} ms`
43
43
 
44
- // < 5 sec
45
- if (millis < 5000) {
44
+ // < 10 sec
45
+ if (millis < 10_000) {
46
46
  const s = millis / 1000
47
- return `${Math.trunc(s) === s ? s : s.toFixed(3)} sec`
47
+ return `${s.toFixed(2)} sec`
48
48
  }
49
49
 
50
50
  const sec = Math.floor(millis / 1000) % 60
@@ -2,6 +2,7 @@
2
2
  /// <reference lib="dom" preserve="true" />
3
3
  /// <reference lib="dom.iterable" preserve="true" />
4
4
 
5
+ import type { ReadableStream as WebReadableStream } from 'node:stream/web'
5
6
  import { _ms, _since } from '../datetime/time.util.js'
6
7
  import { isServerSide } from '../env.js'
7
8
  import { _assertErrorClassOrRethrow, _assertIsError } from '../error/assert.js'
@@ -250,7 +251,10 @@ export class Fetcher {
250
251
  * More on streams and Node interop:
251
252
  * https://css-tricks.com/web-streams-everywhere-and-fetch-for-node-js/
252
253
  */
253
- async getReadableStream(url: string, opt?: FetcherOptions): Promise<ReadableStream<Uint8Array>> {
254
+ async getReadableStream(
255
+ url: string,
256
+ opt?: FetcherOptions,
257
+ ): Promise<WebReadableStream<Uint8Array>> {
254
258
  return await this.fetch({
255
259
  url,
256
260
  responseType: 'readableStream',