Module: Operators

It enables you to create new operator by composing existing operators. The newly created operator is used like any other operator. The operations provided will be executed in a serial manner ie. result of one operation will be the input for the next operations (like pipe operator in unix). Compose has added benefits which chaining does not provide. Like, if there are group of operators are involved to transform data, chaining would create so intermediate DataModel instances. If `compose` is used no intermediate DataModels are created. Suported operators in compose are - `select` - `project` - `groupBy` - `bin` - Any operator created using compose `compose`
Parameters:
Name Type Description
operators: Array.<Operators> An array of operation that will be applied on the datatable.
Source:
Returns:
Function which expects an instance of DataModel on which the operator needs to be applied.
Type
PreparatorFunction
Example
//@preamble_start
 Promise.all([loadData('/static/cars.json'), loadData('/static/cars-schema.json')]).then(function (params) {
 const data = params[0];
 const schema = params[1];
 const DataModel = muze.DataModel;
 const dm = new DataModel(data, schema);
 //@preamble_end
 // DataModel instance is created from https://www.charts.com/static/cars.json data,
 // https://www.charts.com/static/cars-schema.json schema and assigned to variable dm. DataModel is extracted from
 // muze namespace and assigned to the DataModel variable.
 const compose = DataModel.Operators.compose;
 const select = DataModel.Operators.select;
 const project = DataModel.Operators.project;

 let lowCylCarsFromUSADM= compose(
     select(fields => fields.Origin.value === 'USA' && fields.Cylinders.value === '4' ),
     project(['Origin', 'Cylinders'], { mode: DataModel.FilteringMode.INVERSE })
 );

 const outputDM = lowCylCarsFromUSADM(dm);
 //@preamble_start
 printDM(outputDM);
 });
 //@preamble_end

Namespaces

DataModel