Nodejs String Dasherize toDash()

Here you can find the source of toDash()

Method Source Code

String.prototype.toDash = function(){
   return this.replace(/([A-Z])/g, function($1){return "-"+$1.toLowerCase();});
};

Related

  1. dasherize()
    String.prototype.dasherize = function() {
      return this.replace(/_/g, "-");
    };
    
  2. dasherize()
    String.prototype.dasherize = function() {
      return this.gsub(/_/,'-');
    };
    
  3. dasherize()
    String.prototype.dasherize = function() {
      return this.replace(/_/g, '-');
    };
    
  4. dasherize()
    String.prototype.dasherize = function() {
      return this.replace(/_/g, "-");
    };
    
  5. dasherize()
    String.prototype.dasherize = function() {
      return this.replace(/_/g, '-');
    };
    
  6. toDash()
    String.prototype.toDash = function () {
      var str = this.replace(/([A-Z])/g, function ($1) { return "-" + $1.toLowerCase(); });
      return (str[0] == '-' ? str.substring(1) : str);
    };
    
  7. toDashCase()
    String.prototype.toDashCase = function() {
      return this
              .replace(/^[A-Z]/, ($1) => {
                return $1.toLowerCase();
              })
              .replace(/([A-Z])/g, ($1) => {
                return '-'+$1.toLowerCase();
              });
    };
    ...
    
  8. toDashedCase()
    String.prototype.toDashedCase = function() {
      return this.replace(/([A-Z])/g, function($1){return '-'+$1.toLowerCase();});
    };