@naturalcycles/js-lib 15.71.3 → 15.72.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.
- package/dist/bot.model.js +1 -2
- package/dist/browser/i18n/translation.service.js +1 -1
- package/dist/browser/topbar.d.ts +3 -3
- package/dist/datetime/localTime.js +2 -2
- package/dist/decorators/asyncMemo.decorator.js +2 -2
- package/dist/error/assert.d.ts +2 -1
- package/dist/error/errorMode.js +1 -2
- package/dist/promise/pMap.js +1 -1
- package/dist/types.d.ts +9 -2
- package/dist/types.js +7 -0
- package/dist/web.js +1 -0
- package/package.json +2 -2
- package/src/datetime/localTime.ts +1 -0
- package/src/types.ts +9 -2
- package/src/web.ts +1 -0
package/dist/bot.model.js
CHANGED
|
@@ -35,7 +35,7 @@ export class TranslationService {
|
|
|
35
35
|
*/
|
|
36
36
|
async loadLocale(locale) {
|
|
37
37
|
const locales = Array.isArray(locale) ? locale : [locale];
|
|
38
|
-
await pMap(locales, async locale => {
|
|
38
|
+
await pMap(locales, async (locale) => {
|
|
39
39
|
if (this.locales[locale])
|
|
40
40
|
return; // already loaded
|
|
41
41
|
this.locales[locale] = await this.cfg.translationLoader.load(locale);
|
package/dist/browser/topbar.d.ts
CHANGED
|
@@ -16,8 +16,8 @@ export interface TopBarOptions {
|
|
|
16
16
|
}
|
|
17
17
|
export declare const topbar: {
|
|
18
18
|
config(opts: TopBarOptions): void;
|
|
19
|
-
set(show: boolean, opts?: TopBarOptions
|
|
20
|
-
show(opts?: TopBarOptions
|
|
21
|
-
progress(to:
|
|
19
|
+
set(show: boolean, opts?: TopBarOptions): void;
|
|
20
|
+
show(opts?: TopBarOptions): void;
|
|
21
|
+
progress(to: number | string): any;
|
|
22
22
|
hide(): void;
|
|
23
23
|
};
|
|
@@ -2,8 +2,7 @@ import { _assert } from '../error/assert.js';
|
|
|
2
2
|
import { localDate } from './localDate.js';
|
|
3
3
|
import { _ms } from './time.util.js';
|
|
4
4
|
import { WallTime } from './wallTime.js';
|
|
5
|
-
export
|
|
6
|
-
var ISODayOfWeek;
|
|
5
|
+
export var ISODayOfWeek;
|
|
7
6
|
(function (ISODayOfWeek) {
|
|
8
7
|
ISODayOfWeek[ISODayOfWeek["MONDAY"] = 1] = "MONDAY";
|
|
9
8
|
ISODayOfWeek[ISODayOfWeek["TUESDAY"] = 2] = "TUESDAY";
|
|
@@ -763,6 +762,7 @@ class LocalTimeFactory {
|
|
|
763
762
|
* Allows to input IsoDate, will set h:m:s to zeros.
|
|
764
763
|
*/
|
|
765
764
|
parse(s) {
|
|
765
|
+
// oxlint-disable-next-line typescript/no-unnecessary-type-conversion
|
|
766
766
|
const d = this.parseLooselyOrUndefined(String(s));
|
|
767
767
|
_assert(d, `Cannot parse "${s}" into LocalTime`);
|
|
768
768
|
return new LocalTime(d);
|
|
@@ -45,7 +45,7 @@ export const _AsyncMemo = (opt) => (target, key, descriptor) => {
|
|
|
45
45
|
// console.log('return promise', promiseCache.size)
|
|
46
46
|
return promise;
|
|
47
47
|
}
|
|
48
|
-
promise = cache.get(cacheKey).then(async value => {
|
|
48
|
+
promise = cache.get(cacheKey).then(async (value) => {
|
|
49
49
|
if (value !== MISS) {
|
|
50
50
|
// console.log('hit', promiseCache.size)
|
|
51
51
|
promiseCache.delete(cacheKey);
|
|
@@ -54,7 +54,7 @@ export const _AsyncMemo = (opt) => (target, key, descriptor) => {
|
|
|
54
54
|
// Miss
|
|
55
55
|
// console.log('miss', promiseCache.size)
|
|
56
56
|
return await onMiss();
|
|
57
|
-
}, async err => {
|
|
57
|
+
}, async (err) => {
|
|
58
58
|
// Log the cache error and proceed "as cache Miss"
|
|
59
59
|
logger.error(err);
|
|
60
60
|
return await onMiss();
|
package/dist/error/assert.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ import type { BackendErrorResponseObject, ErrorData, ErrorObject } from './error
|
|
|
16
16
|
*
|
|
17
17
|
* Since 2024-07-10 it no longer sets `userFriendly: true` by default.
|
|
18
18
|
*/
|
|
19
|
-
export declare function _assert(condition: any,
|
|
19
|
+
export declare function _assert(condition: any, // will be evaluated as Boolean
|
|
20
|
+
message?: string, errorData?: ErrorData): asserts condition;
|
|
20
21
|
/**
|
|
21
22
|
* Like _assert(), but prints more helpful error message.
|
|
22
23
|
* API is similar to Node's assert.equals().
|
package/dist/error/errorMode.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export { ErrorMode };
|
|
2
1
|
/**
|
|
3
2
|
* Allows to define error-controlling behaviour for batch operations.
|
|
4
3
|
*
|
|
5
4
|
* @default is THROW_IMMEDIATELY in most cases
|
|
6
5
|
*/
|
|
7
|
-
var ErrorMode;
|
|
6
|
+
export var ErrorMode;
|
|
8
7
|
(function (ErrorMode) {
|
|
9
8
|
/**
|
|
10
9
|
* Usually a default behaviour, similar as "exit early".
|
package/dist/promise/pMap.js
CHANGED
|
@@ -77,7 +77,7 @@ export async function pMap(iterable, mapper, opt = {}) {
|
|
|
77
77
|
}
|
|
78
78
|
resolvingCount++;
|
|
79
79
|
Promise.resolve(nextItem)
|
|
80
|
-
.then(async element => await mapper(element, i))
|
|
80
|
+
.then(async (element) => await mapper(element, i))
|
|
81
81
|
.then(value => {
|
|
82
82
|
if (value === END) {
|
|
83
83
|
isSettled = true;
|
package/dist/types.d.ts
CHANGED
|
@@ -298,15 +298,22 @@ export declare const _stringMapEntries: <T>(map: StringMap<T>) => [k: string, v:
|
|
|
298
298
|
/**
|
|
299
299
|
* Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
|
|
300
300
|
* This is how TypeScript should work, actually.
|
|
301
|
+
*
|
|
302
|
+
* Object.keys always returns strings, so numeric keys are stringified via `${K}`.
|
|
303
|
+
* Symbol keys are excluded (Object.keys does not return symbols).
|
|
301
304
|
*/
|
|
302
|
-
export declare const _objectKeys: <K extends PropertyKey>(obj: Partial<Record<K, any>>) => K[];
|
|
305
|
+
export declare const _objectKeys: <K extends PropertyKey>(obj: Partial<Record<K, any>>) => (K extends string ? K : K extends number | bigint ? `${K}` : never)[];
|
|
303
306
|
/**
|
|
304
307
|
* Alias of `Object.entries`, but returns better-typed output.
|
|
305
308
|
*
|
|
309
|
+
* Difference with _stringMapEntries?
|
|
310
|
+
* Use _stringMapEntries when the object is a StringMap<T> - it'll correctly infer T being not undefined.
|
|
311
|
+
* If the object is not a StringMap - use _objectEntries - it'll correctly infer object keys, which can be typed as Enum.
|
|
312
|
+
*
|
|
306
313
|
* So e.g you can use _objectEntries(obj).map([k, v] => {})
|
|
307
314
|
* and `k` will be `keyof obj` instead of generic `string`.
|
|
308
315
|
*/
|
|
309
|
-
export declare const _objectEntries: <K extends PropertyKey, V>(obj: Partial<Record<K, V>>) => [k: K, v: V][];
|
|
316
|
+
export declare const _objectEntries: <K extends PropertyKey, V>(obj: Partial<Record<K, V>>) => [k: K extends string ? K : K extends number | bigint ? `${K}` : never, v: V][];
|
|
310
317
|
export type NullishValue = null | undefined;
|
|
311
318
|
export type FalsyValue = false | '' | 0 | null | undefined;
|
|
312
319
|
/**
|
package/dist/types.js
CHANGED
|
@@ -33,11 +33,18 @@ export const _stringMapEntries = Object.entries;
|
|
|
33
33
|
/**
|
|
34
34
|
* Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
|
|
35
35
|
* This is how TypeScript should work, actually.
|
|
36
|
+
*
|
|
37
|
+
* Object.keys always returns strings, so numeric keys are stringified via `${K}`.
|
|
38
|
+
* Symbol keys are excluded (Object.keys does not return symbols).
|
|
36
39
|
*/
|
|
37
40
|
export const _objectKeys = Object.keys;
|
|
38
41
|
/**
|
|
39
42
|
* Alias of `Object.entries`, but returns better-typed output.
|
|
40
43
|
*
|
|
44
|
+
* Difference with _stringMapEntries?
|
|
45
|
+
* Use _stringMapEntries when the object is a StringMap<T> - it'll correctly infer T being not undefined.
|
|
46
|
+
* If the object is not a StringMap - use _objectEntries - it'll correctly infer object keys, which can be typed as Enum.
|
|
47
|
+
*
|
|
41
48
|
* So e.g you can use _objectEntries(obj).map([k, v] => {})
|
|
42
49
|
* and `k` will be `keyof obj` instead of generic `string`.
|
|
43
50
|
*/
|
package/dist/web.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.72.1",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"tslib": "^2"
|
|
7
7
|
},
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@types/crypto-js": "^4",
|
|
18
18
|
"@types/node": "^25",
|
|
19
19
|
"@types/semver": "^7",
|
|
20
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
20
|
+
"@typescript/native-preview": "7.0.0-dev.20260401.1",
|
|
21
21
|
"crypto-js": "^4",
|
|
22
22
|
"dayjs": "^1",
|
|
23
23
|
"@naturalcycles/dev-lib": "18.4.2"
|
|
@@ -899,6 +899,7 @@ class LocalTimeFactory {
|
|
|
899
899
|
* Allows to input IsoDate, will set h:m:s to zeros.
|
|
900
900
|
*/
|
|
901
901
|
parse(s: string): LocalTime {
|
|
902
|
+
// oxlint-disable-next-line typescript/no-unnecessary-type-conversion
|
|
902
903
|
const d = this.parseLooselyOrUndefined(String(s))
|
|
903
904
|
_assert(d, `Cannot parse "${s}" into LocalTime`)
|
|
904
905
|
return new LocalTime(d)
|
package/src/types.ts
CHANGED
|
@@ -373,20 +373,27 @@ export const _stringMapEntries = Object.entries as <T>(map: StringMap<T>) => [k:
|
|
|
373
373
|
/**
|
|
374
374
|
* Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
|
|
375
375
|
* This is how TypeScript should work, actually.
|
|
376
|
+
*
|
|
377
|
+
* Object.keys always returns strings, so numeric keys are stringified via `${K}`.
|
|
378
|
+
* Symbol keys are excluded (Object.keys does not return symbols).
|
|
376
379
|
*/
|
|
377
380
|
export const _objectKeys = Object.keys as <K extends PropertyKey>(
|
|
378
381
|
obj: Partial<Record<K, any>>,
|
|
379
|
-
) => K[]
|
|
382
|
+
) => (K extends string ? K : K extends number | bigint ? `${K}` : never)[]
|
|
380
383
|
|
|
381
384
|
/**
|
|
382
385
|
* Alias of `Object.entries`, but returns better-typed output.
|
|
383
386
|
*
|
|
387
|
+
* Difference with _stringMapEntries?
|
|
388
|
+
* Use _stringMapEntries when the object is a StringMap<T> - it'll correctly infer T being not undefined.
|
|
389
|
+
* If the object is not a StringMap - use _objectEntries - it'll correctly infer object keys, which can be typed as Enum.
|
|
390
|
+
*
|
|
384
391
|
* So e.g you can use _objectEntries(obj).map([k, v] => {})
|
|
385
392
|
* and `k` will be `keyof obj` instead of generic `string`.
|
|
386
393
|
*/
|
|
387
394
|
export const _objectEntries = Object.entries as <K extends PropertyKey, V>(
|
|
388
395
|
obj: Partial<Record<K, V>>,
|
|
389
|
-
) => [k: K, v: V][]
|
|
396
|
+
) => [k: K extends string ? K : K extends number | bigint ? `${K}` : never, v: V][]
|
|
390
397
|
|
|
391
398
|
export type NullishValue = null | undefined
|
|
392
399
|
export type FalsyValue = false | '' | 0 | null | undefined
|