chop.js 192 B

123456
  1. module.exports = function chop(str, step) {
  2. if (str == null) return [];
  3. str = String(str);
  4. step = ~~step;
  5. return step > 0 ? str.match(new RegExp('.{1,' + step + '}', 'g')) : [str];
  6. };