Created
January 15, 2014 22:10
-
-
Save ericf/8445732 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Exposed.prototype._getApplicableNamespaces = function () { | |
var namespaces = this.__namespaces__.concat(), | |
proto = Object.getPrototypeOf(this); | |
function isApplicable(namespace) { | |
return !namespaces.some(function (ns) { | |
var nsRegex = new RegExp('^' + ns + '(?:$|\\..+)'); | |
return nsRegex.test(namespace); | |
}); | |
} | |
while (Exposed.isExposed(proto)) { | |
namespaces.unshift.apply(namespaces, | |
proto.__namespaces__.filter(isApplicable)); | |
proto = Object.getPrototypeOf(proto); | |
} | |
return namespaces; | |
}; |
Oh this actually has to check the whole chain. There's some semantics behind this which aren't obvious, but I documented them in the real code: https://github.com/yahoo/express-state/blob/cache/lib/exposed.js#L118
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I know, performance probably doesn't matter. So, for laughs:
I don't know for certain if this actually works, nor if it really is faster. Both assumptions should be true... in theory.