@ditojs/utils 1.13.0 → 1.14.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/types/index.d.ts +32 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/utils",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "type": "module",
5
5
  "description": "Dito.js Utility Functions – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
6
6
  "repository": "https://github.com/ditojs/dito/tree/master/packages/utils",
@@ -32,8 +32,8 @@
32
32
  "punycode": "^2.1.1"
33
33
  },
34
34
  "devDependencies": {
35
- "typescript": "^4.8.4"
35
+ "typescript": "^4.9.3"
36
36
  },
37
37
  "types": "types",
38
- "gitHead": "b65d7d15871b0d11579565df92780536ef2926da"
38
+ "gitHead": "ba197ae5254deb657b2c3b5dab7a851f488e022a"
39
39
  }
package/types/index.d.ts CHANGED
@@ -93,7 +93,7 @@ export function asObject<O extends {}, T extends any>(arg: T): T & O
93
93
  * the supplied value is undefined, an empty array is returned. Otherwise an
94
94
  * array is returned containing the supplied value as its only element.
95
95
  */
96
- export function asArray<T extends any>(o: T): T extends any[] ? T : T[]
96
+ export function asArray<T>(o: T): T extends any[] ? T : T[]
97
97
 
98
98
  /**
99
99
  * Returns the supplied value as a function.
@@ -101,14 +101,16 @@ export function asArray<T extends any>(o: T): T extends any[] ? T : T[]
101
101
  * When the supplied value is a function, the original function is returned.
102
102
  * Otherwise a function is returned that returns the value when called.
103
103
  */
104
- export function asFunction<T extends any>(o: T): T extends Function ? T : () => T
104
+ export function asFunction<T>(
105
+ o: T
106
+ ): T extends Function ? T : () => T
105
107
 
106
108
  /* --------------------------------- object --------------------------------- */
107
109
 
108
110
  /**
109
111
  * Performs a deep (recursive) clone on the supplied value.
110
112
  */
111
- export function clone<T extends any>(arg: T, iteratee?: (arg: any) => void): T
113
+ export function clone<T>(arg: T, iteratee?: (arg: any) => void): T
112
114
 
113
115
  /**
114
116
  * Determines whether the supplied values can be considered equal through
@@ -119,12 +121,17 @@ export function equals(arg1: any, arg2: any): boolean
119
121
 
120
122
  // TODO: document groupBy
121
123
  export function groupBy<T, K extends string | number | symbol>(
122
- list: T[], callback: (item: T) => K
124
+ list: T[],
125
+ callback: (item: T) => K
123
126
  ): Record<K, T[]>
124
127
 
125
128
  // TODO: document merge
126
129
  export function merge<ArgA, ArgB>(a: ArgA, b: ArgB): ArgA & ArgB
127
- export function merge<ArgA, ArgB, ArgC>(a: ArgA, b: ArgB, c: ArgC): ArgA & ArgB & ArgC
130
+ export function merge<ArgA, ArgB, ArgC>(
131
+ a: ArgA,
132
+ b: ArgB,
133
+ c: ArgC
134
+ ): ArgA & ArgB & ArgC
128
135
  export function merge<ArgA, ArgB, ArgC, ArgD>(
129
136
  a: ArgA,
130
137
  b: ArgB,
@@ -144,7 +151,11 @@ export function merge(...args: any[]): any
144
151
  * Returns the first argument which is not undefined.
145
152
  */
146
153
  export function pick<ArgA, ArgB>(a: ArgA, b: ArgB): ArgA | ArgB
147
- export function pick<ArgA, ArgB, ArgC>(a: ArgA, b: ArgB, c: ArgC): ArgA | ArgB | ArgC
154
+ export function pick<ArgA, ArgB, ArgC>(
155
+ a: ArgA,
156
+ b: ArgB,
157
+ c: ArgC
158
+ ): ArgA | ArgB | ArgC
148
159
  export function pick<ArgA, ArgB, ArgC, ArgD>(
149
160
  a: ArgA,
150
161
  b: ArgB,
@@ -196,7 +207,8 @@ export function capitalize(str: string): string
196
207
  * supplied seperator string.
197
208
  *
198
209
  * @param str The string to decamelize.
199
- * @param {string} [sep=' '] - The string to seperate the decamelized words with.
210
+ * @param {string} [sep=' '] - The string to seperate the decamelized words
211
+ * with.
200
212
  */
201
213
  export function decamelize(str: string, sep?: string): string
202
214
  /**
@@ -216,7 +228,10 @@ export function underscore(str: string): string
216
228
  * you need to break it over multiple lines.`
217
229
  * console.log(str)
218
230
  */
219
- export function deindent(strings: OrArrayOf<string>, ...values: Array<string>): string
231
+ export function deindent(
232
+ strings: OrArrayOf<string>,
233
+ ...values: Array<string>
234
+ ): string
220
235
  /**
221
236
  * Returns the longest prefix string that is common to both supplied strings.
222
237
  */
@@ -401,11 +416,12 @@ export function debounceAsync<T extends (...args: any[]) => Promise<any>>(
401
416
  }
402
417
  ): T & { cancel: () => boolean }
403
418
 
404
- // Adjusted version of @types/node's promisify (which includes support for overloaded
405
- // node function types), excluding the custom promisified function
419
+ // Adjusted version of @types/node's promisify (which includes support for
420
+ // overloaded node function types), excluding the custom promisified function
406
421
  // functionality, which toAsync does not support:
407
422
  // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/fa723dee727e433add7e700420523f0f90e87a01/types/node/util.d.ts#L86
408
- export interface CustomPromisifyLegacy<TCustom extends Function> extends Function {
423
+ interface CustomPromisifyLegacy<TCustom extends Function>
424
+ extends Function {
409
425
  __promisify__: TCustom
410
426
  }
411
427
  type CustomToAsync<TCustom extends Function> = CustomPromisifyLegacy<TCustom>
@@ -416,7 +432,9 @@ type CustomToAsync<TCustom extends Function> = CustomPromisifyLegacy<TCustom>
416
432
  *
417
433
  * @param fn function following the error-first callback style
418
434
  */
419
- export function toAsync<TCustom extends Function>(fn: CustomToAsync<TCustom>): TCustom
435
+ export function toAsync<TCustom extends Function>(
436
+ fn: CustomToAsync<TCustom>
437
+ ): TCustom
420
438
  export function toAsync<R>(
421
439
  fn: (callback: (err: any, result: R) => void) => void
422
440
  ): () => Promise<R>
@@ -587,7 +605,7 @@ export function toCallback<T1, T2, T3, T4, T5, T6, R>(
587
605
  callback: (err: any | null, result: R) => void
588
606
  ) => void
589
607
 
590
- export function toPromiseCallback<T extends any, R extends any>(
608
+ export function toPromiseCallback<T, R>(
591
609
  resolve: (value: T) => void,
592
610
  reject: (reason: R) => void
593
611
  ): (err: R, res: T) => void
@@ -634,5 +652,5 @@ export interface ArrayLike<T> {
634
652
  export interface Dictionary<T> {
635
653
  [index: string]: T
636
654
  }
637
- export interface RecursiveArray<T> extends Array<T | RecursiveArray<T>> {}
655
+ export type RecursiveArray<T> = Array<T | RecursiveArray<T>>
638
656
  type OrArrayOf<T> = T | T[]