block-comment.js
Create a multi-line block comment from a string or an array
var comment = console;
yields:
/*! * Hello * World*/
Installation
Package managers
npm
npm install block-comment
Bower
bower install block-comment
Duo
const blockComment = ;
Standalone
Download the script file directly.
API
blockComment(content [, option])
content: String
or Array
of String
option: Object
Return: String
It returns a string of ECMAScript multi-line comment.
When content is a string, the result reflects the newlines of content.
; //=> '/*\n * foo\n * bar\n * baz\n*/'
You can also specify content with an array.
; //=> '/*\n * foo\n * bar\n*/'
option.start
Type: String
Default: ''
Adds a string immediately after /*
.
For example, if you use some JavaScript compression tools such as grunt-contrib-uglify and gulp-uglify, you can preserve the comment by adding !
;
; //=> '/*!\n * foo\n*/'
Properties
This function has three properties used as components of the comment template.
blockComment.open
Type: String
Default: '/*'
blockComment.linePrefix
Type: String
Default: ' *'
blockComment.close
Type: String
Default: '*/'
You can overwrite these properties if you want to modify the comment template. However, you don't have to care about them in most cases.
blockCommentopen = '/**********';blockCommentclose = '**********/'; ; //=> '/**********\n * foo\n**********/'
CLI
You can use this module as a CLI tool by installing it globally.
Usage
Usage1: block-comment <string>
Usage2: cat <file> | block-comment <string>
Options:
--start, -s <string> Add something (e.g. `!`) to the first line
--help, -h Print usage information
--version, -v Print version
License
Copyright (c) 2014 - 2015 Shinnosuke Watanabe
Licensed under the MIT License.