FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
openapi-typescript-codegen/src/utils/formatCode.ts at main · thulium/openapi-typescript-codegen · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
thulium
/
openapi-typescript-codegen
Public
forked from
ferdikoomen/openapi-typescript-codegen
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
21
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
openapi-typescript-codegen
/
src
/
utils
/
formatCode.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
23 lines (22 loc) · 676 Bytes
Breadcrumbs
openapi-typescript-codegen
/
src
/
utils
/
formatCode.ts
Copy path
File metadata and controls
23 lines (22 loc) · 676 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import
{
EOL
}
from
'os'
;
export
const
formatCode
=
(
s
:
string
)
:
string
=>
{
let
indent
:
number
=
0
;
let
lines
=
s
.
split
(
EOL
)
;
lines
=
lines
.
map
(
line
=>
{
line
=
line
.
trim
(
)
.
replace
(
/
^
\*
/
g
,
' *'
)
;
let
i
=
indent
;
if
(
line
.
endsWith
(
'('
)
||
line
.
endsWith
(
'{'
)
||
line
.
endsWith
(
'['
)
)
{
indent
++
;
}
if
(
(
line
.
startsWith
(
')'
)
||
line
.
startsWith
(
'}'
)
||
line
.
startsWith
(
']'
)
)
&&
i
)
{
indent
--
;
i
--
;
}
const
result
=
`
${
' '
.
repeat
(
i
)
}
${
line
}
`
;
if
(
result
.
trim
(
)
===
''
)
{
return
''
;
}
return
result
;
}
)
;
return
lines
.
join
(
EOL
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL