4
1

indent.js 368 B

123456789101112
  1. 'use strict';
  2. var repeat = require('./repeat')
  3. , replace = String.prototype.replace
  4. , re = /(\r\n|[\n\r\u2028\u2029])([\u0000-\u0009\u000b-\uffff]+)/g;
  5. module.exports = function (indent/*, count*/) {
  6. var count = arguments[1];
  7. indent = repeat.call(String(indent), (count == null) ? 1 : count);
  8. return indent + replace.call(this, re, '$1' + indent + '$2');
  9. };