UNPKG

784 BJavaScriptView Raw
1'use strict';
2const chalk = require('chalk');
3const 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
12class 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
33Separator.exclude = function (obj) {
34 return obj.type !== 'separator';
35};
36
37module.exports = Separator;