diff --git a/lib/Clownface.js b/lib/Clownface.js index c957380..fd11e77 100644 --- a/lib/Clownface.js +++ b/lib/Clownface.js @@ -174,7 +174,8 @@ class Clownface { * @returns {Clownface} */ forEach (callback) { - return this.toArray().forEach(callback) + this.toArray().forEach(callback) + return this } /** diff --git a/test/Clownface/forEach.js b/test/Clownface/forEach.js index ea5158a..db07ba9 100644 --- a/test/Clownface/forEach.js +++ b/test/Clownface/forEach.js @@ -1,5 +1,4 @@ -/* global describe, it */ - +const { describe, it } = require('mocha') const assert = require('assert') const clownface = require('../..') const loadExample = require('../support/example') @@ -42,4 +41,15 @@ describe('.forEach', () => { assert.strictEqual(count, 7) }) + + it('should return self', () => { + const cf = clownface({ + dataset: rdf.dataset(), + term: rdf.namedNode('http://localhost:8080/data/person/bernadette-rostenkowski') + }) + + const forEachReturned = cf.forEach(() => {}) + + assert.strictEqual(forEachReturned, cf) + }) })