@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.
@@ -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
@@ -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;
@@ -17,7 +17,7 @@ exports._parseQueryString = void 0;
17
17
  function _parseQueryString(search) {
18
18
  const qs = {};
19
19
  search
20
- .substr(search[0] === '?' ? 1 : 0)
20
+ .slice(search[0] === '?' ? 1 : 0)
21
21
  .split('&')
22
22
  .forEach(p => {
23
23
  const [k, v] = p.split('=');
@@ -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
  }
@@ -14,7 +14,7 @@
14
14
  export function _parseQueryString(search) {
15
15
  const qs = {};
16
16
  search
17
- .substr(search[0] === '?' ? 1 : 0)
17
+ .slice(search[0] === '?' ? 1 : 0)
18
18
  .split('&')
19
19
  .forEach(p => {
20
20
  const [k, v] = p.split('=');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.104.1",
3
+ "version": "14.104.2",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -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
@@ -16,7 +16,7 @@ export function _sortObjectDeep<T>(o: T): T {
16
16
  Object.keys(o)
17
17
  .sort((a, b) => a.localeCompare(b))
18
18
  .forEach(k => {
19
- out[k] = _sortObjectDeep(o[k])
19
+ out[k as keyof T] = _sortObjectDeep(o[k as keyof T])
20
20
  })
21
21
 
22
22
  return out
@@ -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
- return Object.fromEntries((await Promise.all(Object.values(input))).map((v, i) => [keys[i], v]))
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
  }
@@ -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
- .substr(search[0] === '?' ? 1 : 0)
19
+ .slice(search[0] === '?' ? 1 : 0)
20
20
  .split('&')
21
21
  .forEach(p => {
22
22
  const [k, v] = p.split('=')