get()

in src/js/other-websites/fathom.js [2585:2607]


        get(thing) {
            if (typeof thing === 'string') {
                if (this._outRules.has(thing)) {
                    return Array.from(this._execute(this._outRules.get(thing)));
                } else {
                    throw new Error(`There is no out() rule with key "${thing}".`);
                }
            } else if (isDomElement(thing)) {
                // Return the fnode and let it run type(foo) on demand, as people
                // ask it things like scoreFor(foo).
                return this.fnodeForElement(thing);
            } else if (thing.asLhs !== undefined) {
                // Make a temporary out rule, and run it. This may add things to
                // the ruleset's cache, but that's fine: it doesn't change any
                // future results; it just might make them faster. For example, if
                // you ask for .get(type('smoo')) twice, the second time will be a
                // cache hit.
                const outRule = rule(thing, out(Symbol('outKey')));
                return Array.from(this._execute(outRule));
            } else {
                throw new Error('ruleset.get() expects a string, an expression like on the left-hand side of a rule, or a DOM node.');
            }
        }