@naturalcycles/js-lib 14.274.0 → 14.274.1

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.
Files changed (62) hide show
  1. package/dist/array/array.util.d.ts +1 -1
  2. package/dist/browser/adminService.d.ts +1 -1
  3. package/dist/browser/i18n/fetchTranslationLoader.d.ts +3 -3
  4. package/dist/browser/i18n/translation.service.d.ts +1 -1
  5. package/dist/datetime/dateInterval.d.ts +2 -2
  6. package/dist/datetime/localDate.d.ts +1 -1
  7. package/dist/datetime/localTime.d.ts +1 -1
  8. package/dist/datetime/timeInterval.d.ts +1 -1
  9. package/dist/datetime/wallTime.d.ts +2 -2
  10. package/dist/decorators/asyncMemo.decorator.d.ts +2 -2
  11. package/dist/decorators/memo.decorator.d.ts +2 -3
  12. package/dist/decorators/memoFn.d.ts +1 -1
  13. package/dist/decorators/memoFnAsync.d.ts +1 -1
  14. package/dist/env.js +2 -3
  15. package/dist/error/error.model.d.ts +2 -2
  16. package/dist/http/fetcher.d.ts +2 -2
  17. package/dist/index.d.ts +2 -1
  18. package/dist/iter/asyncIterable2.d.ts +3 -2
  19. package/dist/iter/iterable2.d.ts +2 -1
  20. package/dist/json-schema/jsonSchema.util.d.ts +1 -1
  21. package/dist/object/object.util.d.ts +2 -1
  22. package/dist/promise/abortable.d.ts +1 -1
  23. package/dist/promise/pDelay.d.ts +1 -1
  24. package/dist/promise/pTimeout.d.ts +1 -1
  25. package/dist/semver.d.ts +1 -1
  26. package/dist/string/hash.util.d.ts +1 -1
  27. package/dist/string/json.util.d.ts +1 -1
  28. package/dist/web.d.ts +1 -1
  29. package/dist-esm/array/array.util.js +1 -1
  30. package/dist-esm/decorators/asyncMemo.decorator.js +1 -1
  31. package/dist-esm/env.js +2 -3
  32. package/dist-esm/object/object.util.js +1 -1
  33. package/package.json +1 -1
  34. package/src/array/array.util.ts +2 -2
  35. package/src/browser/adminService.ts +1 -1
  36. package/src/browser/i18n/fetchTranslationLoader.ts +3 -3
  37. package/src/browser/i18n/translation.service.ts +1 -1
  38. package/src/datetime/dateInterval.ts +3 -2
  39. package/src/datetime/localDate.ts +2 -1
  40. package/src/datetime/localTime.ts +2 -1
  41. package/src/datetime/timeInterval.ts +2 -1
  42. package/src/datetime/wallTime.ts +3 -2
  43. package/src/decorators/asyncMemo.decorator.ts +4 -9
  44. package/src/decorators/memo.decorator.ts +4 -3
  45. package/src/decorators/memoFn.ts +1 -1
  46. package/src/decorators/memoFnAsync.ts +2 -1
  47. package/src/decorators/swarmSafe.decorator.ts +1 -1
  48. package/src/env.ts +2 -3
  49. package/src/error/error.model.ts +2 -2
  50. package/src/http/fetcher.ts +3 -3
  51. package/src/index.ts +2 -1
  52. package/src/iter/asyncIterable2.ts +3 -2
  53. package/src/iter/iterable2.ts +2 -1
  54. package/src/json-schema/jsonSchema.util.ts +2 -1
  55. package/src/object/object.util.ts +2 -3
  56. package/src/promise/abortable.ts +1 -1
  57. package/src/promise/pDelay.ts +2 -1
  58. package/src/promise/pTimeout.ts +2 -1
  59. package/src/semver.ts +1 -1
  60. package/src/string/hash.util.ts +1 -1
  61. package/src/string/json.util.ts +1 -1
  62. package/src/web.ts +1 -1
