Module: overrider

Methods

(static) mixIn(source) → {object}

Mix source members into this.

Parameters:
Name Type Description
source
Returns:

The target object (this)

Type
object
Examples
// A. Simple usage (using .call):
var mixIn = require('overrider').mixIn;
var target = { a: 1 }, source = { b: 2 };
target === overrider.mixIn.call(target, source) // true
// target object now has both a and b; source object untouched
// B. Semantic usage (when the target hosts the method):
var mixIn = require('overrider').mixIn;
var target = { a: 1, mixIn: mixIn }, source = { b: 2 };
target === target.mixIn(source) // true
// target now has both a and b (and mixIn); source untouched

(static) mixInTo(target) → {object}

Mix this members into target.

This:
  • {object}
Parameters:
Name Type Description
target
Returns:

The target object (target)

Type
object
Examples
// A. Simple usage (using .call):
var mixInTo = require('overrider').mixInTo;
var target = { a: 1 }, source = { b: 2 };
target === overrider.mixInTo.call(source, target); // true
// target object now has both a and b; source object untouched
// B. Semantic usage (when the source hosts the method):
var mixInTo = require('overrider').mixInTo;
var target = { a: 1 }, source = { b: 2, mixInTo: mixInTo };
target === source.mixInTo(target); // true
// target object now has both a and b; source object untouched

(inner) overrider(object, …sourcesopt) → {object}

Mixes members of all sources into target, handling getters and setters properly.

Any number of sources objects may be given and each is copied in turn.

Parameters:
Name Type Attributes Description
object object

The target object to receive sources.

sources object <optional>
<repeatable>

Object(s) containing members to copy to target. (Omitting is a no-op.)

Returns:

The target object (target)

Type
object
Example
var overrider = require('overrider');
var target = { a: 1 }, source1 = { b: 2 }, source2 = { c: 3 };
target === overrider(target, source1, source2); // true
// target object now has a, b, and c; source objects untouched