@transformation/core
Advanced tools
Comparing version 5.1.1 to 6.0.0
{ | ||
"name": "@transformation/core", | ||
"version": "5.1.1", | ||
"version": "6.0.0", | ||
"description": "Create transformation pipelines", | ||
@@ -28,3 +28,3 @@ "main": "./src/index.js", | ||
"unexpected": "12.0.4", | ||
"unexpected-steps": "^5.0.0" | ||
"unexpected-steps": "^6.0.0" | ||
}, | ||
@@ -34,3 +34,3 @@ "engines": { | ||
}, | ||
"gitHead": "16310db8d6c73a64a83098a966042c99754ee52e" | ||
"gitHead": "682f9600b8c8e191798ff605529e837e03f293eb" | ||
} |
@@ -1739,9 +1739,2 @@ # @transformation/core | ||
Notice that `uniq` keep internal state from its first invocation. You can | ||
change this behavior by setting the scope to `pipeline`, the default is `global`. | ||
```js | ||
const uniqToPipeline = uniq({ scope: "pipeline" }); | ||
``` | ||
## uniqBy | ||
@@ -1805,9 +1798,2 @@ | ||
Notice that `uniqBy` keep internal state from its first invocation. You can | ||
change this behavior by setting the scope to `pipeline`, the default is `global`. | ||
```js | ||
const uniqByName = uniqBy(({ name }) => name, { scope: "pipeline" }); | ||
``` | ||
## unless | ||
@@ -1814,0 +1800,0 @@ |
@@ -15,19 +15,17 @@ const expect = require("unexpected").clone().use(require("unexpected-steps")); | ||
describe("when scope is pipeline", () => { | ||
it("resets state for each invocation of the step", async () => { | ||
const uniqInPipeline = uniq({ scope: "pipeline" }); | ||
it("resets state for each invocation of the step", async () => { | ||
const uniqInPipeline = uniq({ scope: "pipeline" }); | ||
await expect( | ||
pipeline(emitItems(0, 1, 2, 0, 3, 2), uniqInPipeline), | ||
"to yield items", | ||
[0, 1, 2, 3] | ||
); | ||
await expect( | ||
pipeline(emitItems(0, 1, 2, 0, 3, 2), uniqInPipeline), | ||
"to yield items", | ||
[0, 1, 2, 3] | ||
); | ||
await expect( | ||
pipeline(emitItems(0, 1, 4), uniqInPipeline), | ||
"to yield items", | ||
[0, 1, 4] | ||
); | ||
}); | ||
await expect( | ||
pipeline(emitItems(0, 1, 4), uniqInPipeline), | ||
"to yield items", | ||
[0, 1, 4] | ||
); | ||
}); | ||
}); |
@@ -9,8 +9,4 @@ const step = require("./step"); | ||
let seen = new Set(); | ||
return step(async ({ take, put, CLOSED }) => { | ||
if (options.scope === "pipeline") { | ||
seen = new Set(); | ||
} | ||
const seen = new Set(); | ||
@@ -17,0 +13,0 @@ while (true) { |
@@ -57,4 +57,4 @@ const expect = require("unexpected").clone().use(require("unexpected-steps")); | ||
it("doesn't reset state for each invocation of the step", async () => { | ||
const uniqByName = uniqBy(({ name }) => name); | ||
it("resets state for each invocation of the step", async () => { | ||
const uniqByName = uniqBy(({ name }) => name, { scope: "pipeline" }); | ||
@@ -92,49 +92,9 @@ await expect( | ||
"to yield items", | ||
[{ id: 4, name: "quux", count: 4 }] | ||
[ | ||
{ id: 0, name: "foo", count: 0 }, | ||
{ id: 1, name: "bar", count: 1 }, | ||
{ id: 4, name: "quux", count: 4 }, | ||
] | ||
); | ||
}); | ||
describe("when scope is pipeline", () => { | ||
it("resets state for each invocation of the step", async () => { | ||
const uniqByName = uniqBy(({ name }) => name, { scope: "pipeline" }); | ||
await expect( | ||
pipeline( | ||
emitItems( | ||
{ id: 0, name: "foo", count: 0 }, | ||
{ id: 1, name: "bar", count: 1 }, | ||
{ id: 2, name: "baz", count: 2 }, | ||
{ id: 0, name: "foo", count: 3 }, | ||
{ id: 3, name: "qux", count: 4 }, | ||
{ id: 2, name: "baz", count: 5 } | ||
), | ||
uniqByName | ||
), | ||
"to yield items", | ||
[ | ||
{ id: 0, name: "foo", count: 0 }, | ||
{ id: 1, name: "bar", count: 1 }, | ||
{ id: 2, name: "baz", count: 2 }, | ||
{ id: 3, name: "qux", count: 4 }, | ||
] | ||
); | ||
await expect( | ||
pipeline( | ||
emitItems( | ||
{ id: 0, name: "foo", count: 0 }, | ||
{ id: 1, name: "bar", count: 1 }, | ||
{ id: 4, name: "quux", count: 4 } | ||
), | ||
uniqByName | ||
), | ||
"to yield items", | ||
[ | ||
{ id: 0, name: "foo", count: 0 }, | ||
{ id: 1, name: "bar", count: 1 }, | ||
{ id: 4, name: "quux", count: 4 }, | ||
] | ||
); | ||
}); | ||
}); | ||
}); |
149934
3743
2015