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.3.0 to 0.4.0

24

lib/rails-delegate.js
// Generated by LiveScript 1.4.0
(function(){
var flatten, debug, delegate, delegateMethod, delegateProperty, slice$ = [].slice;
var flatten, debug, delegate, delegateEvent, delegateMethod, delegateProperty, _delegateEvent, slice$ = [].slice;
flatten = require('lodash.flatten');

@@ -29,2 +29,11 @@ debug = require('debug')('rails-delegate');

};
delegateEvent = function(){
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;
for (i$ = 0, len$ = (ref$ = flatten(names)).length; i$ < len$; ++i$) {
name = ref$[i$];
results$.push(_delegateEvent(name, from, to));
}
return results$;
};
delegateMethod = function(from, to, methodName){

@@ -45,3 +54,14 @@ var ref$;

};
module.exports = delegate;
_delegateEvent = function(eventName, from, to){
debug("delegating event '" + eventName + "'");
return from.on(eventName, function(){
var params;
params = slice$.call(arguments);
return to.emit.apply(to, [eventName].concat(slice$.call(params)));
});
};
module.exports = {
delegate: delegate,
delegateEvent: delegateEvent
};
}).call(this);

6

package.json
{
"name": "rails-delegate",
"version": "0.3.0",
"version": "0.4.0",
"description": "A simple helper to implement the delegation pattern in JavaScript code bases",

@@ -27,3 +27,5 @@ "main": "lib/rails-delegate.js",

"david": "^7.0.0",
"livescript": "^1.4.0"
"jsdiff-console": "^1.1.3",
"livescript": "^1.4.0",
"wait": "^0.1.0"
},

@@ -30,0 +32,0 @@ "dependencies": {

@@ -21,3 +21,3 @@ # Delegation Pattern for JavaScript

delegate('start', 'stop', { from: this, to: this.engine });
delegate('start', 'stop', 'cylinders', { from: this, to: this.engine });
};

@@ -30,4 +30,7 @@

`myCar.stop()` calls `myCar.engine.stop()`.
You can also access the property `myCar.cylinders`,
which contains the value of `myCar.engine.cylinders`.
More information in the [spec](features/delegate.feature).
More information in the spec for delegating [methods](features/delegating-methods.feature)
and [properties](features/delegating-properties.feature).
This library also provides meaningful [error messages](features/error-messages.feature).

@@ -34,0 +37,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