{"name":"periscopic","description":"periscopic","version":"1.0.0","repository":{"type":"git","url":"git+https://github.com/Rich-Harris/periscopic.git"},"main":"dist/periscopic.js","module":"dist/periscopic.mjs","types":"types/index.d.ts","devDependencies":{"@types/mocha":"^5.2.5","@types/node":"^10.9.4","acorn":"^7.0.0","mocha":"^5.2.0","rollup":"^0.65.2","rollup-plugin-sucrase":"^2.1.0","sander":"^0.6.0","sucrase":"^3.9.5","tiny-glob":"^0.2.6","typescript":"^3.6.2"},"scripts":{"build-declarations":"tsc -d && node scripts/move-type-declarations.js","build":"npm run build-declarations && rollup -c","dev":"rollup -cw","test":"mocha --opts mocha.opts","prepublishOnly":"npm test && npm run build"},"license":"MIT","dependencies":{"is-reference":"^1.1.3"},"gitHead":"cc01f0cd86c8a78ec394a0aab136f7ee1fd05e15","bugs":{"url":"https://github.com/Rich-Harris/periscopic/issues"},"homepage":"https://github.com/Rich-Harris/periscopic#readme","_id":"periscopic@1.0.0","_npmVersion":"6.5.0-next.0","_nodeVersion":"11.6.0","_npmUser":{"name":"rich_harris","email":"richard.a.harris@gmail.com"},"dist":{"integrity":"sha512-ftydZZH2Ca4FdWJXDwQ1Uuz4VEBhh4jXuT1bprR4qg/zM2+FhulluBUxnQXI0olDqADmsQRE1eHLs42iIhNjtA==","shasum":"3cc2077b82c4fd541dadd4eea6bb4f412dd36617","tarball":"http://registry-npm.ywwl.com/periscopic/download/periscopic-1.0.0.tgz","fileCount":7,"unpackedSize":12224,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJddVfTCRA9TVsSAnZWagAABi8P/jd63j+j5oUiTG5IiVwQ\nQSD9CSXabLhf0+G4pm6Dmwa82ZD6B41Ugw2KJSNf/vYLDkJ+ReeG5/+aqhYz\n/NPKZcrVtk5e8BSqoztiXPYMcYQRGTQE/PhXt2HAoKdrr9HKalRqHwBDyU5t\nao/Fi1wv3efAJCMzKAj1onREBonsU52+Otk+kDw2xUefJ4QKl3kO5pP5nrgI\nXSfOtoYIDcmIiIKgCPXhRvA5BC3X9srli0l2tJU7/CHYvwMHF7cwzbBJNLWn\nLqs5hAFZFQ68rrrTCgcJQeBbghPYWwLAvrkmWm/XWfcUzkAWdW/+W8v7NWUA\nuVxFJCDzoCSXw1wytGHVMC9JfhYzdgyL4kU8qVAGOtfQZoiZ9IKSUU1CwJLK\nvkdndnv5rlwZw5NEGvb8SoTQD0GvUz2iXxTLICUseMk/QZdufZOOWeFmhEaL\nY8Oi2Q567mLF6DfgpTttL84dQ8HgYsn9F1xDDHFWFZv76VkIjaFoNpQ1te7e\nuf7AMTkuQ14fzJJ1eX1lwczdTX6ZbjJO97KOcKdnVw1uM+NwFJgWg4cKGorh\nBSP1r46/uG4XHnhcgj+xxIZkK0ImQVOU14zN8Y56viriCDXgM/jOjjHw1T/j\nCtLIxseJ2XQJIos3p0C2ZaNouGlToqC8O9yXLalEbgbPBiG/Oa9VzsB/2lA4\nPgky\r\n=R3Ah\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCqlPlPP77neZa8il2GfWc3rMRSm1gtUhd/+8B3+hwY1gIgew92Vnkbsm9JNqr8yJSwf/h/YENlbHc6lN6UeCZ4mUE="}],"size":3490,"noattachment":false,"key":"/periscopic/-/periscopic-1.0.0.tgz"},"maintainers":[{"name":"rich_harris","email":"richard.a.harris@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/periscopic_1.0.0_1567971282759_0.3236794841134858"},"_hasShrinkwrap":false,"readme":"# periscopic\n\nUtility for analyzing scopes belonging to an ESTree-compliant AST.\n\n\n## API\n\n```js\nimport { analyze } from 'periscopic';\n\nconst ast = acorn.parse(`\nconst a = b;\nconsole.log(a);\n`);\n\nconst { map, globals, scope } = analyze(ast);\n```\n\n* `map` is a `WeakMap<Node, Scope>`, where the keys are the nodes of your AST that create a scope\n* `globals` is a `Map<string, Node>` of all the identifiers that are referenced without being declared anywhere in the program (in this case, `b` and `console`)\n* `scope` is the top-level `Scope` belonging to the program\n\n\n### Scope\n\nEach `Scope` instance has the following properties:\n\n* `scope.block` — true if the scope is created by a block statement (i.e. `let`, `const` and `class` are contained to it), false otherwise\n* `scope.parent` — the parent scope object\n* `scope.declarations` — a `Map<string, Node>` of all the variables declared in this scope, the node value referes to the declaration statement\n* `scope.initialised_declarations` — a `Set<string>` of all the variables declared and initialised in this scope\n* `scope.references` — a `Set<string>` of all the names referenced in this scope (or child scopes)\n\nIt also has two methods:\n\n* `scope.has(name)` — returns `true` if `name` is declared in this scope or an ancestor scope\n* `scope.find_owner(name)` — returns the scope object in which `name` is declared (or `null` if it is not declared)\n\n\n### `extract_identifiers` and `extract_names`\n\nThis package also exposes utilities for extracting the identifiers contained in a declaration or a function parameter:\n\n```js\nimport { extract_identifiers, extract_names } from 'periscopic';\n\nconst ast = acorn.parse(`\nconst { a, b: [c, d] = e } = opts;\n`);\n\nconst lhs = ast.body[0].declarations[0].id;\n\nextract_identifiers(lhs);\n/*\n[\n\t{ type: 'Identifier', name: 'a', start: 9, end: 10 },\n\t{ type: 'Identifier', name: 'c', start: 16, end: 17 },\n\t{ type: 'Identifier', name: 'd', start: 19, end: 20 }\n]\n*/\n\nextract_names(lhs);\n/*\n['a', 'c', 'd']\n*/\n```\n\n\n## License\n\n[MIT](LICENSE)","publish_time":1567971282924,"_cnpm_publish_time":1567971282924,"dist-tags":{"latest":"4.0.3"}}