index.js 220 B

12345678
  1. 'use strict';
  2. module.exports = function (str, sep) {
  3. if (typeof str !== 'string') {
  4. throw new TypeError('Expected a string');
  5. }
  6. return str.replace(/([a-z\d])([A-Z])/g, '$1' + (sep || '_') + '$2').toLowerCase();
  7. };