[Pkg-javascript-commits] [node-stack-utils] 17/67: Revert "refactor methods to use options objects"
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Sep 7 09:53:02 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-stack-utils.
commit 68707fd8c45676d54aa90c2ba03c3b6cbf75e58c
Author: James Talmage <james at talmage.io>
Date: Thu Jan 7 15:11:53 2016 -0500
Revert "refactor methods to use options objects"
This reverts commit 307716fe42d708ff8157e5e7fb5dd7c9af9b44ee.
---
index.js | 27 +++++++++++++++++----------
test.js | 12 ++++++------
2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/index.js b/index.js
index 093f8a3..961e6fa 100644
--- a/index.js
+++ b/index.js
@@ -57,10 +57,14 @@ StackUtils.prototype.clean = function (stack) {
return null;
};
-StackUtils.prototype.captureString = function (options) {
- options = options || {};
- var limit = options.limit || Infinity;
- var fn = options.startStackFunction || this.captureString;
+StackUtils.prototype.captureString = function (limit, fn) {
+ if (typeof limit === 'function') {
+ fn = limit;
+ limit = Infinity;
+ }
+ if (!fn) {
+ fn = this.captureString;
+ }
var limitBefore = Error.stackTraceLimit;
if (limit) {
@@ -76,11 +80,14 @@ StackUtils.prototype.captureString = function (options) {
return this.clean(stack);
};
-StackUtils.prototype.capture = function (options) {
- options = options || {};
- var limit = options.limit || Infinity;
- var fn = options.startStackFunction || this.capture;
-
+StackUtils.prototype.capture = function (limit, fn) {
+ if (typeof limit === 'function') {
+ fn = limit;
+ limit = Infinity;
+ }
+ if (!fn) {
+ fn = this.capture;
+ }
var prepBefore = Error.prepareStackTrace;
var limitBefore = Error.stackTraceLimit;
@@ -106,7 +113,7 @@ StackUtils.prototype.at = function at(fn) {
fn = at;
}
- var site = this.capture({limit: 1, startStackFunction: fn})[0];
+ var site = this.capture(1, fn)[0];
if (!site) {
return {};
diff --git a/test.js b/test.js
index 9966bf1..71c34fd 100644
--- a/test.js
+++ b/test.js
@@ -80,7 +80,7 @@ test('captureString: with startStack function', t => {
const stack = new StackUtils({internals: internals(), cwd: fixtureDir});
const capture = new CaptureFixture(stack);
- const capturedString = capture.redirect1('redirect2', 'call', 'captureString', {startStackFunction: capture.call});
+ const capturedString = capture.redirect1('redirect2', 'call', 'captureString', capture.call);
t.is(capturedString, join([
'CaptureFixture.redirect2 (capture-fixture.js:17:22)',
'CaptureFixture.redirect1 (capture-fixture.js:11:22)'
@@ -91,7 +91,7 @@ test('captureString: with limit', t => {
const stack = new StackUtils({internals: internals(), cwd: fixtureDir});
const capture = new CaptureFixture(stack);
- const capturedString = capture.redirect1('redirect2', 'call', 'captureString', {limit: 1});
+ const capturedString = capture.redirect1('redirect2', 'call', 'captureString', 1);
t.is(capturedString, join([
'CaptureFixture.call (capture-fixture.js:23:28)'
]));
@@ -101,7 +101,7 @@ test('captureString: with limit and startStack', t => {
const stack = new StackUtils({internals: internals(), cwd: fixtureDir});
const capture = new CaptureFixture(stack);
- const capturedString = capture.redirect1('redirect2', 'call', 'captureString', {limit: 1, startStackFunction: capture.call});
+ const capturedString = capture.redirect1('redirect2', 'call', 'captureString', 1, capture.call);
t.is(capturedString, join([
'CaptureFixture.redirect2 (capture-fixture.js:17:22)'
]));
@@ -119,7 +119,7 @@ test('capture returns an array of call sites', t => {
test('capture: with limit', t => {
const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
const capture = new CaptureFixture(stackUtil);
- const stack = capture.redirect1('redirect2', 'call', 'capture', {limit: 1});
+ const stack = capture.redirect1('redirect2', 'call', 'capture', 1);
t.is(stack.length, 1);
t.is(stack[0].getFunctionName(), 'CaptureFixture.call');
});
@@ -127,7 +127,7 @@ test('capture: with limit', t => {
test('capture: with stackStart function', t => {
const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
const capture = new CaptureFixture(stackUtil);
- const stack = capture.redirect1('redirect2', 'call', 'capture', {startStackFunction: capture.call});
+ const stack = capture.redirect1('redirect2', 'call', 'capture', capture.call);
t.true(stack.length > 1);
t.is(stack[0].getFunctionName(), 'CaptureFixture.redirect2');
});
@@ -135,7 +135,7 @@ test('capture: with stackStart function', t => {
test('capture: with limit and stackStart function', t => {
const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
const capture = new CaptureFixture(stackUtil);
- const stack = capture.redirect1('redirect2', 'call', 'capture', {limit: 1, startStackFunction: capture.call});
+ const stack = capture.redirect1('redirect2', 'call', 'capture', 1, capture.call);
t.is(stack.length, 1);
t.is(stack[0].getFunctionName(), 'CaptureFixture.redirect2');
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stack-utils.git
More information about the Pkg-javascript-commits
mailing list