Skip to content

Instantly share code, notes, and snippets.

@ericf
Created January 15, 2014 22:10
Show Gist options
  • Select an option

  • Save ericf/8445732 to your computer and use it in GitHub Desktop.

Select an option

Save ericf/8445732 to your computer and use it in GitHub Desktop.

Revisions

  1. ericf created this gist Jan 15, 2014.
    20 changes: 20 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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;
    };