Nodejs String to Pascal Case Convert toPascalCase()

Here you can find the source of toPascalCase()

Method Source Code

// Copyright 2015 Alec Thilenius
// All rights reserved.

/*/*  w ww  .ja  v a  2s . co m*/
 * Various helpers for Javascript strings
 */

var isEmpty = function(str) {
  return str && str.length > 0;
};

var isBlank = function(str) {
  return !str || /^\s*$/.test(str);
};

String.prototype.toPascalCase = function() {
  return this.replace(/\w\S*/g, function(txt) {
    return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
  });
};

String.prototype.capitalizeFirstLetter = function() {
  return this.charAt(0).toUpperCase() + this.slice(1);
};

var newGuid = newUuid = function() {
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
    var r = Math.random() * 16 | 0;
    var v = c == 'x' ? r : (r & 0x3 | 0x8);
    return v.toString(16);
  });
};

var ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var ID_LENGTH = 16;

var newShortGuid = newShortUuid = function() {
  var rtn = '';
  for (var i = 0; i < ID_LENGTH; i++) {
    rtn += ALPHABET.charAt(Math.floor(Math.random() * ALPHABET.length));
  }
  return rtn;
};

Related

  1. toPascalCase()
    String.prototype.toPascalCase = function() {
        return this.charAt(0).toLowerCase() + this.slice(1);
    };
    
  2. toPascalCase()
    function checkVariable(value)
      return ( (value != undefined) && (value != null) );
    String.prototype.toPascalCase = function()
      return this.replace(/\w+/g, function(w){return w[0].toUpperCase() + w.slice(1).toLowerCase();});
    function thousandsSeparator(value)
    ...