@naturalcycles/js-lib 15.100.0 → 15.102.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.
- package/dist/abort.d.ts +0 -8
- package/dist/abort.js +2 -19
- package/dist/array/array.util.d.ts +1 -3
- package/dist/array/array.util.js +1 -3
- package/dist/array/sort.js +1 -1
- package/dist/array/sortedSet.d.ts +1 -1
- package/dist/array/sortedSet.js +1 -1
- package/dist/asyncManager.js +5 -4
- package/dist/browser/analytics.util.js +3 -2
- package/dist/browser/topbar.js +1 -1
- package/dist/datetime/localDate.js +10 -5
- package/dist/datetime/localTime.d.ts +4 -0
- package/dist/datetime/localTime.js +17 -8
- package/dist/datetime/time.util.d.ts +18 -1
- package/dist/datetime/time.util.js +28 -2
- package/dist/decorators/createPromiseDecorator.js +2 -1
- package/dist/decorators/debounce.js +7 -6
- package/dist/decorators/logMethod.decorator.js +3 -3
- package/dist/enum.util.js +1 -0
- package/dist/error/tryCatch.js +2 -2
- package/dist/http/fetcher.js +13 -13
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -1
- package/dist/object/deepEquals.js +2 -0
- package/dist/object/keySortedMap.js +1 -1
- package/dist/object/lazyKeySortedMap.js +1 -1
- package/dist/object/object.util.js +2 -2
- package/dist/promise/pGradualQueue.js +3 -2
- package/dist/promise/pRetry.js +2 -2
- package/dist/semver.js +10 -5
- package/dist/string/stringify.js +1 -2
- package/package.json +4 -2
- package/src/abort.ts +2 -21
- package/src/array/array.util.ts +1 -3
- package/src/array/sort.ts +1 -1
- package/src/array/sortedSet.ts +1 -1
- package/src/asyncManager.ts +5 -4
- package/src/browser/analytics.util.ts +3 -2
- package/src/browser/topbar.ts +1 -1
- package/src/datetime/localDate.ts +12 -6
- package/src/datetime/localTime.ts +19 -9
- package/src/datetime/time.util.ts +32 -3
- package/src/decorators/createPromiseDecorator.ts +2 -1
- package/src/decorators/debounce.ts +7 -6
- package/src/decorators/logMethod.decorator.ts +3 -3
- package/src/enum.util.ts +1 -0
- package/src/error/tryCatch.ts +3 -3
- package/src/http/fetcher.ts +15 -20
- package/src/index.ts +1 -1
- package/src/object/deepEquals.ts +2 -0
- package/src/object/keySortedMap.ts +1 -1
- package/src/object/lazyKeySortedMap.ts +1 -1
- package/src/object/object.util.ts +2 -2
- package/src/promise/pGradualQueue.ts +3 -2
- package/src/promise/pRetry.ts +3 -3
- package/src/semver.ts +11 -7
- package/src/string/stringify.ts +2 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nowUnixMillis } from '../datetime/time.util.js'
|
|
1
2
|
import { ErrorMode } from '../error/errorMode.js'
|
|
2
3
|
import { createCommonLoggerAtLevel } from '../log/commonLogger.js'
|
|
3
4
|
import type { CommonLogger, CommonLogLevel } from '../log/commonLogger.js'
|
|
@@ -73,7 +74,7 @@ export class PGradualQueue {
|
|
|
73
74
|
// Fast-path: warmup complete
|
|
74
75
|
if (this.warmupComplete) return this.cfg.concurrency
|
|
75
76
|
|
|
76
|
-
const elapsed =
|
|
77
|
+
const elapsed = nowUnixMillis() - this.startTime
|
|
77
78
|
if (elapsed >= this.warmupMs) {
|
|
78
79
|
this.warmupComplete = true
|
|
79
80
|
this.logger.debug('warmup complete')
|
|
@@ -92,7 +93,7 @@ export class PGradualQueue {
|
|
|
92
93
|
async push<R>(fn: AsyncFunction<R>): Promise<R> {
|
|
93
94
|
// Initialize start time on first push
|
|
94
95
|
if (this.startTime === 0) {
|
|
95
|
-
this.startTime =
|
|
96
|
+
this.startTime = nowUnixMillis()
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
const job: PGradualQueueJob<R> = { fn, defer: pDefer<R>() }
|
package/src/promise/pRetry.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { _since } from '../datetime/time.util.js'
|
|
1
|
+
import { _since, nowUnixMillis } from '../datetime/time.util.js'
|
|
2
2
|
import type { ErrorData } from '../error/error.model.js'
|
|
3
3
|
import { _errorDataAppend } from '../error/error.util.js'
|
|
4
4
|
import { consoleLogger } from '../log/commonLogger.js'
|
|
5
5
|
import type { CommonLogger } from '../log/commonLogger.js'
|
|
6
|
-
import type { AnyAsyncFunction
|
|
6
|
+
import type { AnyAsyncFunction } from '../types.js'
|
|
7
7
|
import { pDelay } from './pDelay.js'
|
|
8
8
|
import { pTimeout } from './pTimeout.js'
|
|
9
9
|
|
|
@@ -141,7 +141,7 @@ export async function pRetry<T>(
|
|
|
141
141
|
let attempt = 0
|
|
142
142
|
|
|
143
143
|
while (true) {
|
|
144
|
-
const started =
|
|
144
|
+
const started = nowUnixMillis()
|
|
145
145
|
|
|
146
146
|
try {
|
|
147
147
|
attempt++
|
package/src/semver.ts
CHANGED
|
@@ -147,13 +147,17 @@ interface SemverFn extends SemverFactory {
|
|
|
147
147
|
(input: SemverInput): Semver
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
// Built inside a function, so the whole construct can be marked pure and tree-shaken (see treeshake.test.ts)
|
|
151
|
+
export const semver2 = /* @__PURE__ */ createSemverFn()
|
|
152
|
+
|
|
153
|
+
function createSemverFn(): SemverFn {
|
|
154
|
+
const semverFactory = new SemverFactory()
|
|
155
|
+
const fn = semverFactory.fromInput.bind(semverFactory) as SemverFn
|
|
156
|
+
// The line below is the blackest of black magic I have ever written in 2024.
|
|
157
|
+
// And probably 2023 as well.
|
|
158
|
+
Object.setPrototypeOf(fn, semverFactory)
|
|
159
|
+
return fn
|
|
160
|
+
}
|
|
157
161
|
|
|
158
162
|
/**
|
|
159
163
|
* Returns 1 if a > b
|
package/src/string/stringify.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
+
import type { ErrorLike } from '../error/error.model.js'
|
|
1
2
|
// oxlint-disable-next-line import/no-cycle -- intentional cycle
|
|
2
3
|
import { _isBackendErrorResponseObject, _isErrorLike, _isErrorObject } from '../error/error.util.js'
|
|
3
|
-
import type { ErrorLike } from '../error/index.js'
|
|
4
4
|
import type { Reviver } from '../types.js'
|
|
5
5
|
// oxlint-disable-next-line import/no-cycle -- intentional cycle
|
|
6
6
|
import { _jsonParseIfPossible } from './json.util.js'
|
|
7
7
|
import { _safeJsonStringify } from './safeJsonStringify.js'
|
|
8
8
|
import { _truncateMiddle } from './string.util.js'
|
|
9
9
|
|
|
10
|
-
const supportsAggregateError = typeof globalThis.AggregateError === 'function'
|
|
11
|
-
|
|
12
10
|
let globalStringifyFunction: JsonStringifyFunction = _safeJsonStringify
|
|
13
11
|
|
|
14
12
|
/**
|
|
@@ -184,7 +182,7 @@ function stringifyErrorLike(obj: Error | ErrorLike, opt: StringifyOptions): stri
|
|
|
184
182
|
s = [s, ...obj.stack.split('\n').slice(sLines)].join('\n')
|
|
185
183
|
}
|
|
186
184
|
|
|
187
|
-
if (
|
|
185
|
+
if (obj instanceof AggregateError && obj.errors.length) {
|
|
188
186
|
s = [
|
|
189
187
|
s,
|
|
190
188
|
`${obj.errors.length} error(s):`,
|