@naturalcycles/js-lib 15.48.0 → 15.49.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,5 +1,5 @@
1
1
  import { Iterable2 } from '../iter/iterable2.js';
2
- import type { Inclusiveness, IsoDate, IsoDateTime, IsoMonth, MonthId, MutateOptions, SortOptions, UnixTimestamp, UnixTimestampMillis } from '../types.js';
2
+ import type { Inclusiveness, IsoDate, IsoDateTime, IsoMonth, MutateOptions, SortOptions, UnixTimestamp, UnixTimestampMillis } from '../types.js';
3
3
  import type { DateObject, ISODayOfWeek, LocalTime } from './localTime.js';
4
4
  export type LocalDateUnit = LocalDateUnitStrict | 'week';
5
5
  export type LocalDateUnitStrict = 'year' | 'month' | 'day';
@@ -151,10 +151,6 @@ export declare class LocalDate {
151
151
  * Returns e.g: `19840621`
152
152
  */
153
153
  toStringCompact(): string;
154
- /**
155
- * @deprecated Use toIsoMonth
156
- */
157
- toMonthId(): MonthId;
158
154
  /**
159
155
  * Returns unix timestamp of 00:00:00 of that date (in UTC, because unix timestamp always reflects UTC).
160
156
  */
@@ -434,12 +434,6 @@ export class LocalDate {
434
434
  String(this.day).padStart(2, '0'),
435
435
  ].join('');
436
436
  }
437
- /**
438
- * @deprecated Use toIsoMonth
439
- */
440
- toMonthId() {
441
- return this.toISOMonth();
442
- }
443
437
  /**
444
438
  * Returns unix timestamp of 00:00:00 of that date (in UTC, because unix timestamp always reflects UTC).
445
439
  */
@@ -1,4 +1,4 @@
1
- import type { IANATimezone, Inclusiveness, IsoDate, IsoDateTime, IsoMonth, MonthId, MutateOptions, NumberOfHours, NumberOfMinutes, SortDirection, UnixTimestamp, UnixTimestampMillis } from '../types.js';
1
+ import type { IANATimezone, Inclusiveness, IsoDate, IsoDateTime, IsoMonth, MutateOptions, NumberOfHours, NumberOfMinutes, SortDirection, UnixTimestamp, UnixTimestampMillis } from '../types.js';
2
2
  import type { LocalDate } from './localDate.js';
3
3
  import { WallTime } from './wallTime.js';
4
4
  export type LocalTimeUnit = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
@@ -231,10 +231,6 @@ export declare class LocalTime {
231
231
  toStringCompact(seconds?: boolean): string;
232
232
  toString(): IsoDateTime;
233
233
  toJSON(): UnixTimestamp;
234
- /**
235
- * @deprecated Use toIsoMonth
236
- */
237
- toMonthId(): MonthId;
238
234
  format(fmt: Intl.DateTimeFormat | LocalTimeFormatter): string;
239
235
  }
