comment-clear
install
npm i comment-clear
example
import CommentClear1 from './';
class CommentClear extends CommentClear1 {
/**
* if you wanna to keep prefix or suffix symbol you can replace by your self;
* default to keep \n
* @param str prefix or suffix
* @returns replacement
*/
// n(str: string){
// return '';
// }
}
const clear = new CommentClear();
clear.setPerfix(/\/\//);
clear.setSuffix(/\n/);
const srt = `
{
///name
///ages
/*/* age */ /* [1,3,4].map(item => n + ' ' + item).join(n) */
"name": "99"
}
`;
console.log(srt)
const ret = clear.parse(
srt
)
console.log(ret)
clear.setPerfix(/\/\*/);
clear.setSuffix(/\*\//);
const ret1 = clear.template(ret, { name: 999, age: 77, n: '\n' })
console.log(ret1)