Açıklama Yok

index.js 485B

1234567891011121314151617181920
  1. 'use strict';
  2. var repeating = require('repeating');
  3. module.exports = function (str, indent, count) {
  4. if (typeof str !== 'string' || typeof indent !== 'string') {
  5. throw new TypeError('`string` and `indent` should be strings');
  6. }
  7. if (count != null && typeof count !== 'number') {
  8. throw new TypeError('`count` should be a number');
  9. }
  10. if (count === 0) {
  11. return str;
  12. }
  13. indent = count > 1 ? repeating(indent, count) : indent;
  14. return str.replace(/^(?!\s*$)/mg, indent);
  15. };