@revolugo/common 7.2.4-alpha.2 → 7.2.4-alpha.21
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/package.json +4 -4
- package/src/amenities/index.ts +1 -1
- package/src/constants/environment.ts +2 -2
- package/src/constants/locales.ts +17 -17
- package/src/icons/index.ts +1 -1
- package/src/types/elements/allowed-payment-method.ts +1 -1
- package/src/utils/amount-from-percentage.ts +1 -1
- package/src/utils/case-transformers.ts +5 -5
- package/src/utils/create-composite-key.ts +1 -1
- package/src/utils/dates.ts +1 -1
- package/src/utils/group-by.ts +2 -2
- package/src/utils/images.ts +1 -1
- package/src/utils/key-by.ts +1 -1
- package/src/utils/map-keys.ts +2 -2
- package/src/utils/map-values.ts +1 -1
- package/src/utils/omit-by.ts +1 -1
- package/src/utils/omit.ts +1 -1
- package/src/utils/poller.ts +3 -3
- package/src/utils/prepare-ts-query.ts +4 -4
- package/src/utils/sort-by.ts +1 -1
- package/src/utils/sum.ts +2 -2
- package/src/utils/to-lang.ts +8 -8
- package/src/utils/to-locale.ts +8 -8
- package/src/utils/uniq-by.ts +2 -2
- package/src/utils/uniq.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revolugo/common",
|
|
3
|
-
"version": "7.2.4-alpha.
|
|
3
|
+
"version": "7.2.4-alpha.21",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Revolugo common",
|
|
6
6
|
"author": "Revolugo",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"./utils": "./src/utils/index.ts"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@asteasolutions/zod-to-openapi": "8.4.
|
|
26
|
+
"@asteasolutions/zod-to-openapi": "8.4.3",
|
|
27
27
|
"change-case": "5.4.4",
|
|
28
|
-
"dayjs": "1.11.
|
|
28
|
+
"dayjs": "1.11.20",
|
|
29
29
|
"ky": "1.14.3",
|
|
30
|
-
"slugify": "1.6.
|
|
30
|
+
"slugify": "1.6.8",
|
|
31
31
|
"type-fest": "5.4.4",
|
|
32
32
|
"uuid": "13.0.0",
|
|
33
33
|
"zod": "4.3.6"
|
package/src/amenities/index.ts
CHANGED
|
@@ -20,10 +20,10 @@ export const AMENITY_TO_ICONS = Object.freeze({
|
|
|
20
20
|
GolfCourse: 'golf',
|
|
21
21
|
HairDryer: 'hairDryer',
|
|
22
22
|
HandicapAccessible: 'wheelchair',
|
|
23
|
+
IndoorPool: 'swimmingPool',
|
|
23
24
|
InHouseBar: 'champagne',
|
|
24
25
|
InHouseDining: 'forkKnife',
|
|
25
26
|
InRoomMovies: 'filmReel',
|
|
26
|
-
IndoorPool: 'swimmingPool',
|
|
27
27
|
InteriorRoomEntrance: 'doorOpen',
|
|
28
28
|
Kitchen: 'forkKnife',
|
|
29
29
|
Map: 'mapPin',
|
|
@@ -52,9 +52,9 @@ export enum BookingEnvironment {
|
|
|
52
52
|
|
|
53
53
|
/* @__PURE__ */
|
|
54
54
|
export const BOOKING_API_URLS = {
|
|
55
|
+
[Environment.CiCd]: 'https://booking-api.staging.revolugo.com',
|
|
56
|
+
[Environment.Local]: 'http://127.0.0.1:3001',
|
|
55
57
|
[Environment.Production]: 'https://booking-api.revolugo.com',
|
|
56
58
|
[Environment.Sandbox]: 'https://booking-api.sandbox.revolugo.com',
|
|
57
59
|
[Environment.Staging]: 'https://booking-api.staging.revolugo.com',
|
|
58
|
-
[Environment.CiCd]: 'https://booking-api.staging.revolugo.com',
|
|
59
|
-
[Environment.Local]: 'http://127.0.0.1:3001',
|
|
60
60
|
}
|
package/src/constants/locales.ts
CHANGED
|
@@ -19,7 +19,7 @@ export enum Lang {
|
|
|
19
19
|
PT = 'pt',
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export type ExtendedLocale =
|
|
22
|
+
export type ExtendedLocale = Lang | Locale
|
|
23
23
|
|
|
24
24
|
export function langFromString(langStr: string): Lang | undefined {
|
|
25
25
|
return Object.entries(Lang).find(entry => {
|
|
@@ -33,10 +33,10 @@ export function langFromString(langStr: string): Lang | undefined {
|
|
|
33
33
|
|
|
34
34
|
/* @__PURE__ */
|
|
35
35
|
export const LANG_TO_LOCALE: Record<Lang, Locale> = {
|
|
36
|
-
[Lang.EN]: Locale.en_US,
|
|
37
|
-
[Lang.FR]: Locale.fr_FR,
|
|
38
36
|
[Lang.DE]: Locale.de_DE,
|
|
37
|
+
[Lang.EN]: Locale.en_US,
|
|
39
38
|
[Lang.ES]: Locale.es_ES,
|
|
39
|
+
[Lang.FR]: Locale.fr_FR,
|
|
40
40
|
[Lang.IT]: Locale.it_IT,
|
|
41
41
|
[Lang.NL]: Locale.nl_NL,
|
|
42
42
|
[Lang.PT]: Locale.pt_PT,
|
|
@@ -55,20 +55,6 @@ export const LOCALE_TO_LANG = {
|
|
|
55
55
|
|
|
56
56
|
/* @__PURE__ */
|
|
57
57
|
export const LOCALES = {
|
|
58
|
-
[Locale.en_US]: {
|
|
59
|
-
code: Locale.en_US,
|
|
60
|
-
countryCode: 'US',
|
|
61
|
-
icon: '🇺🇸',
|
|
62
|
-
locale: Lang.EN,
|
|
63
|
-
name: 'English',
|
|
64
|
-
},
|
|
65
|
-
[Locale.fr_FR]: {
|
|
66
|
-
code: Locale.fr_FR,
|
|
67
|
-
countryCode: 'FR',
|
|
68
|
-
icon: '🇫🇷',
|
|
69
|
-
locale: Lang.FR,
|
|
70
|
-
name: 'Français',
|
|
71
|
-
},
|
|
72
58
|
[Locale.de_DE]: {
|
|
73
59
|
code: Locale.de_DE,
|
|
74
60
|
countryCode: 'DE',
|
|
@@ -76,6 +62,13 @@ export const LOCALES = {
|
|
|
76
62
|
locale: Lang.DE,
|
|
77
63
|
name: 'Deutsch',
|
|
78
64
|
},
|
|
65
|
+
[Locale.en_US]: {
|
|
66
|
+
code: Locale.en_US,
|
|
67
|
+
countryCode: 'US',
|
|
68
|
+
icon: '🇺🇸',
|
|
69
|
+
locale: Lang.EN,
|
|
70
|
+
name: 'English',
|
|
71
|
+
},
|
|
79
72
|
[Locale.es_ES]: {
|
|
80
73
|
code: Locale.es_ES,
|
|
81
74
|
countryCode: 'ES',
|
|
@@ -83,6 +76,13 @@ export const LOCALES = {
|
|
|
83
76
|
locale: Lang.ES,
|
|
84
77
|
name: 'Español',
|
|
85
78
|
},
|
|
79
|
+
[Locale.fr_FR]: {
|
|
80
|
+
code: Locale.fr_FR,
|
|
81
|
+
countryCode: 'FR',
|
|
82
|
+
icon: '🇫🇷',
|
|
83
|
+
locale: Lang.FR,
|
|
84
|
+
name: 'Français',
|
|
85
|
+
},
|
|
86
86
|
[Locale.it_IT]: {
|
|
87
87
|
code: Locale.it_IT,
|
|
88
88
|
countryCode: 'IT',
|
package/src/icons/index.ts
CHANGED
|
@@ -167,7 +167,6 @@ export const ICONS_NAME = Object.freeze({
|
|
|
167
167
|
subway: 'ph:subway',
|
|
168
168
|
swimmingPool: 'ph:swimming-pool',
|
|
169
169
|
synagogue: 'ph:synagogue',
|
|
170
|
-
tShirt: 'ph:t-shirt',
|
|
171
170
|
taxi: 'ph:taxi',
|
|
172
171
|
tennisBall: 'ph:tennis-ball',
|
|
173
172
|
tent: 'ph:tent',
|
|
@@ -181,6 +180,7 @@ export const ICONS_NAME = Object.freeze({
|
|
|
181
180
|
trendDown: 'ph:trend-down',
|
|
182
181
|
trendUp: 'ph:trend-up',
|
|
183
182
|
truck: 'ph:truck',
|
|
183
|
+
tShirt: 'ph:t-shirt',
|
|
184
184
|
upload: 'ph:upload-simple',
|
|
185
185
|
uploadThick: 'ph:arrow-fat-line-up',
|
|
186
186
|
user: 'ph:user',
|
|
@@ -7,10 +7,10 @@ import type {
|
|
|
7
7
|
} from './payment-method.ts'
|
|
8
8
|
|
|
9
9
|
export type AllowedPaymentMethod =
|
|
10
|
+
| AllowedPaymentMethodPayLater
|
|
10
11
|
| BasePaymentMethodCoupon
|
|
11
12
|
| BasePaymentMethodCreditCard
|
|
12
13
|
| BasePaymentMethodDepositAccount
|
|
13
|
-
| AllowedPaymentMethodPayLater
|
|
14
14
|
|
|
15
15
|
export interface AllowedPaymentMethodPayLater extends BasePaymentMethodPayLater {
|
|
16
16
|
payload: PayloadPayLater
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function amountFromPercentage(
|
|
2
2
|
percentage: number,
|
|
3
3
|
amount: number,
|
|
4
|
-
roundingType: '
|
|
4
|
+
roundingType: 'ceil' | 'floor' | 'none' | 'round' = 'none',
|
|
5
5
|
): number {
|
|
6
6
|
if (Number.isNaN(Number(percentage)) || Number.isNaN(Number(amount))) {
|
|
7
7
|
throw new TypeError(`${percentage} || ${amount} is NaN`)
|
|
@@ -32,7 +32,7 @@ export const CASE_TRANSFORMERS_MAPPING = {
|
|
|
32
32
|
[CaseTransformer.Snake]: snakeCase,
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export function changeCase<T extends string | string
|
|
35
|
+
export function changeCase<T extends string[] | string>(
|
|
36
36
|
input: T,
|
|
37
37
|
toCase: CaseTransformer,
|
|
38
38
|
): T extends string ? string : string[] {
|
|
@@ -47,7 +47,7 @@ export function changeCase<T extends string | string[]>(
|
|
|
47
47
|
: string[]
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
function matches(patterns: (
|
|
50
|
+
function matches(patterns: (RegExp | string)[], value: string) {
|
|
51
51
|
return patterns.some(pattern =>
|
|
52
52
|
typeof pattern === 'string' ? pattern === value : pattern.test(value),
|
|
53
53
|
)
|
|
@@ -62,14 +62,14 @@ export function keysChangeCase<T = any>(
|
|
|
62
62
|
obj: any[],
|
|
63
63
|
toCase: CaseTransformer,
|
|
64
64
|
|
|
65
|
-
options?: { deep?: boolean; exclude?: (
|
|
65
|
+
options?: { deep?: boolean; exclude?: (RegExp | string)[] },
|
|
66
66
|
): T[]
|
|
67
67
|
|
|
68
68
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
69
69
|
export function keysChangeCase<T = any>(
|
|
70
70
|
obj: unknown,
|
|
71
71
|
toCase: CaseTransformer,
|
|
72
|
-
options?: { deep?: boolean; exclude?: (
|
|
72
|
+
options?: { deep?: boolean; exclude?: (RegExp | string)[] },
|
|
73
73
|
): T
|
|
74
74
|
|
|
75
75
|
export function keysChangeCase<T>(
|
|
@@ -77,7 +77,7 @@ export function keysChangeCase<T>(
|
|
|
77
77
|
obj: any,
|
|
78
78
|
toCase: CaseTransformer,
|
|
79
79
|
|
|
80
|
-
options: { deep?: boolean; exclude?: (
|
|
80
|
+
options: { deep?: boolean; exclude?: (RegExp | string)[] } = { deep: true },
|
|
81
81
|
): unknown {
|
|
82
82
|
if (isObject(obj) && !(obj instanceof Date)) {
|
|
83
83
|
return Object.keys(obj).reduce<any>((result, key) => {
|
|
@@ -16,7 +16,7 @@ type CompositeKeyOptions<T> =
|
|
|
16
16
|
NonNullable<T> extends (infer U)[]
|
|
17
17
|
? CompositeKeyOptions<U>
|
|
18
18
|
: CompositeLeafAttributes & {
|
|
19
|
-
attributes: CompositeOmitAttributes<T>
|
|
19
|
+
attributes: CompositeAttributesType | CompositeOmitAttributes<T>
|
|
20
20
|
children?: {
|
|
21
21
|
[K in keyof T]?: NonNullable<T[K]> extends object
|
|
22
22
|
? CompositeKeyOptions<NonNullable<T[K]>>
|
package/src/utils/dates.ts
CHANGED
|
@@ -72,7 +72,7 @@ export function isDate(value: unknown): value is Date {
|
|
|
72
72
|
return value instanceof Date && !isNaN(value.getTime())
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export type DateInput =
|
|
75
|
+
export type DateInput = Date | string
|
|
76
76
|
|
|
77
77
|
export function generateDates(
|
|
78
78
|
startDate: DateInput,
|
package/src/utils/group-by.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @param keyOrGetter The key to group by or a function that returns the key.
|
|
5
5
|
* @returns An object where keys are the group identifiers and values are arrays of items.
|
|
6
6
|
*/
|
|
7
|
-
function groupBy<T, K extends
|
|
7
|
+
function groupBy<T, K extends number | string>(
|
|
8
8
|
array: T[],
|
|
9
|
-
keyOrGetter:
|
|
9
|
+
keyOrGetter: ((item: T) => K | undefined) | keyof T,
|
|
10
10
|
): Record<K, T[]> {
|
|
11
11
|
return array.reduce(
|
|
12
12
|
(acc, item) => {
|
package/src/utils/images.ts
CHANGED
package/src/utils/key-by.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export function keyBy<T>(
|
|
10
10
|
collection: T[] | null | undefined,
|
|
11
|
-
iteratee: ((value: T) =>
|
|
11
|
+
iteratee: ((value: T) => number | string) | keyof T,
|
|
12
12
|
): Record<string, T> {
|
|
13
13
|
return (
|
|
14
14
|
collection?.reduce<Record<string, T>>((acc, item) => {
|
package/src/utils/map-keys.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export const mapKeys = <
|
|
6
6
|
TValue,
|
|
7
|
-
TKey extends
|
|
8
|
-
TNewKey extends
|
|
7
|
+
TKey extends number | string | symbol,
|
|
8
|
+
TNewKey extends number | string | symbol,
|
|
9
9
|
>(
|
|
10
10
|
obj: Record<TKey, TValue>,
|
|
11
11
|
mapFunc: (key: TKey, value: TValue) => TNewKey,
|
package/src/utils/map-values.ts
CHANGED
package/src/utils/omit-by.ts
CHANGED
package/src/utils/omit.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// eslint-disable-next-line no-restricted-syntax
|
|
7
7
|
export function omit<T extends object, K extends keyof T>(
|
|
8
8
|
object: T | null | undefined,
|
|
9
|
-
keys: readonly K[]
|
|
9
|
+
keys: K | readonly K[],
|
|
10
10
|
// eslint-disable-next-line no-restricted-syntax
|
|
11
11
|
): Omit<T, K> {
|
|
12
12
|
if (object === null || object === undefined) {
|
package/src/utils/poller.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { CaseTransformer, keysChangeCase } from './case-transformers.ts'
|
|
|
6
6
|
export interface IPollerResponse<T = any> {
|
|
7
7
|
data?: T
|
|
8
8
|
meta?: {
|
|
9
|
-
status: '
|
|
9
|
+
status: 'COMPLETE' | 'IN_PROGRESS'
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ export type TPollerRequestCallback<V> = () => Promise<V>
|
|
|
14
14
|
export type TPollerEventCallbackArg<
|
|
15
15
|
V extends IPollerResponse = IPollerResponse,
|
|
16
16
|
> = V | Error
|
|
17
|
-
export type TPollerEventName = '
|
|
17
|
+
export type TPollerEventName = 'complete' | 'data' | 'error'
|
|
18
18
|
export type TPollerEventCallback<V extends IPollerResponse = IPollerResponse> =
|
|
19
19
|
(arg?: TPollerEventCallbackArg<V>) => void
|
|
20
20
|
export type TPollerEvents<V extends IPollerResponse = IPollerResponse> = {
|
|
@@ -233,7 +233,7 @@ export function pollRequest<R extends IPollerResponse>(
|
|
|
233
233
|
request: TRequest<R>,
|
|
234
234
|
options: TOptions<R>,
|
|
235
235
|
pollerCallback?: TPollerCallback<R>,
|
|
236
|
-
): Promise<PollerReturn<R> | R | undefined> |
|
|
236
|
+
): PollerReturn<R> | Promise<PollerReturn<R> | R | undefined> | R | undefined {
|
|
237
237
|
const poller: Poller<R> = Poller.getInstance()
|
|
238
238
|
|
|
239
239
|
poller.poll(request, options)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const TS_QUERY_SPECIAL_CHARS = new Set([
|
|
2
|
-
'&',
|
|
3
|
-
'|',
|
|
4
|
-
':',
|
|
5
2
|
'!',
|
|
3
|
+
'&',
|
|
6
4
|
'(',
|
|
7
5
|
')',
|
|
6
|
+
':',
|
|
8
7
|
'<',
|
|
9
8
|
'>',
|
|
10
9
|
'@',
|
|
10
|
+
'|',
|
|
11
11
|
])
|
|
12
12
|
|
|
13
|
-
const REGEX_SPECIAL_CHARS = new Set(['
|
|
13
|
+
const REGEX_SPECIAL_CHARS = new Set(['(', ')', '|'])
|
|
14
14
|
|
|
15
15
|
export function prepareTsQuery(query: string): string | null {
|
|
16
16
|
// Remove leading/trailing whitespaces
|
package/src/utils/sort-by.ts
CHANGED
|
@@ -2,7 +2,7 @@ type Iteratee<T> = ((item: T) => unknown) | keyof T
|
|
|
2
2
|
type SortOrder = 'asc' | 'desc'
|
|
3
3
|
|
|
4
4
|
export function sortBy<T>(
|
|
5
|
-
collection:
|
|
5
|
+
collection: Record<string, T> | T[] | null | undefined,
|
|
6
6
|
iteratees?: Iteratee<T> | Iteratee<T>[] | string,
|
|
7
7
|
order?: SortOrder | SortOrder[],
|
|
8
8
|
): T[] {
|
package/src/utils/sum.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export function sum(arr: number[]): number
|
|
2
2
|
export function sum<T>(
|
|
3
3
|
arr: T[],
|
|
4
|
-
keyOrFunc:
|
|
4
|
+
keyOrFunc: ((item: T) => number) | keyof T,
|
|
5
5
|
): number
|
|
6
6
|
export function sum<T>(
|
|
7
7
|
arr: T[],
|
|
8
|
-
keyOrFunc?:
|
|
8
|
+
keyOrFunc?: ((item: T) => number) | keyof T,
|
|
9
9
|
): number {
|
|
10
10
|
if (arr.length === 0) {
|
|
11
11
|
return 0
|
package/src/utils/to-lang.ts
CHANGED
|
@@ -4,22 +4,22 @@ import type { ExtendedLocale } from '../constants/locales.ts'
|
|
|
4
4
|
|
|
5
5
|
export function toLang(localeOrLang: ExtendedLocale): Lang {
|
|
6
6
|
switch (localeOrLang) {
|
|
7
|
-
case Lang.EN:
|
|
8
|
-
case Locale.en_US: {
|
|
9
|
-
return Lang.EN
|
|
10
|
-
}
|
|
11
|
-
case Lang.FR:
|
|
12
|
-
case Locale.fr_FR: {
|
|
13
|
-
return Lang.FR
|
|
14
|
-
}
|
|
15
7
|
case Lang.DE:
|
|
16
8
|
case Locale.de_DE: {
|
|
17
9
|
return Lang.DE
|
|
18
10
|
}
|
|
11
|
+
case Lang.EN:
|
|
12
|
+
case Locale.en_US: {
|
|
13
|
+
return Lang.EN
|
|
14
|
+
}
|
|
19
15
|
case Lang.ES:
|
|
20
16
|
case Locale.es_ES: {
|
|
21
17
|
return Lang.ES
|
|
22
18
|
}
|
|
19
|
+
case Lang.FR:
|
|
20
|
+
case Locale.fr_FR: {
|
|
21
|
+
return Lang.FR
|
|
22
|
+
}
|
|
23
23
|
case Lang.IT:
|
|
24
24
|
case Locale.it_IT: {
|
|
25
25
|
return Lang.IT
|
package/src/utils/to-locale.ts
CHANGED
|
@@ -4,22 +4,22 @@ import type { ExtendedLocale } from '../constants/locales.ts'
|
|
|
4
4
|
|
|
5
5
|
export function toLocale(localeOrLang: ExtendedLocale): Locale {
|
|
6
6
|
switch (localeOrLang) {
|
|
7
|
-
case Lang.EN:
|
|
8
|
-
case Locale.en_US: {
|
|
9
|
-
return Locale.en_US
|
|
10
|
-
}
|
|
11
|
-
case Lang.FR:
|
|
12
|
-
case Locale.fr_FR: {
|
|
13
|
-
return Locale.fr_FR
|
|
14
|
-
}
|
|
15
7
|
case Lang.DE:
|
|
16
8
|
case Locale.de_DE: {
|
|
17
9
|
return Locale.de_DE
|
|
18
10
|
}
|
|
11
|
+
case Lang.EN:
|
|
12
|
+
case Locale.en_US: {
|
|
13
|
+
return Locale.en_US
|
|
14
|
+
}
|
|
19
15
|
case Lang.ES:
|
|
20
16
|
case Locale.es_ES: {
|
|
21
17
|
return Locale.es_ES
|
|
22
18
|
}
|
|
19
|
+
case Lang.FR:
|
|
20
|
+
case Locale.fr_FR: {
|
|
21
|
+
return Locale.fr_FR
|
|
22
|
+
}
|
|
23
23
|
case Lang.IT:
|
|
24
24
|
case Locale.it_IT: {
|
|
25
25
|
return Locale.it_IT
|
package/src/utils/uniq-by.ts
CHANGED
package/src/utils/uniq.ts
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export function uniq<T>(
|
|
8
8
|
array: readonly T[],
|
|
9
|
-
toKey?: (item: T) =>
|
|
9
|
+
toKey?: (item: T) => number | string | symbol,
|
|
10
10
|
): T[] {
|
|
11
|
-
const valueMap = array.reduce<Record<
|
|
11
|
+
const valueMap = array.reduce<Record<number | string | symbol, T>>(
|
|
12
12
|
(acc, item) => {
|
|
13
|
-
const key = toKey ? toKey(item) : (item as
|
|
13
|
+
const key = toKey ? toKey(item) : (item as number | string | symbol)
|
|
14
14
|
if (acc[key]) {
|
|
15
15
|
return acc
|
|
16
16
|
}
|