Skip to content

Commit

Permalink
start from quads, not undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
ajuvercr committed Dec 24, 2024
1 parent 7932410 commit ba3bf09
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rdf-lens",
"version": "1.3.2",
"version": "1.3.3",
"main": "./dist/index.js",
"type": "module",
"exports": {
Expand Down
5 changes: 3 additions & 2 deletions src/lens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,13 @@ export class BasicLensM<C, T> extends BasicLens<C, T[]> {

reduce<F>(
lens: BasicLens<[T, F], F>,
start: BasicLens<T[], F>,
start: BasicLens<C, F>,
): BasicLens<C, F> {
return new BasicLens((c, _, states) => {
const st = this.then(empty<T[]>().and(start)).map(([ts, f]) => {
const st = this.and(start).map(([ts, f]) => {
return ts.reduce((acc, v) => lens.execute([v, acc], states), f);
});

return st.execute(c, states);
});
}
Expand Down
5 changes: 1 addition & 4 deletions src/shacl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,7 @@ export function envReplace(): BasicLens<Quad[], Quad[]> {
RDFL.terms.EnvVariable,
)
.thenAll(subject)
.reduce(
reduce,
empty<Cont[]>().map((x) => x[0].quads),
);
.reduce(reduce, empty<Quad[]>());

return sliced().then(actualReplace);
}
Expand Down
10 changes: 8 additions & 2 deletions test/shacl2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,11 +568,12 @@ ${prefixes}
describe("Env replace works", () => {
const data = `
${prefixes}
<a> <b> <c>.
<1> js:test [
a rdfl:EnvVariable;
rdfl:envDefault js:generatedAtTime;
rdfl:envKey "key1"
].
], <c>.
<2> js:test [
a rdfl:EnvVariable;
Expand Down Expand Up @@ -603,7 +604,7 @@ ${prefixes}
});

test("Did change new quads", () => {
expect(newQuads.length).toBe(3);
expect(newQuads.length).toBe(5);
});

test("Datatype defaults to literal", () => {
Expand All @@ -625,5 +626,10 @@ ${prefixes}
"https://w3id.org/conn/js#generatedAtTime",
);
});

test("Doesnt fail when no env to replace", () => {
const newNewQuads = envReplace().execute(newQuads);
expect(newNewQuads.length).toBe(newQuads.length);
});
});
});

0 comments on commit ba3bf09

Please sign in to comment.