How to use the ext.extend function in ext

To help you get started, we’ve selected a few ext examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NV / jsonpwrapper.com / vendor / support / ext / lib / ext / core_ext / regexp.js View on Github external
// ext.js - RegExp - Copyright TJ Holowaychuk  (MIT Licensed)

require('ext').extend(RegExp, {

  /**
   * Escape RegExp _chars_ in _string_. Where _chars_
   * defaults to regular expression special characters.
   *
   * _chars_ should be a space delimited list of characters,
   * for example '[ ] ( )'.
   *
   * @param  {string} str
   * @param  {string} chars
   * @return {Type}
   * @api public
   */

  escape: function(str, chars) {
    var specials = (chars || '/ . * + ? | ( ) [ ] { } \\ ^ ? ! = : $').split(' ').join('|\\')
github brianleroux / wtfjs / lib / codeblog / lib / express / lib / support / ext / lib / ext / core_ext / regexp.js View on Github external
// ext.js - RegExp - Copyright TJ Holowaychuk  (MIT Licensed)

require('ext').extend(RegExp, {

  /**
   * Escape RegExp _chars_ in _string_. Where _chars_
   * defaults to regular expression special characters.
   *
   * _chars_ should be a space delimited list of characters,
   * for example '[ ] ( )'.
   *
   * @param  {string} str
   * @param  {string} chars
   * @return {Type}
   * @api public
   */

  escape: function(str, chars) {
    var specials = (chars || '/ . * + ? | ( ) [ ] { } \\ ^ ? ! = : $').split(' ').join('|\\')
github NV / jsonpwrapper.com / vendor / support / ext / lib / ext / core_ext / error.js View on Github external
// ext.js - Error - Copyright TJ Holowaychuk  (MIT Licensed)

require('ext').extend(Error, {

  /**
   * Shorthand for assigning a _name_ and offending _object_ as #object to an
   * Error object. Throws the error immediately after the function finished
   * executing.
   *
   * If no offending object is given, the function calling Error.raise() is
   * attached using arguments.callee.caller.
   *
   * All arguments are optional.
   *
   * @param {string} name
   * @param {string} message
   * @param {mixed} object
   * @throws
   */
github brianleroux / wtfjs / lib / codeblog / lib / express / lib / support / ext / lib / ext / core_ext / object / extensions.js View on Github external
// ext.js - Object - Copyright TJ Holowaychuk  (MIT Licensed)

require('ext').extend(Object, {

  /**
   * Merges all values from object _b_ to _a_.
   *
   * @param  {object} a
   * @param  {object} b
   * @return {object}
   * @api public
   */

  merge: function (a, b) {
    if (!b) return a
    var keys = Object.keys(b)
    for (var i = 0, len = keys.length; i < len; ++i)
      a[keys[i]] = b[keys[i]]
    return a
github brianleroux / wtfjs / lib / codeblog / lib / express / lib / support / ext / lib / ext / md5.js View on Github external
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
        b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
        a=AddUnsigned(a,AA);
        b=AddUnsigned(b,BB);
        c=AddUnsigned(c,CC);
        d=AddUnsigned(d,DD);
    }

    var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);

    return temp.toLowerCase();
}

// --- Extensions

require('ext').extend(String.prototype, {

  /**
   * @see hash()
   */

  get md5() { return exports.hash(this) }
})
github brianleroux / wtfjs / lib / codeblog / lib / express / lib / support / ext / lib / ext / base64.js View on Github external
var i2 = chars.indexOf(str.charAt(c++));
      var i3 = chars.indexOf(str.charAt(c++));
      var buf = (i0 << 18) + (i1 << 12) + ((i2 & 63) << 6) + (i3 & 63);
      var b0 = (buf & (255 << 16)) >> 16;
      var b1 = (i2 == 64) ? -1 : (buf & (255 << 8)) >> 8;
      var b2 = (i3 == 64) ? -1 : (buf & 255);
      decoded[decoded.length] = String.fromCharCode(b0);
      if (b1 >= 0) decoded[decoded.length] = String.fromCharCode(b1);
      if (b2 >= 0) decoded[decoded.length] = String.fromCharCode(b2);
  }
  return decoded.join('');
}

// --- Extensions

require('ext').extend(String.prototype, {

  /**
   * @see encode()
   */

   get base64Encoded() { return exports.encode(this) },

   /**
    * @see decode()
    */

  get base64Decoded() { return exports.decode(this) }

})
github brianleroux / wtfjs / lib / codeblog / lib / express / lib / support / ext / lib / ext / core_ext / string / inflections.js View on Github external
// ext.js - String - Inflections - Copyright TJ Holowaychuk  (MIT Licensed)

require('ext').extend(String.prototype, {

  /**
   * Capitalize the given _str_, optionally _all_ words.
   *
   *   'hello there'.capitalize()
   *    // => 'Hello there'
   *
   *   'hello there'.capitalize('all') // or true
   *    // => 'Hello There'
   *
   * @param  {bool} all
   * @return {string}
   * @api public
   */

  capitalize: function (all) {
github brianleroux / wtfjs / lib / codeblog / lib / express / lib / support / ext / lib / ext / core_ext / array / enumerable.js View on Github external
// ext.js - Array - Iterators - Copyright TJ Holowaychuk  (MIT Licensed)

require('ext').extend(Array.prototype, {

  /**
   * Alias of #forEach()
   */

  each: [].forEach,
  
  /**
   * Alias of #some()
   */
  
  any: [].some,
  
  /**
   * Alias of #every()
   */
github brianleroux / wtfjs / lib / codeblog / lib / express / lib / support / ext / lib / ext / core_ext / number.js View on Github external
// ext.js - Number - Copyright TJ Holowaychuk  (MIT Licensed)

require('ext').extend(Number.prototype, {

  /**
   * Convert a the given number _n_ to an ordinal string used to denote the
   * position in an ordered sequence such as 1st, 2nd, 3rd, 4th, etc.
   *
   * @return {string}
   * @api public
   */

  get ordinalize() {
    if ([11, 12, 13].indexOf(this % 100) !== -1)
      return this + 'th'
    else
      switch (this % 10) {
        case 1:  return this + 'st'
        case 2:  return this + 'nd'
github brianleroux / wtfjs / lib / codeblog / lib / express / lib / support / ext / lib / ext / core_ext / date / extensions.js View on Github external
/**
 * Day names.
 */

var days = [
  'Sunday',
  'Monday',
  'Tuesday',
  'Wednesday',
  'Thursday',
  'Friday',
  'Saturday']

// --- Extensions

require('ext').extend(Date.prototype, {

  /**
   * Shortcuts for getMETHOD
   */

  get milliseconds() { return this.getMilliseconds() },
  get seconds() { return this.getSeconds() },
  get minutes() { return this.getMinutes() },
  get hours() { return this.getHours() },
  get date() { return this.getDate() },
  get day() { return this.getDay() },
  get month() { return this.getMonth() },
  get year() { return this.getFullYear() },

  /**
   * Return month name string.