@@ -1,4 +1,4 @@
1
- import { AbortablePredicate, FalsyValue, Mapper, Predicate, SortDirection, StringMap } from '../types';
1
+ import type { AbortablePredicate, FalsyValue, Mapper, Predicate, SortDirection, StringMap } from '../types';
2
2
  /**
3
3
  * Creates an array of elements split into groups the length of size. If collection can’t be split evenly, the
4
4
  * final chunk will be the remaining elements.
@@ -1,4 +1,4 @@
1
- import { Promisable } from '../typeFest';
1
+ import type { Promisable } from '../typeFest';
2
2
  export interface AdminModeCfg {
3
3
  /**
4
4
  * Function (predicate) to detect if needed keys are pressed.
@@ -1,6 +1,6 @@
1
- import { Fetcher } from '../../http/fetcher';
2
- import { StringMap } from '../../types';
3
- import { TranslationLoader } from './translation.service';
1
+ import type { Fetcher } from '../../http/fetcher';
2
+ import type { StringMap } from '../../types';
3
+ import type { TranslationLoader } from './translation.service';
4
4
  /**
5
5
  * Use `baseUrl` to prefix your language files.
6
6
  * Example URL structure:
@@ -1,4 +1,4 @@
1
- import { StringMap } from '../../types';
1
+ import type { StringMap } from '../../types';
2
2
  export type MissingTranslationHandler = (key: string, params?: StringMap<any>) => string;
3
3
  export declare const defaultMissingTranslationHandler: MissingTranslationHandler;
4
4
  export interface TranslationServiceCfg {
@@ -1,5 +1,5 @@
1
- import { Inclusiveness } from '../types';
2
- import { LocalDate, LocalDateInput, LocalDateUnit } from './localDate';
1
+ import type { Inclusiveness } from '../types';
2
+ import type { LocalDate, LocalDateInput, LocalDateUnit } from './localDate';
3
3
  export type DateIntervalConfig = DateInterval | DateIntervalString;
4
4
  export type DateIntervalString = string;
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import { Iterable2 } from '../iter/iterable2';
2
2
  import type { Inclusiveness, IsoDate, IsoDateTime, MonthId, SortDirection, UnixTimestamp, UnixTimestampMillis } from '../types';
3
- import { DateObject, ISODayOfWeek, LocalTime } from './localTime';
3
+ import type { DateObject, ISODayOfWeek, LocalTime } from './localTime';
4
4
  export type LocalDateUnit = LocalDateUnitStrict | 'week';
5
5
  export type LocalDateUnitStrict = 'year' | 'month' | 'day';
6
6
  export type LocalDateInput = LocalDate | Date | IsoDate;
@@ -1,5 +1,5 @@
1
1
  import type { IANATimezone, Inclusiveness, IsoDate, IsoDateTime, MonthId, NumberOfHours, NumberOfMinutes, SortDirection, UnixTimestamp, UnixTimestampMillis } from '../types';
2
- import { LocalDate } from './localDate';
2
+ import type { LocalDate } from './localDate';
3
3
  import { WallTime } from './wallTime';
4
4
  export type LocalTimeUnit = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
5
5
  export declare enum ISODayOfWeek {
@@ -1,5 +1,5 @@
1
1
  import type { Inclusiveness, UnixTimestamp } from '../types';
2
- import { LocalTime, LocalTimeInput } from './localTime';
2
+ import type { LocalTime, LocalTimeInput } from './localTime';
3
3
  export type TimeIntervalConfig = TimeInterval | TimeIntervalString;
4
4
  export type TimeIntervalString = string;
5
5
  /**
@@ -1,6 +1,6 @@
1
- import { IsoDate, IsoDateTime } from '../types';
1
+ import type { IsoDate, IsoDateTime } from '../types';
2
2
  import { LocalDate } from './localDate';
3
- import { DateTimeObject, LocalTime } from './localTime';
3
+ import type { DateTimeObject, LocalTime } from './localTime';
4
4
  /**
5
5
  * Representation of a "time on the wall clock",
6
6
  * which means "local time, regardless of timezone".
@@ -1,6 +1,6 @@
1
1
  import type { CommonLogger } from '../log/commonLogger';
2
- import { AnyAsyncFunction, AnyFunction, AnyObject, MaybeParameters } from '../types';
3
- import { AsyncMemoCache, MethodDecorator } from './memo.util';
2
+ import type { AnyAsyncFunction, AnyFunction, AnyObject, MaybeParameters } from '../types';
3
+ import type { AsyncMemoCache, MethodDecorator } from './memo.util';
4
4
  export interface AsyncMemoOptions<FN> {
5
5
  /**
6
6
  * Provide a custom implementation of AsyncMemoCache.
@@ -1,7 +1,6 @@
1
1
  import type { CommonLogger } from '../log/commonLogger';
2
- import { AnyFunction, AnyObject, MaybeParameters } from '../types';
3
- import type { MemoCache } from './memo.util';
4
- import { MethodDecorator } from './memo.util';
2
+ import type { AnyFunction, AnyObject, MaybeParameters } from '../types';
3
+ import type { MemoCache, MethodDecorator } from './memo.util';
5
4
  export interface MemoOptions<FN> {
6
5
  /**
7
6
  * Provide a custom implementation of MemoCache.
@@ -1,4 +1,4 @@
1
- import { AnyFunction } from '../types';
1
+ import type { AnyFunction } from '../types';
2
2
  import type { MemoOptions } from './memo.decorator';
3
3
  import type { MemoCache } from './memo.util';
4
4
  export interface MemoizedFunction {
@@ -1,4 +1,4 @@
1
- import { AnyAsyncFunction } from '../types';
1
+ import type { AnyAsyncFunction } from '../types';
2
2
  import type { AsyncMemoOptions } from './asyncMemo.decorator';
3
3
  import type { AsyncMemoCache } from './memo.util';
4
4
  export interface MemoizedAsyncFunction {
package/dist/env.js CHANGED
@@ -9,8 +9,7 @@ exports.isClientSide = isClientSide;
9
9
  * Will return `false` in the Browser.
10
10
  */
