| /** | ||
| * Message - a message to be written. | ||
| * | ||
| * @param {Stream} target | ||
| * @param {String} prefix | ||
| * @constructor | ||
| */ | ||
| function Message(target, prefix) { | ||
| this.target = target; | ||
| this.prefix = prefix; | ||
| } | ||
| /** | ||
| * Print a line. | ||
| * | ||
| * @param {String} message | ||
| * @api public | ||
| */ | ||
| Message.prototype.println = | ||
| Message.prototype.print = function(msg) { | ||
| msg = msg || ''; | ||
| msg = this.prefix + msg; | ||
| this.write(msg + '\n'); | ||
| }; | ||
| /** | ||
| * Write the given `msg` to the stream. | ||
| * | ||
| * @param {String} message | ||
| * @api public | ||
| */ | ||
| Message.prototype.write = function(msg) { | ||
| msg = msg || ''; | ||
| this.target.write(msg); | ||
| }; | ||
| /** | ||
| * Primary export | ||
| */ | ||
| module.exports = Message; |
+1
-1
| { | ||
| "name": "printr", | ||
| "description": "Print utils", | ||
| "version": "0.0.0", | ||
| "version": "1.0.0", | ||
| "main": "lib/printr.js", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/vesln/printr", |
+34
-0
@@ -11,2 +11,36 @@ [![NPM | ||
| ```js | ||
| var Printr = require('printr'); | ||
| var printr new Printr({ | ||
| out: process.stdout, // out stream, default | ||
| err: process.stderr, // err stream, default | ||
| prefix: '-test-: ', // prefix, default: '' | ||
| }); | ||
| printr.error.print('Hello'); | ||
| printr.error.println('Hello'); | ||
| printr.error.write('H'); | ||
| printr.error.write('i'); | ||
| printr.out.print('Hi'); | ||
| printr.out.println('Hi'); | ||
| printr.out.write('H'); | ||
| printr.out.write('i'); | ||
| ``` | ||
| stderr: | ||
| ``` | ||
| -test-: Hello\n | ||
| -test-: Hello\n | ||
| Hi | ||
| ``` | ||
| stdout: | ||
| ``` | ||
| -test-: Hi\n | ||
| -test-: Hi\n | ||
| Hi | ||
| ``` | ||
| ## Tests | ||
@@ -13,0 +47,0 @@ |
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
3370
205.81%4
33.33%85
Infinity%0
-100%59
136%0
-100%