Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-reference

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-reference - npm Package Compare versions

Comparing version 1.2.1 to 2.0.0

src/index.js

4

CHANGELOG.md
# is-reference changelog
## 2.0.0
* Convert to JavaScript
## 1.2.1

@@ -4,0 +8,0 @@

31

package.json
{
"name": "is-reference",
"version": "1.2.1",
"version": "2.0.0",
"description": "Determine whether an AST node is a reference",
"main": "dist/is-reference.js",
"module": "dist/is-reference.es.js",
"types": "dist/types/index.d.ts",
"type": "module",
"module": "src/index.js",
"types": "types/index.d.ts",
"exports": {
"import": "./src/index.js"
},
"files": [
"dist/*.js",
"dist/types/**/*.d.ts"
"src",
"types"
],
"scripts": {
"test": "mocha",
"build": "rollup -c && tsc --emitDeclarationOnly",
"pretest": "npm run build",
"prepare": "npm run build",
"prepublishOnly": "npm test"
"test": "uvu",
"prepublishOnly": "npm test && tsc"
},

@@ -42,9 +42,6 @@ "repository": {

"acorn-static-class-features": "^0.2.1",
"estree-walker": "^2.0.1",
"mocha": "^7.1.2",
"rollup": "^2.10.3",
"rollup-plugin-typescript": "^1.0.1",
"tslib": "^2.0.0",
"typescript": "^3.9.2"
"estree-walker": "^3.0.0",
"typescript": "^3.9.2",
"uvu": "^0.5.1"
}
}

@@ -8,6 +8,6 @@ # is-reference

```js
console.log( foo );
console.log(foo);
var foo;
function foo () {}
function bar ( foo ) {}
function foo() {}
function bar(foo) {}
export { foo as x };

@@ -20,3 +20,3 @@ ```

var obj = { foo: 1 };
console.log( obj.foo );
console.log(obj.foo);
export { x as foo };

@@ -40,5 +40,5 @@ ```

```js
const { parse } = require( 'acorn' );
const { walk } = require( 'estree-walker' );
const isReference = require( 'is-reference' );
import { parse } from 'acorn';
import { walk } from 'estree-walker';
import is_reference from 'is-reference';

@@ -48,13 +48,13 @@ const identifiers = [];

const ast = parse( `var a = b.c;` );
const ast = parse(`var a = b.c;`);
walk( ast, {
enter ( node, parent ) {
if ( node.type === 'Identifier' ) identifiers.push( node );
if ( isReference( node, parent ) ) references.push( node );
walk(ast, {
enter(node, parent) {
if (node.type === 'Identifier') identifiers.push(node);
if (is_reference(node, parent)) references.push(node);
}
});
identifiers.forEach( node => console.log( node.name ) ); // a, b, c
references.forEach( node => console.log( node.name ) ); // a, b
identifiers.forEach(node => console.log(node.name)); // a, b, c
references.forEach(node => console.log(node.name)); // a, b
```

@@ -61,0 +61,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc