mirror of
https://github.com/vale981/grapher
synced 2025-03-08 11:01:39 -05:00
15 lines
No EOL
333 B
JavaScript
15 lines
No EOL
333 B
JavaScript
export default class ReducerNode {
|
|
constructor(name, {body, reduce}) {
|
|
this.name = name;
|
|
this.body = body;
|
|
this.reduceFunction = reduce;
|
|
}
|
|
|
|
compute(object) {
|
|
object[this.name] = this.reduce(object);
|
|
}
|
|
|
|
reduce(object) {
|
|
return this.reduceFunction.call(null, object);
|
|
}
|
|
} |