diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/align-text/index.js | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/align-text/index.js')
-rw-r--r-- | node_modules/align-text/index.js | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/node_modules/align-text/index.js b/node_modules/align-text/index.js deleted file mode 100644 index 75902a3f3..000000000 --- a/node_modules/align-text/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/*! - * align-text <https://github.com/jonschlinkert/align-text> - * - * Copyright (c) 2015, Jon Schlinkert. - * Licensed under the MIT License. - */ - -'use strict'; - -var typeOf = require('kind-of'); -var repeat = require('repeat-string'); -var longest = require('longest'); - -module.exports = function alignText(val, fn) { - var lines, type = typeOf(val); - - if (type === 'array') { - lines = val; - } else if (type === 'string') { - lines = val.split(/(?:\r\n|\n)/); - } else { - throw new TypeError('align-text expects a string or array.'); - } - - var fnType = typeOf(fn); - var len = lines.length; - var max = longest(lines); - var res = [], i = 0; - - while (len--) { - var line = String(lines[i++]); - var diff; - - if (fnType === 'function') { - diff = fn(line.length, max.length, line, lines, i); - } else if (fnType === 'number') { - diff = fn; - } else { - diff = max.length - line.length; - } - - if (typeOf(diff) === 'number') { - res.push(repeat(' ', diff) + line); - } else if (typeOf(diff) === 'object') { - var result = repeat(diff.character || ' ', diff.indent || 0); - res.push((diff.prefix || '') + result + line); - } - } - - if (type === 'array') return res; - return res.join('\n'); -}; |