You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 481B

1234567891011121314151617
  1. 'use strict';
  2. var indentString = require('indent-string');
  3. var longest = require('longest');
  4. module.exports = function (str, arr, indent) {
  5. var pad = typeof indent === 'number' ? indent : 0;
  6. if (typeof str !== 'string') {
  7. throw new TypeError('Expected a `string`, got `' + typeof str + '`');
  8. }
  9. if (!Array.isArray(arr)) {
  10. throw new TypeError('Expected an `Array`, got `' + typeof arr + '`');
  11. }
  12. return indentString(str, ' ', pad + longest(arr).length - str.length);
  13. };