UNPKG
comments-remover
Version:
latest (0.0.1-a)
0.0.1
0.0.1-ignore
0.0.1-a
Removing coding leangues comments
comments-remover
/
functions
/
js.js
11 lines
(6 loc)
•
263 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
const
fs =
require
(
'fs'
);
async
function
removeComment
(
code
) {
if
(!code)
throw
new
Error
(
"Please give a javascript code to remove the comments!"
);
return
code.
replace
(
/\/\*[\s\S]*?\*\/|\/\/.*/g
,
''
).
trim
(); }
module
.
exports
= removeComment;