-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (41 loc) · 1012 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Console.Star mimics the behaviour of console.log, but also wraps the log in stars
*
* Usage:
* console.star('Hello %s', 'World');
*
* Result:
* ***************
* ***************
* Hello World
* ***************
* ***************
*
* @type {{starString: string, lines: number, logType: string}}
*/
/**
* Default Options, can be overridden at any time
* @type {{starString: string, lines: number, logType: string}}
*/
console.starOptions = {
'starString': '***************',
'lines': 2,
'logType': 'log'
};
/**
* The console[log] wrapper, which pre/post-pends stars
*/
console.star = function() {
var options = this.starOptions,
log = this[options.logType],
lines = options.lines,
starString = options.starString;
// Pre-log Stars
while(lines--){log.call(this, starString);}
// Apply the original console[log]
log.apply(this, arguments);
// Reset the count, post-log stars
lines = options.lines;
while(lines--){log.call(this, starString);}
};
exports = console.star;