You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

caller

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 1.0.0

.travis.yml

9

index.js

@@ -10,3 +10,3 @@ 'use strict';

*/
module.exports = function () {
module.exports = function (depth) {
var pst, stack, file, frame;

@@ -21,10 +21,11 @@

stack = (new Error()).stack;
stack = stack.slice(2);
depth = !depth || isNaN(depth) ? 1 : (depth > stack.length - 2 ? stack.length - 2 : depth);
stack = stack.slice(depth + 1);
do {
frame = stack.shift();
file = frame && frame.getFileName()
file = frame && frame.getFileName();
} while (stack.length && file === 'module.js');
return file;
};
};
{
"name": "caller",
"version": "0.0.1",
"version": "1.0.0",
"description": "@substack's caller.js as a module",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -35,2 +35,33 @@ #### caller

};
```
```
### Depth
Caller also accepts a `depth` argument for tracing back further (defaults to `1`).
```javascript
// foo.js
var bar = require('bar');
bar.doWork();
```
```javascript
// bar.js
var baz = require('baz');
exports.doWork = function () {
baz.doWork();
};
```
```javascript
// baz.js
var caller = require('caller');
exports.doWork = function () {
console.log(caller(2)); // `/path/to/foo.js`
};
```

@@ -19,3 +19,2 @@ 'use strict';

t.test('determine caller at runtime', function (t) {

@@ -32,3 +31,24 @@ var callee, actual, expected;

t.test('determine caller with depth', function (t) {
var callee, actual, expected;
callee = require('./fixtures/callee');
actual = callee(caller.bind(null, 2));
expected = require.resolve('tape/lib/test');
t.equal(actual, expected);
t.end();
});
t.test('determine caller with depth cap', function (t) {
var callee, actual, expected;
callee = require('./fixtures/callee');
actual = callee(caller.bind(null, 99));
expected = require.resolve('tape/lib/test');
t.equal(actual, expected);
t.end();
});
t.test('determine caller at initialization time', function (t) {

@@ -44,2 +64,2 @@ var actual, expected;

});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc