Sha256: 9e8af3f34b62543a2a1a811e641055a86d9069ed383ecd5349377c5ac74601dd

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

(function (global, factory) {
	typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
	typeof define === 'function' && define.amd ? define(factory) :
	(global.isReference = factory());
}(this, (function () { 'use strict';

function isReference(node, parent) {
    if (node.type === 'MemberExpression') {
        return !node.computed && isReference(node.object, node);
    }
    if (node.type === 'Identifier') {
        // the only time we could have an identifier node without a parent is
        // if it's the entire body of a function without a block statement –
        // i.e. an arrow function expression like `a => a`
        if (!parent)
            return true;
        // TODO is this right?
        if (parent.type === 'MemberExpression' || parent.type === 'MethodDefinition') {
            return parent.computed || node === parent.object;
        }
        // disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
        if (parent.type === 'Property')
            return parent.computed || node === parent.value;
        // disregard the `bar` in `export { foo as bar }`
        if (parent.type === 'ExportSpecifier' && node !== parent.local)
            return false;
        return true;
    }
    return false;
}

return isReference;

})));

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
jass-0.9.5 vendor/node_modules/is-reference/dist/is-reference.js
jass-0.9.4 vendor/node_modules/is-reference/dist/is-reference.js
jass-0.9.3 vendor/node_modules/is-reference/dist/is-reference.js
condenser-0.0.4 lib/condenser/processors/node_modules/is-reference/dist/is-reference.js
jass-0.9.1 vendor/node_modules/is-reference/dist/is-reference.js