Forbes Lindesay
Forbes Lindesay
The and can already be done implicitly by chaining one after another (`app.get('/foo', user.is('registered'), user.can('do stuff'), ...)`), but I can see that it is more explicit. I like the idea...
That's referring to the fact that you could write: ``` js roles.use(function (req) { if (req.user.isSuperuser) return true; }); roles.use('do stuff', function (req) { if (req.user.isDoer) return true; }); ```...
A pull request to implement `.or` and `.and` would be welcomed.
The optimisation above would be completely safe though
In general it is safe to optimise: ``` javascript var x = E, y = E; ``` to ``` javascript var x = E, y = x; ``` For all...
Interestingly it would be safe with certain very specific side effects, but this is probably more in depth analysis than we'd want to do: ``` javascript var got = false;...
No worries @abody these things are tricky at the best of times, my initial intuition which I started writing down was completely false.
You wouldn't want it to run for anything that **could** be a getter, because that's way too likely to be unsafe. Just code the optimisation so it only does it...
OK, anything that can be a getter then, which should include all property accessors and any variable that's not found in the current scope (and therefore could be a property...
this.**defineGetter** wouldn't make any difference, I've already said we should exempt property accessors and 'global' variables, `this.name` is a property accessor.