Created
January 15, 2014 22:10
-
-
Save ericf/8445732 to your computer and use it in GitHub Desktop.
This file contains 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; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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