Socket
Socket
Sign inDemoInstall

stack-chain

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

test/simple/callSite-function.js

2

package.json
{
"name": "stack-chain",
"description": "API for combining call site modifiers",
"version": "1.2.0",
"version": "1.3.0",
"author": "Andreas Madsen <amwebdk@gmail.com>",

@@ -6,0 +6,0 @@ "main": "./stack-chain.js",

@@ -97,8 +97,26 @@ #stack-chain [![Build Status](https://secure.travis-ci.org/AndreasMadsen/stack-chain.png)](http://travis-ci.org/AndreasMadsen/stack-chain)

### chain.callSite()
### chain.callSite([options])
This will return the unmodified callSite array from the current tick. This
This will return the unmodified `callSite` array from the current tick. This
is a performance shortcut, as it does not require generating the `.stack`
string. This behaviour is different from the `Error().callSite` properties.
While this is mostly generating `callSite` in hot code, it can be useful to
do some modification on the array. The `options` object, supports the following:
```javascript
options = {
// (default false) run the extenders on the callSite array.
extend: true,
// (default false) run the filters on the callSite array.
filter: true,
// (default 0) before running extend or filter methods, slice of some of the
// end. This can be useful for hiding the place from where you called this
// function.
slice: 2
}
```
### Error.stackTraceLimit

@@ -118,3 +136,3 @@

Returns the mutated `callSite` array, that is after `extend` and `filter`
is applied. The array will also mot excite the `Error.stackTraceLimit`.
is applied. The array will not excite the `Error.stackTraceLimit`.

@@ -121,0 +139,0 @@ ## License

@@ -14,3 +14,6 @@

var SHORTCUT_CALLSITE = false;
stackChain.prototype.callSite = function collectCallSites() {
stackChain.prototype.callSite = function collectCallSites(options) {
if (!options) options = {};
// Get CallSites
SHORTCUT_CALLSITE = true;

@@ -21,2 +24,11 @@ var error = new Error();

SHORTCUT_CALLSITE = false;
// Slice
callSites = callSites.slice(options.slice || 0);
// Modify CallSites
if (options.extend) callSites = this.extend._modify(error, callSites);
if (options.filter) callSites = this.filter._modify(error, callSites);
// Done
return callSites;

@@ -23,0 +35,0 @@ };

// Produces an error with `level` deept in the call stack
function deepStack(curr, top, callback) {
exports.deepStack = function deepStack(curr, top, callback) {
if (curr === top) {

@@ -9,3 +9,3 @@ callback();

}
}
};

@@ -16,3 +16,3 @@ exports.real = function produceError(level) {

deepStack(0, level, function () {
exports.deepStack(0, level, function () {
Error.stackTraceLimit = level;

@@ -39,1 +39,9 @@

};
exports.convert = function (callSites) {
var lines = [];
for (var i = 0; i < callSites.length; i++) {
lines.push(" at " + callSites[i].toString());
}
return lines.join('\n');
};
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc