{"name":"is-reference","version":"3.0.3","description":"Determine whether an AST node is a reference","type":"module","module":"src/index.js","types":"types/index.d.ts","exports":{"types":"./types/index.d.ts","import":"./src/index.js"},"scripts":{"test":"uvu","prepublishOnly":"npm test && dts-buddy"},"repository":{"type":"git","url":"git+https://github.com/Rich-Harris/is-reference.git"},"keywords":["ast","javascript","estree","acorn"],"author":{"name":"Rich Harris"},"license":"MIT","bugs":{"url":"https://github.com/Rich-Harris/is-reference/issues"},"homepage":"https://github.com/Rich-Harris/is-reference#readme","dependencies":{"@types/estree":"^1.0.6"},"devDependencies":{"acorn":"^8.0.5","acorn-class-fields":"^1.0.0","acorn-static-class-features":"^1.0.0","dts-buddy":"^0.5.3","estree-walker":"^3.0.0","typescript":"^5.6.3","uvu":"^0.5.6"},"_id":"is-reference@3.0.3","gitHead":"8bb053129bfabe2f6a7d7ed050159d67ebe82829","_nodeVersion":"20.16.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==","shasum":"9ef7bf9029c70a67b2152da4adf57c23d718910f","tarball":"http://registry-npm.ywwl.com/is-reference/download/is-reference-3.0.3.tgz","fileCount":5,"unpackedSize":3953,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDMOodLCJZDH27k9jm3Hex98Eb1t31q6sk/ESxB1OR7ZwIhAPGcq0HFAblEDVeiTcTEXyOvJ+1ADdGXcrBFljTJkVP9"}],"size":1724,"noattachment":false,"key":"/is-reference/-/is-reference-3.0.3.tgz"},"_npmUser":{"name":"rich_harris","email":"richard.a.harris@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/is-reference_3.0.3_1731423104112_0.3264479182729505"},"_hasShrinkwrap":false,"readme":"# is-reference\n\nUtility for determining whether an AST node is a reference.\n\n`foo` is a reference in these cases:\n\n```js\nconsole.log(foo);\nvar foo;\nfunction foo() {}\nfunction bar(foo) {}\nexport { foo as x };\n```\n\n`foo` is *not* a reference in these cases:\n\n```js\nvar obj = { foo: 1 };\nconsole.log(obj.foo);\nexport { x as foo };\n```\n\nIn all cases, `foo` is an `Identifier` node, but the two kinds must be treated differently for the purposes of scope analysis etc. (The examples are non-exhaustive.)\n\n\n## Installation\n\n```bash\nnpm install is-reference\n```\n\n\n## Usage\n\nExample using [Acorn](https://github.com/ternjs/acorn) and [estree-walker](https://github.com/Rich-Harris/estree-walker):\n\n```js\nimport { parse } from 'acorn';\nimport { walk } from 'estree-walker';\nimport is_reference from 'is-reference';\n\nconst identifiers = [];\nconst references = [];\n\nconst ast = parse(`var a = b.c;`);\n\nwalk(ast, {\n\tenter(node, parent) {\n\t\tif (node.type === 'Identifier') identifiers.push(node);\n\t\tif (is_reference(node, parent)) references.push(node);\n\t}\n});\n\nidentifiers.forEach(node => console.log(node.name)); // a, b, c\nreferences.forEach(node => console.log(node.name)); // a, b\n```\n\n\n## License\n\nMIT\n","publish_time":1731423104271,"maintainers":[{"name":"rich_harris","email":"richard.a.harris@gmail.com"}],"_cnpm_publish_time":1731423104271,"dist-tags":{"latest":"3.0.3"}}