block-comment
Create a multi-line block comment from a string or an array
Last updated 6 years ago by shinnn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install block-comment 
SYNC missed versions from official npm registry.

block-comment.js

NPM version Bower version Build Status Build status Coverage Status Dependency Status devDependency Status

Create a multi-line block comment from a string or an array

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

yields:

/*!
 * Hello
 * World
*/

Installation

Package managers

npm

npm install block-comment

Bower

bower install block-comment

Duo

const blockComment = require('shinnn/block-comment.js');

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.

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

You can also specify content with an array.

blockComment(['foo', 'bar']); //=> '/*\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 !;

blockComment('foo', {start: '!'}); //=> '/*!\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.

blockComment.open = '/**********';
blockComment.close = '**********/';

blockComment('foo'); //=> '/**********\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.

Current Tags

  • 1.0.3                                ...           latest (5 years ago)
  • 2.0.0-3                                ...           next (2 years ago)

9 Versions

  • 2.0.0-3                                ...           2 years ago
  • 2.0.0-2                                ...           2 years ago
  • 2.0.0-1                                ...           2 years ago
  • 2.0.0-0                                ...           2 years ago
  • 1.0.3                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           6 years ago
  • 0.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |