Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rails-delegate

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rails-delegate - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

37

lib/rails-delegate.js
// Generated by LiveScript 1.4.0
(function(){
var flatten, delegate, slice$ = [].slice;
var flatten, debug, delegate, delegateMethod, delegateProperty, slice$ = [].slice;
flatten = require('lodash.flatten');
debug = require('debug')('rails-delegate');
delegate = function(){
var i$, methodNames, ref$, from, to, len$, methodName, ref1$, results$ = [];
methodNames = 0 < (i$ = arguments.length - 1) ? slice$.call(arguments, 0, i$) : (i$ = 0, []), ref$ = arguments[i$], from = ref$.from, to = ref$.to;
var i$, names, ref$, from, to, len$, name, results$ = [];
names = 0 < (i$ = arguments.length - 1) ? slice$.call(arguments, 0, i$) : (i$ = 0, []), ref$ = arguments[i$], from = ref$.from, to = ref$.to;
switch (false) {

@@ -14,12 +15,32 @@ case !!to:

}
for (i$ = 0, len$ = (ref$ = flatten(methodNames)).length; i$ < len$; ++i$) {
methodName = ref$[i$];
results$.push(from[methodName] = ((ref1$ = to[methodName]) != null ? ref1$.bind(to) : void 8) || (fn$()));
for (i$ = 0, len$ = (ref$ = flatten(names)).length; i$ < len$; ++i$) {
name = ref$[i$];
switch (typeof to[name]) {
case 'function':
results$.push(delegateMethod(from, to, name));
break;
case 'undefined':
throw new Error("Error in rails-delegate: method '" + name + "' not found on the delegate");
default:
results$.push(delegateProperty(from, to, name));
}
}
return results$;
function fn$(){
};
delegateMethod = function(from, to, methodName){
var ref$;
debug("delegating method '" + methodName + "'");
return from[methodName] = ((ref$ = to[methodName]) != null ? ref$.bind(to) : void 8) || (function(){
throw new Error("Error in rails-delegate: method '" + methodName + "' not found on the delegate");
}
}());
};
delegateProperty = function(from, to, propertyName){
debug("delegating property '" + propertyName + "'");
return Object.defineProperty(from, propertyName, {
get: function(){
return to[propertyName];
}
});
};
module.exports = delegate;
}).call(this);
{
"name": "rails-delegate",
"version": "0.2.0",
"version": "0.3.0",
"description": "A simple helper to implement the delegation pattern in JavaScript code bases",

@@ -30,4 +30,5 @@ "main": "lib/rails-delegate.js",

"dependencies": {
"debug": "^2.2.0",
"lodash.flatten": "^4.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc