Front end of the Slack clone application.

index.js 485B

123456789101112131415161718192021
  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. };