@naturalcycles/js-lib 14.104.1 → 14.104.2
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/object/object.util.js +1 -0
- package/dist/promise/pProps.js +2 -0
- package/dist/string/url.util.js +1 -1
- package/dist-esm/object/object.util.js +1 -0
- package/dist-esm/promise/pProps.js +2 -0
- package/dist-esm/string/url.util.js +1 -1
- package/package.json +1 -1
- package/src/object/object.util.ts +5 -4
- package/src/object/sortObjectDeep.ts +1 -1
- package/src/promise/pProps.ts +5 -1
- package/src/string/url.util.ts +2 -2
|
@@ -330,6 +330,7 @@ function _set(obj, path, value) {
|
|
|
330
330
|
a[c]
|
|
331
331
|
: // No: create the key. Is the next key a potential array-index?
|
|
332
332
|
(a[c] =
|
|
333
|
+
// @ts-ignore
|
|
333
334
|
// eslint-disable-next-line
|
|
334
335
|
Math.abs(path[i + 1]) >> 0 === +path[i + 1]
|
|
335
336
|
? [] // Yes: assign a new array object
|
package/dist/promise/pProps.js
CHANGED
|
@@ -17,6 +17,8 @@ exports.pProps = void 0;
|
|
|
17
17
|
*/
|
|
18
18
|
async function pProps(input) {
|
|
19
19
|
const keys = Object.keys(input);
|
|
20
|
+
// `as any` here is added to make it compile when `noUncheckedIndexedAccess` is false
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
20
22
|
return Object.fromEntries((await Promise.all(Object.values(input))).map((v, i) => [keys[i], v]));
|
|
21
23
|
}
|
|
22
24
|
exports.pProps = pProps;
|
package/dist/string/url.util.js
CHANGED
|
@@ -306,6 +306,7 @@ export function _set(obj, path, value) {
|
|
|
306
306
|
a[c]
|
|
307
307
|
: // No: create the key. Is the next key a potential array-index?
|
|
308
308
|
(a[c] =
|
|
309
|
+
// @ts-ignore
|
|
309
310
|
// eslint-disable-next-line
|
|
310
311
|
Math.abs(path[i + 1]) >> 0 === +path[i + 1]
|
|
311
312
|
? [] // Yes: assign a new array object
|
|
@@ -14,5 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export async function pProps(input) {
|
|
16
16
|
const keys = Object.keys(input);
|
|
17
|
+
// `as any` here is added to make it compile when `noUncheckedIndexedAccess` is false
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
17
19
|
return Object.fromEntries((await Promise.all(Object.values(input))).map((v, i) => [keys[i], v]));
|
|
18
20
|
}
|
package/package.json
CHANGED
|
@@ -125,7 +125,7 @@ export function _mapValues<T extends AnyObject, OUT = T>(
|
|
|
125
125
|
mutate = false,
|
|
126
126
|
): OUT {
|
|
127
127
|
return Object.entries(obj).reduce((map, [k, v]) => {
|
|
128
|
-
map[k] = mapper(k, v, obj)
|
|
128
|
+
map[k as keyof OUT] = mapper(k, v, obj)
|
|
129
129
|
return map
|
|
130
130
|
}, (mutate ? obj : {}) as OUT)
|
|
131
131
|
}
|
|
@@ -142,9 +142,9 @@ export function _mapKeys<T extends AnyObject>(
|
|
|
142
142
|
): StringMap<T[keyof T]> {
|
|
143
143
|
// eslint-disable-next-line unicorn/prefer-object-from-entries
|
|
144
144
|
return Object.entries(obj).reduce((map, [k, v]) => {
|
|
145
|
-
map[mapper(k, v, obj)] = v
|
|
145
|
+
map[mapper(k, v, obj) as keyof T] = v
|
|
146
146
|
return map
|
|
147
|
-
}, {})
|
|
147
|
+
}, {} as T)
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
/**
|
|
@@ -299,7 +299,7 @@ export function _unset<T extends AnyObject>(obj: T, prop: string): void {
|
|
|
299
299
|
export function _invert<T extends AnyObject>(o: T): { [k in ValueOf<T>]: keyof T | undefined } {
|
|
300
300
|
const inv = {} as { [k in ValueOf<T>]: keyof T }
|
|
301
301
|
Object.keys(o).forEach(k => {
|
|
302
|
-
inv[o[k]] = k
|
|
302
|
+
inv[o[k] as ValueOf<T>] = k
|
|
303
303
|
})
|
|
304
304
|
return inv
|
|
305
305
|
}
|
|
@@ -365,6 +365,7 @@ export function _set<IN extends AnyObject, OUT = IN>(
|
|
|
365
365
|
a[c]
|
|
366
366
|
: // No: create the key. Is the next key a potential array-index?
|
|
367
367
|
(a[c] =
|
|
368
|
+
// @ts-ignore
|
|
368
369
|
// eslint-disable-next-line
|
|
369
370
|
Math.abs(path[i + 1]) >> 0 === +path[i + 1]
|
|
370
371
|
? [] // Yes: assign a new array object
|
package/src/promise/pProps.ts
CHANGED
|
@@ -16,5 +16,9 @@ export async function pProps<T>(input: { [K in keyof T]: T[K] | Promise<T[K]> })
|
|
|
16
16
|
[K in keyof T]: Awaited<T[K]>
|
|
17
17
|
}> {
|
|
18
18
|
const keys = Object.keys(input)
|
|
19
|
-
|
|
19
|
+
// `as any` here is added to make it compile when `noUncheckedIndexedAccess` is false
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
21
|
+
return Object.fromEntries(
|
|
22
|
+
(await Promise.all(Object.values(input))).map((v, i) => [keys[i], v]),
|
|
23
|
+
) as any
|
|
20
24
|
}
|
package/src/string/url.util.ts
CHANGED
|
@@ -14,9 +14,9 @@ import { StringMap } from '../types'
|
|
|
14
14
|
* Goal of this function is to produce exactly same output as URLSearchParams would.
|
|
15
15
|
*/
|
|
16
16
|
export function _parseQueryString(search: string): StringMap {
|
|
17
|
-
const qs = {}
|
|
17
|
+
const qs: StringMap = {}
|
|
18
18
|
search
|
|
19
|
-
.
|
|
19
|
+
.slice(search[0] === '?' ? 1 : 0)
|
|
20
20
|
.split('&')
|
|
21
21
|
.forEach(p => {
|
|
22
22
|
const [k, v] = p.split('=')
|