forked from prisma/web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringify.ts
More file actions
41 lines (35 loc) 路 769 Bytes
/
Copy pathstringify.ts
File metadata and controls
41 lines (35 loc) 路 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
export function stringify(children: any): string {
if (typeof children === 'string') {
return children
}
if (typeof children === 'undefined') {
return ''
}
if (children === null) {
return ''
}
if (children.props && children.props.children) {
children = children.props.children
}
if (children.props && children.props.children) {
children = children.props.children
}
/**
* Necessary because now the pointer changed!!!!
*/
if (typeof children === 'string') {
return children
}
if (Array.isArray(children)) {
return children
.map((el) => {
if (typeof el === 'string') {
return el
} else {
return stringify(el)
}
})
.join('')
}
return ''
}