Skip to content

Commit d987798

Browse files
authored
fix: align some with RDF/JS definition of Dataset (#504)
* chore: implement some correctly according to RDF/JS spec * chore: fixup test
1 parent 68c1266 commit d987798

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/N3Store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ export default class N3Store {
601601
// Setting any field to `undefined` or `null` indicates a wildcard.
602602
some(callback, subject, predicate, object, graph) {
603603
for (const quad of this.readQuads(subject, predicate, object, graph))
604-
if (callback(quad))
604+
if (callback(quad, this))
605605
return true;
606606
return false;
607607
}

test/N3Store-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,6 +2444,18 @@ describe('Store', () => {
24442444
it('should return false on the empty set', () => {
24452445
expect(empty.some(quad => true)).toBe(false);
24462446
});
2447+
2448+
it('should return true if any quad passes the test with a graph', () => {
2449+
expect(storeb.some(quad => quad.subject.value === 's1')).toBe(true);
2450+
expect(storeb.some(quad => quad.subject.value === 's2')).toBe(false);
2451+
});
2452+
2453+
it('should have the store as the second argument of the callback', () => {
2454+
expect(store1.some((_, store) => {
2455+
expect(store.equals(store1)).toBe(true);
2456+
return true;
2457+
})).toBe(true);
2458+
});
24472459
});
24482460

24492461
describe('#every', () => {

0 commit comments

Comments
 (0)