11
11
  function isServerSide() {
12
- // eslint-disable-next-line unicorn/prefer-global-this
13
- return typeof window === 'undefined';
12
+ return !isClientSide();
14
13
  }
15
14
  /**
16
15
  * Use it to detect Browser (not SSR/Node) environment.
@@ -20,5 +19,5 @@ function isServerSide() {
20
19
  */
21
20
  function isClientSide() {
22
21
  // eslint-disable-next-line unicorn/prefer-global-this
23
- return typeof window !== 'undefined';
22
+ return typeof window !== 'undefined' && !!window?.document;
24
23
  }
@@ -1,5 +1,5 @@
1
- import { HttpMethod, HttpStatusCode } from '../http/http.model';
2
- import { NumberOfMilliseconds } from '../types';
1
+ import type { HttpMethod, HttpStatusCode } from '../http/http.model';
2
+ import type { NumberOfMilliseconds } from '../types';
3
3
  /**
4
4
  * Extendable payload object to transfer custom additional data with AppError.
5
5
  */
@@ -2,8 +2,8 @@
2
2
  /// <reference lib="dom" preserve="true" />
3
3
  /// <reference lib="dom.iterable" preserve="true" />
4
4
  import { HttpRequestError } from '../error/error.util';
5
- import { ErrorDataTuple } from '../types';
6
- import { FetcherAfterResponseHook, FetcherBeforeRequestHook, FetcherBeforeRetryHook, FetcherCfg, FetcherGraphQLOptions, FetcherNormalizedCfg, FetcherOnErrorHook, FetcherOptions, FetcherResponse, RequestInitNormalized } from './fetcher.model';
5
+ import type { ErrorDataTuple } from '../types';
6
+ import type { FetcherAfterResponseHook, FetcherBeforeRequestHook, FetcherBeforeRetryHook, FetcherCfg, FetcherGraphQLOptions, FetcherNormalizedCfg, FetcherOnErrorHook, FetcherOptions, FetcherResponse, RequestInitNormalized } from './fetcher.model';
7
7
  /**
8
8
  * Experimental wrapper around Fetch.
9
9
  * Works in both Browser and Node, using `globalThis.fetch`.
package/dist/index.d.ts CHANGED
@@ -96,6 +96,7 @@ export * from './unit/size.util';
96
96
  export * from './web';
97
97
  export * from './zod/zod.shared.schemas';
98
98
  export * from './zod/zod.util';
99
- import { z, ZodError, ZodIssue, ZodSchema } from 'zod';
99
+ import type { ZodIssue } from 'zod';
100
+ import { z, ZodError, ZodSchema } from 'zod';
100
101
  export { z, ZodError, ZodSchema };
101
102
  export type { ZodIssue };
@@ -1,5 +1,6 @@
1
- import { Promisable } from '../typeFest';
2
- import { AbortableAsyncMapper, AbortableAsyncPredicate, END } from '../types';
1
+ import type { Promisable } from '../typeFest';
2
+ import type { AbortableAsyncMapper, AbortableAsyncPredicate } from '../types';
3
+ import { END } from '../types';
3
4
  /**
4
5
  * Similar to Iterable2, but for AsyncIterable.
5
6
  *
@@ -1,4 +1,5 @@
1
- import { AbortableMapper, AbortablePredicate, END } from '../types';
1
+ import type { AbortableMapper, AbortablePredicate } from '../types';
2
+ import { END } from '../types';
2
3
  /**
3
4
  * Iterable2 is a wrapper around Iterable that implements "Iterator Helpers proposal":
4
5
  * https://github.com/tc39/proposal-iterator-helpers
@@ -1,4 +1,4 @@
1
- import { AnyObject } from '../index';
1
+ import type { AnyObject } from '../index';
2
2
  import type { JsonSchemaObject } from './jsonSchema.model';
3
3
  /**
4
4
  * Merges s2 into s1 (mutates s1) and returns s1.
@@ -1,4 +1,5 @@
1
- import { AnyObject, KeyValueTuple, ObjectMapper, ObjectPredicate, Reviver, SKIP, ValueOf } from '../types';
1
+ import type { AnyObject, KeyValueTuple, ObjectMapper, ObjectPredicate, Reviver, ValueOf } from '../types';
2
+ import { SKIP } from '../types';
2
3
  /**
3
4
  * Returns clone of `obj` with only `props` preserved.
4
5
  * Opposite of Omit.
@@ -1,4 +1,4 @@
1
- import { AnyFunction } from '../types';
1
+ import type { AnyFunction } from '../types';
2
2
  /**
3
3
  * Similar to AbortController and AbortSignal.
4
4
  * Similar to pDefer and Promise.
@@ -1,5 +1,5 @@
1
1
  import type { NumberOfMilliseconds, PromisableFunction } from '../types';
2
- import { DeferredPromise } from './pDefer';
2
+ import type { DeferredPromise } from './pDefer';
3
3
  /**
4
4
  * Promisified version of setTimeout.
5
5
  *
@@ -1,6 +1,6 @@
1
1
  import type { ErrorData } from '../error/error.model';
2
2
  import { TimeoutError } from '../error/error.util';
3
- import { AnyAsyncFunction, NumberOfMilliseconds } from '../types';
3
+ import type { AnyAsyncFunction, NumberOfMilliseconds } from '../types';
4
4
  export interface PTimeoutOptions {
5
5
  /**
6
6
  * Timeout in milliseconds.
package/dist/semver.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SortDirection } from './types';
1
+ import type { SortDirection } from './types';
2
2
  export type SemverInput = string | Semver;
3
3
  export type SemverInputNullable = SemverInput | null | undefined;
4
4
  export type SemverTokens = [major: number, minor: number, patch: number];
@@ -1,4 +1,4 @@
1
- import { Integer } from '../types';
1
+ import type { Integer } from '../types';
2
2
  /**
3
3
  * Returns hashCode as hex (radix 16).
4
4
  *
@@ -1,4 +1,4 @@
1
- import { Reviver } from '../types';
1
+ import type { Reviver } from '../types';
2
2
  /**
3
3
  * Attempts to parse object as JSON.
4
4
  * Returns original object if JSON parse failed (silently).
package/dist/web.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="es2022" preserve="true" />
2
2
  /// <reference lib="dom" preserve="true" />
3
- import { StringMap } from './types';
3
+ import type { StringMap } from './types';
4
4
  /**
5
5
  * Implements WebStorage API by using in-memory storage.
6
6
  * Can be useful in SSR environment or unit tests.
@@ -1,5 +1,5 @@
1
1
  import { _assert } from '../error/assert';
2
- import { END, } from '../types';
2
+ import { END } from '../types';
3
3
  /**
4
4
  * Creates an array of elements split into groups the length of size. If collection can’t be split evenly, the
5
5
  * final chunk will be the remaining elements.
@@ -1,5 +1,5 @@
1
1
  import { _assert, _assertTypeOf } from '../error/assert';
2
- import { _objectAssign, MISS, } from '../types';
2
+ import { _objectAssign, MISS } from '../types';
3
3
  import { _getTargetMethodSignature } from './decorator.util';
4
4
  import { jsonMemoSerializer } from './memo.util';
5
5
  /**
package/dist-esm/env.js CHANGED
@@ -5,8 +5,7 @@
5
5
  * Will return `false` in the Browser.
6
6
  */
