@revolugo/common 6.13.0-beta.1 → 6.13.0-beta.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revolugo/common",
3
- "version": "6.13.0-beta.1",
3
+ "version": "6.13.0-beta.11",
4
4
  "private": false,
5
5
  "description": "Revolugo common",
6
6
  "author": "Revolugo",
@@ -93,6 +93,7 @@ export const ICONS_NAME = Object.freeze({
93
93
  idBadge: 'ph:identification-badge',
94
94
  image: 'ph:image',
95
95
  images: 'ph:images',
96
+ imagesSquare: 'ph:images-square',
96
97
  info: 'ph:info',
97
98
  key: 'ph:key',
98
99
  leaf: 'ph:leaf',
@@ -1,4 +1,5 @@
1
1
  import type { Bed } from './bed.ts'
2
+ import type { HotelImage } from './hotel-image.ts'
2
3
 
3
4
  export interface HotelRoom {
4
5
  /**
@@ -63,6 +64,12 @@ export interface HotelRoom {
63
64
  * @memberof HotelRoom
64
65
  */
65
66
  imageIndexes?: number[] | null
67
+ /**
68
+ * List of images for the given Hotel Room.
69
+ * @type {Array<string>}
70
+ * @memberof HotelRoom
71
+ */
72
+ images?: HotelImage[] | null
66
73
  /**
67
74
  * Whether low resolution images are available.
68
75
  * @type {boolean}
@@ -27,6 +27,8 @@ export * from './is-equal.ts'
27
27
  export * from './is-nil.ts'
28
28
  export * from './key-by.ts'
29
29
  export * from './lang-default-fallbacks.ts'
30
+ export * from './map-keys.ts'
31
+ export * from './map-values.ts'
30
32
  export * from './merge.ts'
31
33
  export * from './omit-by.ts'
32
34
  export * from './omit.ts'
@@ -43,6 +45,7 @@ export * from './sort-by.ts'
43
45
  export * from './sum-by.ts'
44
46
  export * from './sum.ts'
45
47
  export * from './to-boolean.ts'
48
+ export * from './uniq.ts'
46
49
  export * from './uniq-by.ts'
47
50
  export * from './uniq-with.ts'
48
51
  export * from './validators.ts'
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Map over all the keys of an object to return
3
+ * a new object
4
+ */
5
+ export const mapKeys = <
6
+ TValue,
7
+ TKey extends string | number | symbol,
8
+ TNewKey extends string | number | symbol,
9
+ >(
10
+ obj: Record<TKey, TValue>,
11
+ mapFunc: (key: TKey, value: TValue) => TNewKey,
12
+ ): Record<TNewKey, TValue> => {
13
+ const keys = Object.keys(obj) as TKey[]
14
+ return keys.reduce(
15
+ (acc, key) => {
16
+ acc[mapFunc(key as TKey, obj[key])] = obj[key]
17
+ return acc
18
+ },
19
+ {} as Record<TNewKey, TValue>,
20
+ )
21
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Map over all the keys to create a new object
3
+ */
4
+ export const mapValues = <
5
+ TValue,
6
+ TKey extends string | number | symbol,
7
+ TNewValue,
8
+ >(
9
+ obj: Record<TKey, TValue>,
10
+ mapFunc: (value: TValue, key: TKey) => TNewValue,
11
+ ): Record<TKey, TNewValue> => {
12
+ const keys = Object.keys(obj) as TKey[]
13
+ return keys.reduce(
14
+ (acc, key) => {
15
+ acc[key] = mapFunc(obj[key], key)
16
+ return acc
17
+ },
18
+ {} as Record<TKey, TNewValue>,
19
+ )
20
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Given a list of items returns a new list with only
3
+ * unique items. Accepts an optional identity function
4
+ * to convert each item in the list to a comparable identity
5
+ * value
6
+ */
7
+ export function uniq<T>(
8
+ array: readonly T[],
9
+ toKey?: (item: T) => string | number | symbol,
10
+ ): T[] {
11
+ const valueMap = array.reduce<Record<string | number | symbol, T>>(
12
+ (acc, item) => {
13
+ const key = toKey ? toKey(item) : (item as string | number | symbol)
14
+ if (acc[key]) {
15
+ return acc
16
+ }
17
+ acc[key] = item
18
+ return acc
19
+ },
20
+ {},
21
+ )
22
+ return Object.values(valueMap)
23
+ }