@naturalcycles/js-lib 15.106.1 → 15.108.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/array/array.util.js +3 -1
- package/dist/browser/adminService.js +1 -1
- package/dist/datetime/localDate.js +10 -8
- package/dist/decorators/asyncMemo.decorator.d.ts +1 -1
- package/dist/decorators/asyncMemo.decorator.js +88 -86
- package/dist/decorators/memo.decorator.d.ts +1 -1
- package/dist/decorators/memo.decorator.js +62 -60
- package/dist/decorators/memoSimple.decorator.d.ts +1 -1
- package/dist/decorators/memoSimple.decorator.js +39 -37
- package/dist/decorators/memoized.js +2 -2
- package/dist/decorators/memoizedAsync.js +2 -2
- package/dist/decorators/swarmSafe.decorator.d.ts +1 -1
- package/dist/decorators/swarmSafe.decorator.js +28 -26
- package/dist/define.js +2 -2
- package/dist/error/tryCatch.d.ts +1 -1
- package/dist/error/tryCatch.js +7 -5
- package/dist/is.util.d.ts +6 -6
- package/dist/is.util.js +18 -6
- package/dist/log/commonLogger.js +6 -2
- package/dist/object/keySortedMap.js +1 -0
- package/dist/object/lazyKeySortedMap.js +1 -0
- package/dist/promise/pMap.js +2 -2
- package/dist/qr/qr.js +3 -1
- package/dist/semver.js +3 -1
- package/dist/string/safeJsonStringify.js +5 -5
- package/dist/string/slugify.js +4 -6
- package/dist/string/string.util.js +4 -4
- package/dist/types.d.ts +1 -1
- package/dist/types.js +3 -1
- package/dist/ua/ua.js +1 -1
- package/package.json +2 -2
- package/src/array/array.util.ts +3 -1
- package/src/browser/adminService.ts +2 -1
- package/src/datetime/localDate.ts +11 -7
- package/src/decorators/asyncMemo.decorator.ts +3 -3
- package/src/decorators/memo.decorator.ts +3 -3
- package/src/decorators/memoSimple.decorator.ts +14 -14
- package/src/decorators/memoized.ts +1 -1
- package/src/decorators/memoizedAsync.ts +1 -1
- package/src/decorators/swarmSafe.decorator.ts +29 -27
- package/src/define.ts +1 -1
- package/src/error/tryCatch.ts +3 -3
- package/src/is.util.ts +22 -6
- package/src/log/commonLogger.ts +5 -2
- package/src/object/keySortedMap.ts +1 -0
- package/src/object/lazyKeySortedMap.ts +1 -0
- package/src/promise/pMap.ts +1 -1
- package/src/qr/qr.ts +5 -1
- package/src/semver.ts +5 -1
- package/src/string/safeJsonStringify.ts +4 -4
- package/src/string/slugify.ts +7 -9
- package/src/string/string.util.ts +4 -4
- package/src/types.ts +3 -1
- package/src/ua/ua.ts +1 -1
|
@@ -32,12 +32,12 @@ function serializer(replacer?: Reviver, cycleReplacer?: Reviver): Reviver {
|
|
|
32
32
|
return function (key, value) {
|
|
33
33
|
if (stack.length > 0) {
|
|
34
34
|
const thisPos = stack.indexOf(this)
|
|
35
|
-
if (thisPos
|
|
36
|
-
stack.splice(thisPos + 1)
|
|
37
|
-
keys.splice(thisPos, Infinity, key)
|
|
38
|
-
} else {
|
|
35
|
+
if (thisPos === -1) {
|
|
39
36
|
stack.push(this)
|
|
40
37
|
keys.push(key)
|
|
38
|
+
} else {
|
|
39
|
+
stack.splice(thisPos + 1)
|
|
40
|
+
keys.splice(thisPos, Infinity, key)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
if (stack.includes(value)) {
|
package/src/string/slugify.ts
CHANGED
|
@@ -61,16 +61,14 @@ function buildPatternSlug(options: any): RegExp {
|
|
|
61
61
|
let negationSetPattern = String.raw`a-z\d`
|
|
62
62
|
negationSetPattern += options.lowercase ? '' : 'A-Z'
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
negationSetPattern += escapeStringRegexp(character)
|
|
64
|
+
for (const character of options.preserveCharacters) {
|
|
65
|
+
if (character === options.separator) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`The separator character \`${options.separator}\` cannot be included in preserved characters: ${options.preserveCharacters}`,
|
|
68
|
+
)
|
|
73
69
|
}
|
|
70
|
+
|
|
71
|
+
negationSetPattern += escapeStringRegexp(character)
|
|
74
72
|
}
|
|
75
73
|
|
|
76
74
|
return new RegExp(`[^${negationSetPattern}]+`, 'g')
|
|
@@ -70,22 +70,22 @@ export function _truncateMiddle(s: string, maxLen: number, omission = '...'): st
|
|
|
70
70
|
|
|
71
71
|
export function _substringBefore(s: string, delimiter: string): string {
|
|
72
72
|
const pos = s.indexOf(delimiter)
|
|
73
|
-
return s.slice(0, pos
|
|
73
|
+
return s.slice(0, pos === -1 ? undefined : pos)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export function _substringBeforeLast(s: string, delimiter: string): string {
|
|
77
77
|
const pos = s.lastIndexOf(delimiter)
|
|
78
|
-
return s.slice(0, pos
|
|
78
|
+
return s.slice(0, pos === -1 ? undefined : pos)
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export function _substringAfter(s: string, delimiter: string): string {
|
|
82
82
|
const pos = s.indexOf(delimiter)
|
|
83
|
-
return pos
|
|
83
|
+
return pos === -1 ? s : s.slice(pos + delimiter.length)
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
export function _substringAfterLast(s: string, delimiter: string): string {
|
|
87
87
|
const pos = s.lastIndexOf(delimiter)
|
|
88
|
-
return pos
|
|
88
|
+
return pos === -1 ? s : s.slice(pos + delimiter.length)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
package/src/types.ts
CHANGED
|
@@ -182,7 +182,9 @@ export const _passUndefinedMapper: IndexedMapper<any, void> = () => undefined
|
|
|
182
182
|
/**
|
|
183
183
|
* Function that does nothings and returns `undefined`.
|
|
184
184
|
*/
|
|
185
|
-
export
|
|
185
|
+
export function _noop(..._args: any[]): undefined {
|
|
186
|
+
return undefined
|
|
187
|
+
}
|
|
186
188
|
|
|
187
189
|
export type Predicate<T> = (item: T, index: number) => boolean
|
|
188
190
|
export type AsyncPredicate<T> = (item: T, index: number) => PromiseLike<boolean>
|
package/src/ua/ua.ts
CHANGED
|
@@ -180,7 +180,7 @@ export function uaParser(userAgent?: string, extensions?: UAParserExtensions): U
|
|
|
180
180
|
*/
|
|
181
181
|
export class UAParser {
|
|
182
182
|
constructor(ua?: string, extensions?: UAParserExtensions) {
|
|
183
|
-
this.nav = typeof globalThis.window
|
|
183
|
+
this.nav = typeof globalThis.window === 'undefined' ? undefined : globalThis.navigator
|
|
184
184
|
this.rgxMap = extensions ? extend(regexes, extensions) : regexes
|
|
185
185
|
const initialUa = ua || this.nav?.userAgent || ''
|
|
186
186
|
// Whether we're parsing the environment's own UA - only then the
|