7
7
  export function isServerSide() {
8
- // eslint-disable-next-line unicorn/prefer-global-this
9
- return typeof window === 'undefined';
8
+ return !isClientSide();
10
9
  }
11
10
  /**
12
11
  * Use it to detect Browser (not SSR/Node) environment.
@@ -16,5 +15,5 @@ export function isServerSide() {
16
15
  */
17
16
  export function isClientSide() {
18
17
  // eslint-disable-next-line unicorn/prefer-global-this
19
- return typeof window !== 'undefined';
18
+ return typeof window !== 'undefined' && !!window?.document;
20
19
  }
@@ -1,5 +1,5 @@
1
1
  import { _isEmpty, _isObject } from '../is.util';
2
- import { _objectEntries, SKIP, } from '../types';
2
+ import { _objectEntries, SKIP } from '../types';
3
3
  /**
4
4
  * Returns clone of `obj` with only `props` preserved.
5
5
  * Opposite of Omit.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.274.0",
3
+ "version": "14.274.1",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build": "dev-lib build-esm-cjs",
@@ -1,13 +1,13 @@
1
1
  import { _assert } from '../error/assert'
2
- import {
2
+ import type {
3
3
  AbortablePredicate,
4
- END,
5
4
  FalsyValue,
6
5
  Mapper,
7
6
  Predicate,
8
7
  SortDirection,
9
8
  StringMap,
10
9
  } from '../types'
10
+ import { END } from '../types'
11
11
 
12
12
  /**
13
13
  * Creates an array of elements split into groups the length of size. If collection can’t be split evenly, the
@@ -1,7 +1,7 @@
1
1
  import { _Memo } from '../decorators/memo.decorator'
2
2
  import { isServerSide } from '../env'
3
3
  import { _stringify } from '../string/stringify'
4
- import { Promisable } from '../typeFest'
4
+ import type { Promisable } from '../typeFest'
5
5
 
6
6
  export interface AdminModeCfg {
7
7
  /**
@@ -1,6 +1,6 @@
1
- import { Fetcher } from '../../http/fetcher'
2
- import { StringMap } from '../../types'
3
- import { TranslationLoader } from './translation.service'
1
+ import type { Fetcher } from '../../http/fetcher'
2
+ import type { StringMap } from '../../types'
3
+ import type { TranslationLoader } from './translation.service'
4
4
 
5
5
  /**
6
6
  * Use `baseUrl` to prefix your language files.
@@ -1,5 +1,5 @@
1
1
  import { pMap } from '../../promise/pMap'
2
- import { StringMap } from '../../types'
2
+ import type { StringMap } from '../../types'
3
3
 
4
4
  export type MissingTranslationHandler = (key: string, params?: StringMap<any>) => string
5
5
 
@@ -1,5 +1,6 @@
1
- import { Inclusiveness, IsoDate } from '../types'
2
- import { LocalDate, localDate, LocalDateInput, LocalDateUnit } from './localDate'
1
+ import type { Inclusiveness, IsoDate } from '../types'
2
+ import type { LocalDate, LocalDateInput, LocalDateUnit } from './localDate'
3
+ import { localDate } from './localDate'
3
4
 
4
5
  export type DateIntervalConfig = DateInterval | DateIntervalString
5
6
  export type DateIntervalString = string
@@ -9,7 +9,8 @@ import type {
9
9
  UnixTimestamp,
10
10
  UnixTimestampMillis,
11
11
  } from '../types'
12
- import { DateObject, ISODayOfWeek, LocalTime, localTime, VALID_DAYS_OF_WEEK } from './localTime'
12
+ import type { DateObject, ISODayOfWeek, LocalTime } from './localTime'
13
+ import { localTime, VALID_DAYS_OF_WEEK } from './localTime'
13
14
 
14
15
  export type LocalDateUnit = LocalDateUnitStrict | 'week'
15
16
  export type LocalDateUnitStrict = 'year' | 'month' | 'day'
@@ -12,7 +12,8 @@ import type {
12
12
  UnixTimestamp,
13
13
  UnixTimestampMillis,
14
14
  } from '../types'
15
- import { LocalDate, localDate } from './localDate'
15
+ import type { LocalDate } from './localDate'
16
+ import { localDate } from './localDate'
16
17
  import { WallTime } from './wallTime'
17
18
 
18
19
  export type LocalTimeUnit = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second'
@@ -1,5 +1,6 @@
1
1
  import type { Inclusiveness, UnixTimestamp } from '../types'
2
- import { LocalTime, localTime, LocalTimeInput } from './localTime'
2
+ import type { LocalTime, LocalTimeInput } from './localTime'
3
+ import { localTime } from './localTime'
3
4
 
4
5
  export type TimeIntervalConfig = TimeInterval | TimeIntervalString
5
6
  export type TimeIntervalString = string
@@ -1,6 +1,7 @@
1
- import { IsoDate, IsoDateTime } from '../types'
1
+ import type { IsoDate, IsoDateTime } from '../types'
2
2
  import { LocalDate } from './localDate'
3
- import { DateTimeObject, LocalTime, localTime } from './localTime'
3
+ import type { DateTimeObject, LocalTime } from './localTime'
4
+ import { localTime } from './localTime'
4
5
 
5
6
  /**
6
7
  * Representation of a "time on the wall clock",
@@ -1,15 +1,10 @@
1
1
  import { _assert, _assertTypeOf } from '../error/assert'
2
2
  import type { CommonLogger } from '../log/commonLogger'
3
- import {
4
- _objectAssign,
5
- AnyAsyncFunction,
6
- AnyFunction,
7
- AnyObject,
8
- MaybeParameters,
9
- MISS,
10
- } from '../types'
3
+ import type { AnyAsyncFunction, AnyFunction, AnyObject, MaybeParameters } from '../types'
4
+ import { _objectAssign, MISS } from '../types'
11
5
  import { _getTargetMethodSignature } from './decorator.util'
12
- import { AsyncMemoCache, jsonMemoSerializer, MethodDecorator } from './memo.util'
6
+ import type { AsyncMemoCache, MethodDecorator } from './memo.util'
7
+ import { jsonMemoSerializer } from './memo.util'
13
8
 
14
9
  export interface AsyncMemoOptions<FN> {
15
10
  /**
@@ -1,9 +1,10 @@
1
1
  import { _assert, _assertTypeOf } from '../error/assert'
2
2
  import type { CommonLogger } from '../log/commonLogger'
3
- import { _objectAssign, AnyFunction, AnyObject, MaybeParameters } from '../types'
3
+ import type { AnyFunction, AnyObject, MaybeParameters } from '../types'
4
+ import { _objectAssign } from '../types'
4
5
  import { _getTargetMethodSignature } from './decorator.util'
5
- import type { MemoCache } from './memo.util'
6
- import { jsonMemoSerializer, MapMemoCache, MethodDecorator } from './memo.util'
6
+ import type { MemoCache, MethodDecorator } from './memo.util'
7
+ import { jsonMemoSerializer, MapMemoCache } from './memo.util'
7
8
 
8
9
  export interface MemoOptions<FN> {
9
10
  /**
@@ -1,4 +1,4 @@
1
- import { AnyFunction, MaybeParameters } from '../types'
1
+ import type { AnyFunction, MaybeParameters } from '../types'
2
2
  import type { MemoOptions } from './memo.decorator'
3
3
  import type { MemoCache } from './memo.util'
4
4
  import { jsonMemoSerializer, MapMemoCache } from './memo.util'
@@ -1,4 +1,5 @@
1
- import { AnyAsyncFunction, MaybeParameters, MISS } from '../types'
1
+ import type { AnyAsyncFunction, MaybeParameters } from '../types'
2
+ import { MISS } from '../types'
2
3
  import type { AsyncMemoOptions } from './asyncMemo.decorator'
3
4
  import type { AsyncMemoCache } from './memo.util'
4
5
  import { jsonMemoSerializer, MapMemoCache } from './memo.util'
@@ -1,4 +1,4 @@
1
- import { AnyObject } from '../types'
1
+ import type { AnyObject } from '../types'
2
2
  import { _getTargetMethodSignature } from './decorator.util'
3
3
 
4
4
  /**
package/src/env.ts CHANGED
@@ -5,8 +5,7 @@
5
5
  * Will return `false` in the Browser.
6
6
  */
