Files
30-seconds-of-code/node_modules/@comandeer/babel-plugin-banner/utils.js
2019-08-20 15:52:05 +02:00

21 lines
440 B
JavaScript

'use strict';
const oneLineRegex = /^\/\/(.*?)\n?$/;
const multiLineRegex = /^\/\*([\s\S]*?)\*\/$/;
exports.isComment = function( input ) {
if ( oneLineRegex.test( input ) || multiLineRegex.test( input ) ) {
return true;
}
return false;
};
exports.getCommentContent = function( input ) {
if ( oneLineRegex.test( input ) ) {
return input.replace( /^\/\//, '' );
}
return input.replace( /^\/\*/, '' ).replace( /\*\/$/, '' );
}