block-comment

Generate a multiline block comment from a string


Keywords
string, comment, block, multline
License
MIT
Install
npm install block-comment@1.0.2

Documentation

block-comment

npm version Build Status Coverage Status

Generate a multiline block comment from a string

const comment = blockComment('Hello\nworld.', {start: '!'})
console.log(comment);

yields:

/*!
 * Hello
 * World
*/

Installation

Use npm.

npm install block-comment

API

import blockComment from 'block-comment';

blockComment(content [, option])

content: 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.

blockComment('foo\nbar\r\nbaz'); //=> '/*\n * foo\n * bar\n * baz\n*/'

option.start

Type: string
Default: ''

Add a given string immediately after /*.

// terser preserves comments with @preserve directive
// https://github.com/terser-js/terser#keeping-copyright-notices-or-other-comments
blockComment('foo', {start: '!'}); //=> '/* @preserve\n * foo\n*/'

License

Copyright (c) 2014 - 2018 Shinnosuke Watanabe

Licensed under the MIT License.