7
7
  export function isServerSide(): boolean {
8
- // eslint-disable-next-line unicorn/prefer-global-this
9
- return typeof window === 'undefined'
8
+ return !isClientSide()
10
9
  }
11
10
 
12
11
  /**
@@ -17,5 +16,5 @@ export function isServerSide(): boolean {
17
16
  */
18
17
  export function isClientSide(): boolean {
19
18
  // eslint-disable-next-line unicorn/prefer-global-this
20
- return typeof window !== 'undefined'
19
+ return typeof window !== 'undefined' && !!window?.document
21
20
  }
@@ -1,5 +1,5 @@
1
- import { HttpMethod, HttpStatusCode } from '../http/http.model'
2
- import { NumberOfMilliseconds } from '../types'
1
+ import type { HttpMethod, HttpStatusCode } from '../http/http.model'
2
+ import type { NumberOfMilliseconds } from '../types'
3
3
 
4
4
  /**
5
5
  * Extendable payload object to transfer custom additional data with AppError.
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { isServerSide } from '../env'
6
6
  import { _assertErrorClassOrRethrow, _assertIsError } from '../error/assert'
7
- import { ErrorLike, ErrorObject } from '../error/error.model'
7
+ import type { ErrorLike, ErrorObject } from '../error/error.model'
8
8
  import {
9
9
  _anyToError,
10
10
  _anyToErrorObject,
@@ -29,8 +29,8 @@ import { pTimeout } from '../promise/pTimeout'
29
29
  import { _jsonParse, _jsonParseIfPossible } from '../string/json.util'
30
30
  import { _stringify } from '../string/stringify'
31
31
  import { _ms, _since } from '../time/time.util'
32
- import { AnyObject, ErrorDataTuple, NumberOfMilliseconds, UnixTimestampMillis } from '../types'
33
- import {
32
+ import type { AnyObject, ErrorDataTuple, NumberOfMilliseconds, UnixTimestampMillis } from '../types'
33
+ import type {
34
34
  FetcherAfterResponseHook,
35
35
  FetcherBeforeRequestHook,
36
36
  FetcherBeforeRetryHook,
package/src/index.ts CHANGED
@@ -96,7 +96,8 @@ export * from './unit/size.util'
96
96
  export * from './web'
97
97
  export * from './zod/zod.shared.schemas'
98
98
  export * from './zod/zod.util'
99
- import { z, ZodError, ZodIssue, ZodSchema } from 'zod'
99
+ import type { ZodIssue } from 'zod'
100
+ import { z, ZodError, ZodSchema } from 'zod'
100
101
 
101
102
  export { z, ZodError, ZodSchema }
102
103
  export type { ZodIssue }
@@ -1,5 +1,6 @@
1
- import { Promisable } from '../typeFest'
2
- import { AbortableAsyncMapper, AbortableAsyncPredicate, END, SKIP } from '../types'
1
+ import type { Promisable } from '../typeFest'
2
+ import type { AbortableAsyncMapper, AbortableAsyncPredicate } from '../types'
3
+ import { END, SKIP } from '../types'
3
4
 
4
5
  /**
5
6
  * Similar to Iterable2, but for AsyncIterable.
@@ -1,4 +1,5 @@
1
- import { AbortableMapper, AbortablePredicate, END, SKIP } from '../types'
1
+ import type { AbortableMapper, AbortablePredicate } from '../types'
2
+ import { END, SKIP } from '../types'
2
3
 
3
4
  /**
4
5
  * Iterable2 is a wrapper around Iterable that implements "Iterator Helpers proposal":
@@ -1,4 +1,5 @@
1
- import { _uniq, AnyObject } from '../index'
1
+ import type { AnyObject } from '../index'
2
+ import { _uniq } from '../index'
2
3
  import { _filterNullishValues } from '../object/object.util'
3
4
  import type { JsonSchemaObject } from './jsonSchema.model'
4
5
 
@@ -1,14 +1,13 @@
1
1
  import { _isEmpty, _isObject } from '../is.util'
2
- import {
3
- _objectEntries,
2
+ import type {
4
3
  AnyObject,
5
4
  KeyValueTuple,
6
5
  ObjectMapper,
7
6
  ObjectPredicate,
8
7
  Reviver,
9
- SKIP,
10
8
  ValueOf,
11
9
  } from '../types'
10
+ import { _objectEntries, SKIP } from '../types'
12
11
 
13
12
  /**
14
13
  * Returns clone of `obj` with only `props` preserved.
@@ -1,4 +1,4 @@
1
- import { AnyFunction } from '../types'
1
+ import type { AnyFunction } from '../types'
2
2
 
3
3
  /**
4
4
  * Similar to AbortController and AbortSignal.
@@ -1,5 +1,6 @@
1
1
  import type { NumberOfMilliseconds, PromisableFunction } from '../types'
2
- import { DeferredPromise, pDefer } from './pDefer'
2
+ import type { DeferredPromise } from './pDefer'
3
+ import { pDefer } from './pDefer'
3
4
 
4
5
  /**
5
6
  * Promisified version of setTimeout.
@@ -1,6 +1,7 @@
1
1
  import type { ErrorData } from '../error/error.model'
2
2
  import { _errorDataAppend, TimeoutError } from '../error/error.util'
3
- import { _typeCast, AnyAsyncFunction, NumberOfMilliseconds } from '../types'
3
+ import type { AnyAsyncFunction, NumberOfMilliseconds } from '../types'
4
+ import { _typeCast } from '../types'
4
5
 
5
6
  export interface PTimeoutOptions {
6
7
  /**
package/src/semver.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { _range } from './array/range'
2
2
  import { _assert } from './error/assert'
3
- import { SortDirection } from './types'
3
+ import type { SortDirection } from './types'
4
4
 
5
5
  export type SemverInput = string | Semver
6
6
  export type SemverInputNullable = SemverInput | null | undefined
@@ -1,4 +1,4 @@
1
- import { Integer } from '../types'
1
+ import type { Integer } from '../types'
2
2
 
3
3
  const BASE62 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
4
4
  // const BASE64 = BASE62 + '+/'
@@ -1,5 +1,5 @@
1
1
  import { JsonParseError } from '../error/error.util'
2
- import { Reviver } from '../types'
2
+ import type { Reviver } from '../types'
3
3
 
4
4
  // const possibleJsonStartTokens = ['{', '[', '"']
5
5
  const DETECT_JSON = /^\s*[{["\-\d]/
package/src/web.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference lib="es2022" preserve="true" />
2
2
  /// <reference lib="dom" preserve="true" />
3
3
 
4
- import { StringMap } from './types'
4
+ import type { StringMap } from './types'
5
5
 
6
6
  /**
7
7
  * Implements WebStorage API by using in-memory storage.