Skip to content

Commit

Permalink
extract order constant outside of Schema constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
espressoroaster authored and kanitw committed Jun 27, 2017
1 parent b170e89 commit 95b0d34
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,23 @@ export function build(data: any, tableSchema: TableSchema<TableSchemaFieldDescr
return new Schema(derivedTableSchema);
}

// order the field schema when we construct a new Schema
// this orders the fields in the UI
const order = {
'nominal': 0,
'key': 1,
'ordinal': 2,
'temporal': 3,
'quantitative': 4
};

export class Schema {
private _tableSchema: TableSchema<FieldSchema>;
private _fieldSchemaIndex: {[field: string]: FieldSchema};

constructor(tableSchema: TableSchema<FieldSchema>) {
this._tableSchema = tableSchema;

// order the field schema when we construct a new Schema
// this orders the fields in the UI
const order = {
'nominal': 0,
'key': 1,
'ordinal': 2,
'temporal': 3,
'quantitative': 4
};

tableSchema.fields.sort(function(a: FieldSchema, b: FieldSchema) {
// first order by vlType: nominal < temporal < quantitative < ordinal
Expand Down

0 comments on commit 95b0d34

Please sign in to comment.