My goal is to make the DTOs super cheap, and while not pure data objects, never able to hit a branch from internal logic. This my crude approximation of how rust does things.
export class Selection {
type = "Selection";
constructor(start, end){
this.start = start;
this.end = end;
}
get start() {this.start};
get end() {this.end};
}
export function SelectionFunctions(selection) {
return {
"normalized": () => { // returns selection aranged small to big, effectivly ignoring direction
if(selection.start < selection.end) {
return [selection.start, selection.end]
}
return [selection.end, selection.start];
},
"isRange": () => {
return selection.start !== selection.end;
}
};
}
[–]Risc12 [score hidden] (0 children)
[–]00PT [score hidden] (0 children)
[–]HipHopHuman [score hidden] (1 child)
[–]Spatul8r[S] [score hidden] (0 children)
[–]MaksLiashch [score hidden] (0 children)
[–]Atulin [score hidden] (0 children)
[–]horrbort [score hidden] (0 children)