indent.js 420 B

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