New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

esliveness

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esliveness - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

test/expected/04-functions-02.js

15

package.json
{
"name": "esliveness",
"version": "0.0.1",
"version": "0.0.2",
"description": "Liveness analysis for JavaScript based on Mozilla's Parser API AST.",

@@ -12,2 +12,15 @@ "main": "liveness.js",

},
"repository": {
"type": "git",
"url": "git+https://github.com/Pfarrer/esliveness.git"
},
"keywords": [
"javascript",
"ecmascript",
"static analysis",
"liveness",
"variable",
"Parser API",
"Mozilla"
],
"author": "Brian Pfretzschner",

@@ -14,0 +27,0 @@ "license": "MIT",

16

test/expected/02-branches-01.js

@@ -1,8 +0,8 @@

// Liveness:
// Liveness: write
// - Kill: a, c
var a = 1, b, c = true;
if (// Liveness: a, c
if (// Liveness: a, c, write
// - Gen: a
a != 0) {
// Liveness: a, c
// Liveness: a, c, write
// - Gen: a

@@ -12,11 +12,11 @@ // - Kill: b

} else {
// Liveness:
// Liveness: write
// - Kill: b
b = 0;
// Liveness: b
// Liveness: b, write
// - Kill: c
c = false;
}
// Liveness: b, c
// - Gen: b, c
console.log(b, c);
// Liveness: b, c, write
// - Gen: b, c, write
write(b, c);

@@ -1,15 +0,15 @@

// Liveness:
// Liveness: write
// - Kill: a, c
var a = 1, b, c = true;
if (// Liveness: a, c
if (// Liveness: a, c, write
// - Gen: a
a == 0) {
// Liveness:
// Liveness: write
// - Kill: b
b = 0;
// Liveness: b
// Liveness: b, write
// - Kill: c
c = false;
} else {
// Liveness: a, c
// Liveness: a, c, write
// - Gen: a

@@ -19,4 +19,4 @@ // - Kill: b

}
// Liveness: b, c
// - Gen: b, c
console.log(b, c);
// Liveness: b, c, write
// - Gen: b, c, write
write(b, c);

@@ -0,5 +1,19 @@

// Liveness: write
// - Kill: res
var res = 0;
for (var i=0; i<10; i++) {
for (// Liveness: res, write
// - Kill: i
var i = 0; // Liveness: i, res, write
// - Gen: i
i < 10; // Liveness: i, res, write
// - Gen: i
// - Kill: i
i++) {
// Liveness: i, write
// - Gen: i
// - Kill: res
res += i;
}
// Liveness: res, write
// - Gen: res, write
write(res);

@@ -1,15 +0,7 @@

var gcd = function (a, b) {
var c = a;
var d = b;
if (c == 0) {
return d;
}
while (d != 0) {
if (c > d)
c = c - d;
else
d = d - c;
}
return c;
};
gcd(18, 7);
function fib(n) {
if (n <= 2)
return 1;
else
return fib(n - 2) + fib(n - 1);
}
console.log(fib(10));

@@ -1,58 +0,18 @@

// Liveness: global, this
// - Gen: global, this
function (__global) {
// Liveness: __global
var tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9;
// Liveness: __global
// - Kill: tmp9
tmp9 = function (n) {
var tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16, tmp17, tmp18, tmp19, tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26;
tmp11 = n;
tmp12 = 2;
tmp10 = tmp11 <= tmp12;
if (tmp10) {
tmp13 = 1;
return tmp13;
} else {
tmp18 = 'fib';
tmp17 = __global[tmp18];
tmp20 = n;
tmp21 = 2;
tmp19 = tmp20 - tmp21;
tmp15 = tmp17(tmp19);
tmp23 = 'fib';
tmp22 = __global[tmp23];
tmp25 = n;
tmp26 = 1;
tmp24 = tmp25 - tmp26;
tmp16 = tmp22(tmp24);
tmp14 = tmp15 + tmp16;
return tmp14;
// TODO
function foo(a) {
var x = a;
function bar() {
var y = x + 5;
function baz() {
x = y + 1;
}
};
tmp8 = 'fib';
__global[tmp8] = tmp9;
tmp2 = 'console';
tmp0 = __global[tmp2];
// Liveness: __global, tmp0
// - Kill: tmp1
tmp1 = 'log';
// Liveness: __global, tmp0, tmp1
// - Kill: tmp5
tmp5 = 'fib';
// Liveness: __global, tmp0, tmp1, tmp5
// - Gen: __global, tmp5
// - Kill: tmp4
tmp4 = __global[tmp5];
// Liveness: tmp0, tmp1, tmp4
// - Kill: tmp6
tmp6 = 10;
// Liveness: tmp0, tmp1, tmp4, tmp6
// - Gen: tmp4, tmp6
// - Kill: tmp3
tmp3 = tmp4(tmp6);
// Liveness: tmp0, tmp1, tmp3
// - Gen: tmp0, tmp1, tmp3
// - Kill: tmp7
tmp7 = tmp0[tmp1](tmp3);
}(typeof global === 'undefined' ? this : global);
baz();
return x;
}
var t = bar();
return x + t;
}
// Liveness: foo
// - Gen: foo
// - Kill: z
var z = foo(3);

@@ -8,2 +8,2 @@ var a = 1, b, c = true;

}
console.log(b, c);
write(b, c);

@@ -8,2 +8,2 @@ var a = 1, b, c = true;

}
console.log(b, c);
write(b, c);

@@ -1,15 +0,6 @@

// Liveness:
var x = 0, y = 0;
// Liveness: x, y
var z = false;
// Liveness: x, y, z
// - Gen: y
while (y < 10) {
// Liveness: x, y, z
// - Gen: x
// - Kill: x
x++;
}
// Liveness: z
// - Kill: z
z = true;

@@ -1,15 +0,7 @@

var gcd = function (a, b) {
var c = a;
var d = b;
if (c == 0) {
return d;
}
while (d != 0) {
if (c > d)
c = c - d;
else
d = d - c;
}
return c;
};
gcd(18, 7);
function fib(n) {
if (n <= 2)
return 1;
else
return fib(n - 2) + fib(n - 1);
}
console.log(fib(10));

@@ -1,5 +0,9 @@

function fib(n) {
if (n <= 2) return 1;
else return fib(n-2) + fib(n-1);
}
console.log(fib(10));
(function (__global) {
var val, id;
id = function (n) {
return n;
};
val = 'string';
var ret = id(val);
return ret;
}(typeof global === 'undefined' ? this : global));

@@ -1,38 +0,15 @@

(function (__global) {
var tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9;
tmp9 = function (n) {
var tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16, tmp17, tmp18, tmp19, tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26;
tmp11 = n;
tmp12 = 2;
tmp10 = tmp11 <= tmp12;
if (tmp10) {
tmp13 = 1;
return tmp13;
} else {
tmp18 = 'fib';
tmp17 = __global[tmp18];
tmp20 = n;
tmp21 = 2;
tmp19 = tmp20 - tmp21;
tmp15 = tmp17(tmp19);
tmp23 = 'fib';
tmp22 = __global[tmp23];
tmp25 = n;
tmp26 = 1;
tmp24 = tmp25 - tmp26;
tmp16 = tmp22(tmp24);
tmp14 = tmp15 + tmp16;
return tmp14;
// Lexical scoping
function foo(a) {
var x = a;
function bar() {
var y = x + 5;
function baz() {
x = y + 1;
}
};
tmp8 = 'fib';
__global[tmp8] = tmp9;
tmp2 = 'console';
tmp0 = __global[tmp2];
tmp1 = 'log';
tmp5 = 'fib';
tmp4 = __global[tmp5];
tmp6 = 10;
tmp3 = tmp4(tmp6);
tmp7 = tmp0[tmp1](tmp3);
}(typeof global === 'undefined' ? this : global));
baz();
return x;
}
var t = bar();
return x + t;
}
var z = foo(3);

Sorry, the diff of this file is not supported yet

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