Skip to content

Commit

Permalink
add slice list node
Browse files Browse the repository at this point in the history
  • Loading branch information
jdudetv committed Sep 27, 2024
1 parent 8dfa05f commit 570d530
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/packages/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,41 @@ export function pkg(core: Core) {
},
});

pkg.createSchema({
name: "Slice List",
type: "pure",
createIO({ io }) {
return {
list: io.dataInput({
id: "list",
type: t.list(t.wildcard(io.wildcard(""))),
}),
start: io.dataInput({
id: "start",
name: "Start",
type: t.int(),
}),
end: io.dataInput({
id: "end",
name: "End",
type: t.int(),
}),
output: io.dataOutput({
id: "output",
type: t.list(t.wildcard(io.wildcard(""))),
}),
};
},
run({ ctx, io }) {
const start = ctx.getInput(io.start);
const end =
ctx.getInput(io.end) !== 0
? ctx.getInput(io.end)
: ctx.getInput(io.list).length;
ctx.setOutput(io.output, ctx.getInput(io.list).slice(start, end));
},
});

pkg.createSchema({
name: "Split Lines",
type: "pure",
Expand Down

0 comments on commit 570d530

Please sign in to comment.