@naturalcycles/js-lib 15.58.0 → 15.59.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.
@@ -1,3 +1,4 @@
1
+ // oxlint-disable-next-line import/no-cycle -- intentional cycle
1
2
  import { LocalDate } from './localDate.js';
2
3
  import { localTime } from './localTime.js';
3
4
  /**
@@ -1,4 +1,5 @@
1
1
  import { isServerSide } from '../env.js';
2
+ // oxlint-disable-next-line import/no-cycle -- intentional cycle
2
3
  import { _jsonParseIfPossible } from '../string/json.util.js';
3
4
  import { _truncate, _truncateMiddle } from '../string/string.util.js';
4
5
  import { _stringify } from '../string/stringify.js';
@@ -1,3 +1,4 @@
1
+ // oxlint-disable-next-line import/no-cycle -- intentional cycle
1
2
  import { JsonParseError } from '../error/error.util.js';
2
3
  // const possibleJsonStartTokens = ['{', '[', '"']
3
4
  const DETECT_JSON = /^\s*[{["\-\d]/;
@@ -1,3 +1,4 @@
1
+ // oxlint-disable-next-line import/no-cycle -- intentional cycle
1
2
  import { _isBackendErrorResponseObject, _isErrorLike, _isErrorObject } from '../error/error.util.js';
2
3
  import { _jsonParseIfPossible } from './json.util.js';
3
4
  import { _safeJsonStringify } from './safeJsonStringify.js';
package/dist/types.d.ts CHANGED
@@ -291,14 +291,14 @@ export declare const _stringMapEntries: <T>(map: StringMap<T>) => [k: string, v:
291
291
  * Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
292
292
  * This is how TypeScript should work, actually.
293
293
  */
294
- export declare const _objectKeys: <T extends AnyObject>(obj: T) => (keyof T)[];
294
+ export declare const _objectKeys: <K extends PropertyKey>(obj: Record<K, any>) => K[];
295
295
  /**
296
296
  * Alias of `Object.entries`, but returns better-typed output.
297
297
  *
298
298
  * So e.g you can use _objectEntries(obj).map([k, v] => {})
299
299
  * and `k` will be `keyof obj` instead of generic `string`.
300
300
  */
301
- export declare const _objectEntries: <T extends AnyObject>(obj: T) => [k: keyof T, v: T[keyof T]][];
301
+ export declare const _objectEntries: <K extends PropertyKey, V>(obj: Record<K, V>) => [k: K, v: V][];
302
302
  export type NullishValue = null | undefined;
303
303
  export type FalsyValue = false | '' | 0 | null | undefined;
304
304
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
3
  "type": "module",
4
- "version": "15.58.0",
4
+ "version": "15.59.0",
5
5
  "dependencies": {
6
6
  "tslib": "^2",
7
7
  "undici": "^7",
@@ -10,6 +10,7 @@ import type {
10
10
  UnixTimestamp,
11
11
  UnixTimestampMillis,
12
12
  } from '../types.js'
13
+ // oxlint-disable-next-line import/no-cycle -- intentional cycle
13
14
  import type { DateObject, ISODayOfWeek, LocalTime } from './localTime.js'
14
15
  import { localTime, VALID_DAYS_OF_WEEK } from './localTime.js'
15
16
 
@@ -12,6 +12,7 @@ import type {
12
12
  UnixTimestamp,
13
13
  UnixTimestampMillis,
14
14
  } from '../types.js'
15
+ // oxlint-disable-next-line import/no-cycle -- intentional cycle
15
16
  import type { LocalDate } from './localDate.js'
16
17
  import { localDate } from './localDate.js'
17
18
  import { _ms } from './time.util.js'
@@ -1,4 +1,5 @@
1
1
  import type { IsoDate, IsoDateTime } from '../types.js'
2
+ // oxlint-disable-next-line import/no-cycle -- intentional cycle
2
3
  import { LocalDate } from './localDate.js'
3
4
  import type { DateTimeObject, LocalTime } from './localTime.js'
4
5
  import { localTime } from './localTime.js'
@@ -1,4 +1,5 @@
1
1
  import { isServerSide } from '../env.js'
2
+ // oxlint-disable-next-line import/no-cycle -- intentional cycle
2
3
  import { _jsonParseIfPossible } from '../string/json.util.js'
3
4
  import { _truncate, _truncateMiddle } from '../string/string.util.js'
4
5
  import { _stringify } from '../string/stringify.js'
@@ -156,7 +156,7 @@ export function _filterObject<T extends AnyObject>(
156
156
  const r = {} as T
157
157
  for (const [k, v] of _objectEntries(obj)) {
158
158
  if (predicate(k, v, obj)) {
159
- r[k] = v
159
+ r[k as keyof T] = v
160
160
  }
161
161
  }
162
162
  return r
@@ -1,3 +1,4 @@
1
+ // oxlint-disable-next-line import/no-cycle -- intentional cycle
1
2
  import { JsonParseError } from '../error/error.util.js'
2
3
  import type { Reviver } from '../types.js'
3
4
 
@@ -1,3 +1,4 @@
1
+ // oxlint-disable-next-line import/no-cycle -- intentional cycle
1
2
  import { _isBackendErrorResponseObject, _isErrorLike, _isErrorObject } from '../error/error.util.js'
2
3
  import type { ErrorLike } from '../error/index.js'
3
4
  import type { Reviver } from '../types.js'
package/src/types.ts CHANGED
@@ -364,7 +364,7 @@ export const _stringMapEntries = Object.entries as <T>(map: StringMap<T>) => [k:
364
364
  * Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
365
365
  * This is how TypeScript should work, actually.
366
366
  */
367
- export const _objectKeys = Object.keys as <T extends AnyObject>(obj: T) => (keyof T)[]
367
+ export const _objectKeys = Object.keys as <K extends PropertyKey>(obj: Record<K, any>) => K[]
368
368
 
369
369
  /**
370
370
  * Alias of `Object.entries`, but returns better-typed output.
@@ -372,9 +372,9 @@ export const _objectKeys = Object.keys as <T extends AnyObject>(obj: T) => (keyo
372
372
  * So e.g you can use _objectEntries(obj).map([k, v] => {})
373
373
  * and `k` will be `keyof obj` instead of generic `string`.
374
374
  */
375
- export const _objectEntries = Object.entries as <T extends AnyObject>(
376
- obj: T,
377
- ) => [k: keyof T, v: T[keyof T]][]
375
+ export const _objectEntries = Object.entries as <K extends PropertyKey, V>(
376
+ obj: Record<K, V>,
377
+ ) => [k: K, v: V][]
378
378
 
379
379
  export type NullishValue = null | undefined
380
380
  export type FalsyValue = false | '' | 0 | null | undefined