Skip to content

Commit d5afc4b

Browse files
committed
chore: 📸 default false to snakCaseKey on transform send
1 parent ae8e3b1 commit d5afc4b

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/core/BaseTransformer.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@ import snakeCaseKeys from 'snakecase-keys'
22
import camelcaseKeys from 'camelcase-keys'
33

44
class BaseTransformer {
5-
static fetchCollection(items: any[], camelCaseKey?: boolean): any[] {
6-
return items.map((item: any) => this.fetch(item, camelCaseKey))
5+
static fetchCollection(
6+
items: Array<Attribute>,
7+
camelCaseKey?: boolean,
8+
): Array<Attribute> {
9+
return items.map((item: Attribute) => this.fetch(item, camelCaseKey))
710
}
811

9-
static sendCollection(items: any[], snakeCaseKey?: boolean): any[] {
10-
return items.map((item: any) => this.send(item, snakeCaseKey))
12+
static sendCollection(
13+
items: Array<Attribute>,
14+
snakeCaseKey?: boolean,
15+
): Array<Attribute> {
16+
return items.map((item: Attribute) => this.send(item, snakeCaseKey))
1117
}
1218

13-
static fetch(item: any, camelCaseKey?: boolean): any {
19+
static fetch(item: Attribute, camelCaseKey?: boolean): Attribute {
1420
if (camelCaseKey) {
1521
return camelcaseKeys(item, { deep: true })
1622
}
1723
return item
1824
}
1925

20-
static send(item: any, snakeCaseKey = true): any {
26+
static send(item: Attribute, snakeCaseKey?: boolean): Attribute {
2127
if (snakeCaseKey) {
2228
return snakeCaseKeys(item)
2329
}
@@ -26,3 +32,7 @@ class BaseTransformer {
2632
}
2733

2834
export default BaseTransformer
35+
36+
export type Attribute = {
37+
[key in string | number]: any
38+
}

0 commit comments

Comments
 (0)