FlavorJS

FlavorJS

FlavorJS the definitive JS natives chainable extensions methods

Constructor

new FlavorJS()

Source:
constructs FlavorJS class & extends the js natives

Methods

delay(fn, ms) → {function}

Source:
delays a function by specified ms
Example

eg. usage

ƒ.delay(function() {
  console.log('ended')
}, 1000);

// it logs 'ended' after 1000ms
Parameters:
Name Type Description
fn function function to invoke
ms number time to wait in milliseconds
Returns:
Type
function

extendArray()

Source:
extendArray

extendBoolean()

Source:
extendBoolean

extendDate()

Source:
extendDate

extendFunction()

Source:
extendFunction

extendLodash()

Source:
extendLodash

extendNumber()

Source:
extendNumber

extendObject()

Source:
extendObject

extendPrototype(proto, extend)

Source:
merges all keys in extend plain object to the prototype (
Parameters:
Name Type Description
proto prototype | object the prototype/object to extend
extend object the extend object to be merged in prototype

extendPrototypeProperty(proto, prop, val, optionsopt)

Source:
safe js native prototype extension using Object.defineProperty
Parameters:
Name Type Attributes Default Description
proto prototype | object the prototype/object to extend
prop string the name of the property to be defined or modified
val * val to be used as value in the descriptor for the property, can be any kind of native (number, function, etc...) or what you want
options object <optional>
{} options to be used as parameters in the descriptor for the property
possible options are (source documentation from Javascript|MDN docs)
Properties
Name Type Attributes Default Description
configurable boolean <optional>
true configurable - true if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding Object.
enumerable boolean <optional>
false enumerable - true if and only if this property shows up during enumeration of the properties on the corresponding Object.
writable boolean <optional>
true writable - true if and only if the value associated with the property may be changed with an assignment operator.
get function <optional>
get - A function which serves as a getter for the property, or undefined if there is no getter. The function return will be used as the value of property.
for example...
function ClassName() {
  var privateProp = null;

  Object.defineProperty(this, 'publicProp', {
    get: function() {
      return privateProp;
    }
  });
}
set function <optional>
set - A function which serves as a setter for the property, or undefined if there is no setter. The function will receive as only argument the new value being assigned to the property.
for example...
function ClassName() {
  var privateProp = null;

  Object.defineProperty(this, 'publicProp', {
    set: function(value) {
      privateProp = value;
    }
  });
}

extendString()

Source:
extendString

init()

Source:
initialize all