Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Removed usage of Object.keys, filter, indexOf, forEach

Guillermo Rauch4f377905aae0
diff --git a/lib/runner.js b/lib/runner.js
index fc44d1ea..1a1f04e1 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -6,6 +6,7 @@
var EventEmitter = require('events').EventEmitter
, debug = require('debug')('runner')
, Test = require('./test')
+ , utils = require('./utils')
, noop = function(){};
/**
@@ -42,7 +43,7 @@ function Runner(suite) {
this.on('test end', function(test){ self.checkGlobals(test); });
this.on('hook end', function(hook){ self.checkGlobals(hook); });
this.grep(/.*/);
- this.globals(Object.keys(global).concat(['errno']));
+ this.globals(utils.keys(global).concat(['errno']));
}
/**
@@ -75,7 +76,7 @@ Runner.prototype.grep = function(re){
Runner.prototype.globals = function(arr){
debug('globals %j', arr);
- arr.forEach(function(arr){
+ utils.forEach(arr, function(arr){
this._globals.push(arr);
}, this);
return this;
@@ -90,8 +91,8 @@ Runner.prototype.globals = function(arr){
Runner.prototype.checkGlobals = function(test){
if (this.ignoreLeaks) return;
- var leaks = Object.keys(global).filter(function(key){
- return !~this._globals.indexOf(key);
+ var leaks = utils.filter(utils.keys(global), function(key){
+ return !~utils.indexOf(this._globals, key);
}, this);
this._globals = this._globals.concat(leaks);