Skip to content

Commit

Permalink
fix: forEach returns the instance
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Jul 9, 2020
1 parent 022b140 commit c39101e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/Clownface.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ class Clownface {
* @returns {Clownface}
*/
forEach (callback) {
return this.toArray().forEach(callback)
this.toArray().forEach(callback)
return this
}

/**
Expand Down
14 changes: 12 additions & 2 deletions test/Clownface/forEach.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* global describe, it */

const { describe, it } = require('mocha')
const assert = require('assert')
const clownface = require('../..')
const loadExample = require('../support/example')
Expand Down Expand Up @@ -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)
})
})

0 comments on commit c39101e

Please sign in to comment.