grapher/lib/query/nodes/reducerNode.js

15 lines
333 B
JavaScript
Raw Normal View History

export default class ReducerNode {
constructor(name, {body, reduce}) {
this.name = name;
this.body = body;
this.reduceFunction = reduce;
2016-11-18 18:33:21 +02:00
}
compute(object) {
object[this.name] = this.reduce(object);
}
reduce(object) {
return this.reduceFunction.call(null, object);
}
}