Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
784 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict';
|
---|
| 2 | const chalk = require('chalk');
|
---|
| 3 | const figures = require('figures');
|
---|
| 4 |
|
---|
| 5 | /**
|
---|
| 6 | * Separator object
|
---|
| 7 | * Used to space/separate choices group
|
---|
| 8 | * @constructor
|
---|
| 9 | * @param {String} line Separation line content (facultative)
|
---|
| 10 | */
|
---|
| 11 |
|
---|
| 12 | class Separator {
|
---|
| 13 | constructor(line) {
|
---|
| 14 | this.type = 'separator';
|
---|
| 15 | this.line = chalk.dim(line || new Array(15).join(figures.line));
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | /**
|
---|
| 19 | * Stringify separator
|
---|
| 20 | * @return {String} the separator display string
|
---|
| 21 | */
|
---|
| 22 | toString() {
|
---|
| 23 | return this.line;
|
---|
| 24 | }
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | /**
|
---|
| 28 | * Helper function returning false if object is a separator
|
---|
| 29 | * @param {Object} obj object to test against
|
---|
| 30 | * @return {Boolean} `false` if object is a separator
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 | Separator.exclude = function (obj) {
|
---|
| 34 | return obj.type !== 'separator';
|
---|
| 35 | };
|
---|
| 36 |
|
---|
| 37 | module.exports = Separator;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.