Initial commit
This commit is contained in:
20
node_modules/delegates/License
generated
vendored
Normal file
20
node_modules/delegates/License
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2015 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
121
node_modules/delegates/index.js
generated
vendored
Normal file
121
node_modules/delegates/index.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
|
||||
/**
|
||||
* Expose `Delegator`.
|
||||
*/
|
||||
|
||||
module.exports = Delegator;
|
||||
|
||||
/**
|
||||
* Initialize a delegator.
|
||||
*
|
||||
* @param {Object} proto
|
||||
* @param {String} target
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Delegator(proto, target) {
|
||||
if (!(this instanceof Delegator)) return new Delegator(proto, target);
|
||||
this.proto = proto;
|
||||
this.target = target;
|
||||
this.methods = [];
|
||||
this.getters = [];
|
||||
this.setters = [];
|
||||
this.fluents = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegate method `name`.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Delegator} self
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Delegator.prototype.method = function(name){
|
||||
var proto = this.proto;
|
||||
var target = this.target;
|
||||
this.methods.push(name);
|
||||
|
||||
proto[name] = function(){
|
||||
return this[target][name].apply(this[target], arguments);
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Delegator accessor `name`.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Delegator} self
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Delegator.prototype.access = function(name){
|
||||
return this.getter(name).setter(name);
|
||||
};
|
||||
|
||||
/**
|
||||
* Delegator getter `name`.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Delegator} self
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Delegator.prototype.getter = function(name){
|
||||
var proto = this.proto;
|
||||
var target = this.target;
|
||||
this.getters.push(name);
|
||||
|
||||
proto.__defineGetter__(name, function(){
|
||||
return this[target][name];
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Delegator setter `name`.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Delegator} self
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Delegator.prototype.setter = function(name){
|
||||
var proto = this.proto;
|
||||
var target = this.target;
|
||||
this.setters.push(name);
|
||||
|
||||
proto.__defineSetter__(name, function(val){
|
||||
return this[target][name] = val;
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Delegator fluent accessor
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Delegator} self
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Delegator.prototype.fluent = function (name) {
|
||||
var proto = this.proto;
|
||||
var target = this.target;
|
||||
this.fluents.push(name);
|
||||
|
||||
proto[name] = function(val){
|
||||
if ('undefined' != typeof val) {
|
||||
this[target][name] = val;
|
||||
return this;
|
||||
} else {
|
||||
return this[target][name];
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
12
node_modules/delegates/package.json
generated
vendored
Normal file
12
node_modules/delegates/package.json
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "delegates",
|
||||
"version": "1.0.0",
|
||||
"repository": "visionmedia/node-delegates",
|
||||
"description": "delegate methods and accessors to another property",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
Reference in New Issue
Block a user