Skip to content

Commit

Permalink
Cache reverse function
Browse files Browse the repository at this point in the history
  • Loading branch information
ig-pj committed May 21, 2018
1 parent d19a4c0 commit 087bc1c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/sinon/sandbox.js
Expand Up @@ -17,6 +17,7 @@ var fakeXhr = require("nise").fakeXhr;
var usePromiseLibrary = require("./util/core/use-promise-library");

// cache original versions, to prevent issues when they are stubbed in user space
var reverse = Array.prototype.reverse;
var push = Array.prototype.push;
var filter = Array.prototype.filter;
var forEach = Array.prototype.filter;
Expand Down Expand Up @@ -132,7 +133,8 @@ function Sandbox() {
throw new Error("sandbox.restore() does not take any parameters. Perhaps you meant stub.restore()");
}

applyOnEach(collection.reverse(), "restore");
reverse.call(collection);
applyOnEach(collection, "restore");
collection = [];

forEach.call(fakeRestorers, function (restorer) {
Expand Down

0 comments on commit 087bc1c

Please sign in to comment.