Skip to content

Commit cc9cc30

Browse files
committedNov 21, 2016
[Fix] don’t assume Array#forEach, for ES3.
1 parent c9b8ce8 commit cc9cc30

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed
 

‎lib/test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var EventEmitter = require('events').EventEmitter;
66
var has = require('has');
77
var trim = require('string.prototype.trim');
88
var bind = require('function-bind');
9+
var forEach = require('for-each');
910
var isEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
1011

1112
module.exports = Test;
@@ -110,7 +111,7 @@ Test.prototype.test = function (name, opts, cb) {
110111

111112
Test.prototype.comment = function (msg) {
112113
var that = this;
113-
trim(msg).split('\n').forEach(function (aMsg) {
114+
forEach(trim(msg).split('\n'), function (aMsg) {
114115
that.emit('result', trim(aMsg).replace(/^#\s*/, ''));
115116
});
116117
};

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"deep-equal": "~1.0.1",
1313
"defined": "~1.0.0",
14+
"for-each": "~0.3.2",
1415
"function-bind": "~1.1.0",
1516
"glob": "~7.1.0",
1617
"has": "~1.0.1",

‎test/end-as-callback.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var tap = require("tap");
2+
var forEach = require("for-each");
23
var tape = require("../");
34
var concat = require('concat-stream');
45

@@ -67,7 +68,7 @@ function fakeAsyncWriteFail(name, cb) {
6768
function getStackTrace(rows) {
6869
var stacktrace = ' ---\n';
6970
var extract = false;
70-
rows.toString('utf8').split('\n').forEach(function (row) {
71+
forEach(rows.toString('utf8').split('\n'), function (row) {
7172
if (!extract) {
7273
if (row.indexOf('---') > -1) { // start of stack trace
7374
extract = true;

0 commit comments

Comments
 (0)
Please sign in to comment.