240
236
  declare class LocalTimeFactory {
@@ -634,12 +634,6 @@ export class LocalTime {
634
634
  toJSON() {
635
635
  return this.unix;
636
636
  }
637
- /**
638
- * @deprecated Use toIsoMonth
639
- */
640
- toMonthId() {
641
- return this.toISOMonth();
642
- }
643
637
  format(fmt) {
644
638
  if (fmt instanceof Intl.DateTimeFormat) {
645
639
  return fmt.format(this.$date);
package/dist/types.d.ts CHANGED
@@ -197,11 +197,6 @@ export type IsoDateTime = Branded<string, 'IsoDateTime'>;
197
197
  * @example '2019-06'
198
198
  */
199
199
  export type IsoMonth = Branded<string, 'IsoMonth'>;
200
- /**
201
- * Identifies the Month.
202
- * @deprecated Use IsoMonth
203
- */
204
- export type MonthId = string;
205
200
  /**
206
201
  * Identifies IANA timezone name.
207
202
  * Branded type.
@@ -293,17 +288,23 @@ export declare const _stringMapValues: <T>(map: StringMap<T>) => T[];
293
288
  */
294
289
  export declare const _stringMapEntries: <T>(map: StringMap<T>) => [k: string, v: T][];
295
290
  /**
296
- * Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
291
+ * Resolves to a string literal union of the keys of T, meaning they are
292
+ * always keys of T and always strings (never numbers or symbols).
293
+ */
294
+ export type ObjectKey<T> = `${Extract<keyof T, string | number>}`;
295
+ /**
296
+ * Alias of `Object.keys`, but returns keys with a string type that's as
297
+ * narrow as possible.
297
298
  * This is how TypeScript should work, actually.
298
299
  */
299
- export declare const _objectKeys: <T extends AnyObject>(obj: T) => (keyof T)[];
300
+ export declare const _objectKeys: <T extends AnyObject>(obj: T) => ObjectKey<T>[];
300
301
  /**
301
302
  * Alias of `Object.entries`, but returns better-typed output.
302
303
  *
303
304
  * So e.g you can use _objectEntries(obj).map([k, v] => {})
304
305
  * and `k` will be `keyof obj` instead of generic `string`.
305
306
  */
306
- export declare const _objectEntries: <T extends AnyObject>(obj: T) => [k: keyof T, v: T[keyof T]][];
307
+ export declare const _objectEntries: <T extends AnyObject>(obj: T) => [k: ObjectKey<T>, v: T[ObjectKey<T>]][];
307
308
  export type NullishValue = null | undefined;
308
309
  export type FalsyValue = false | '' | 0 | null | undefined;
309
310
  /**
package/dist/types.js CHANGED
@@ -31,7 +31,8 @@ export const _stringMapValues = Object.values;
31
31
  */
32
32
  export const _stringMapEntries = Object.entries;
33
33
  /**
34
- * Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
34
+ * Alias of `Object.keys`, but returns keys with a string type that's as
35
+ * narrow as possible.
35
36
  * This is how TypeScript should work, actually.
36
37
  */
37
38
  export const _objectKeys = Object.keys;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
3
  "type": "module",
4
- "version": "15.48.0",
4
+ "version": "15.49.0",
5
5
  "dependencies": {
6
6
  "tslib": "^2",
7
7
  "undici": "^7",
@@ -5,7 +5,6 @@ import type {
5
5
  IsoDate,
6
6
  IsoDateTime,
7
7
  IsoMonth,
8
- MonthId,
9
8
  MutateOptions,
10
9
  SortOptions,
11
10
  UnixTimestamp,
@@ -513,13 +512,6 @@ export class LocalDate {
513
512
  ].join('')
514
513
  }
515
514
 
516
- /**
517
- * @deprecated Use toIsoMonth
518
- */
519
- toMonthId(): MonthId {
520
- return this.toISOMonth()
521
- }
522
-
523
515
  /**
524
516
  * Returns unix timestamp of 00:00:00 of that date (in UTC, because unix timestamp always reflects UTC).
525
517
  */
@@ -5,7 +5,6 @@ import type {
5
5
  IsoDate,
6
6
  IsoDateTime,
7
7
  IsoMonth,
8
- MonthId,
9
8
  MutateOptions,
10
9
  NumberOfHours,
11
10
  NumberOfMinutes,
@@ -765,13 +764,6 @@ export class LocalTime {
765
764
  return this.unix
766
765
  }
767
766
 
768
- /**
769
- * @deprecated Use toIsoMonth
770
- */
771
- toMonthId(): MonthId {
772
- return this.toISOMonth()
773
- }
774
-
775
767
  format(fmt: Intl.DateTimeFormat | LocalTimeFormatter): string {
776
768
  if (fmt instanceof Intl.DateTimeFormat) {
777
769
  return fmt.format(this.$date)
package/src/types.ts CHANGED
@@ -254,12 +254,6 @@ export type IsoDateTime = Branded<string, 'IsoDateTime'>
254
254
  */
255
255
  export type IsoMonth = Branded<string, 'IsoMonth'>
256
256
 
257
- /**
258
- * Identifies the Month.
259
- * @deprecated Use IsoMonth
260
- */
261
- export type MonthId = string
262
-
263
257
  /**
264
258
  * Identifies IANA timezone name.
265
259
  * Branded type.
@@ -367,10 +361,17 @@ export const _stringMapValues = Object.values as <T>(map: StringMap<T>) => T[]
367
361
  export const _stringMapEntries = Object.entries as <T>(map: StringMap<T>) => [k: string, v: T][]
368
362
 
369
363
  /**
370
- * Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
364
+ * Resolves to a string literal union of the keys of T, meaning they are
365
+ * always keys of T and always strings (never numbers or symbols).
366
+ */
367
+ export type ObjectKey<T> = `${Extract<keyof T, string | number>}`
368
+
369
+ /**
370
+ * Alias of `Object.keys`, but returns keys with a string type that's as
371
+ * narrow as possible.
371
372
  * This is how TypeScript should work, actually.
372
373
  */
373
- export const _objectKeys = Object.keys as <T extends AnyObject>(obj: T) => (keyof T)[]
374
+ export const _objectKeys = Object.keys as <T extends AnyObject>(obj: T) => ObjectKey<T>[]
374
375
 
375
376
  /**
376
377
  * Alias of `Object.entries`, but returns better-typed output.
@@ -380,7 +381,7 @@ export const _objectKeys = Object.keys as <T extends AnyObject>(obj: T) => (keyo
380
381
  */
381
382
  export const _objectEntries = Object.entries as <T extends AnyObject>(
382
383
  obj: T,
383
- ) => [k: keyof T, v: T[keyof T]][]
384
+ ) => [k: ObjectKey<T>, v: T[ObjectKey<T>]][]
384
385
 
385
386
  export type NullishValue = null | undefined
386
387
  export type FalsyValue = false | '' | 0 | null | undefined