import Package from '@/data/package/package' ; import _ from 'lodash' ; import { ValueType } from '@/data/parser' ; import { valueComparator } from '@/data/util' ; export default class ConstantsPackage extends Package { private values : Array < number | string > = [ ] ; constructor ( values ? ) { super ( ) ; this . values = values || [ ] ; } public setConstants ( values ) { this . values = values . concat ( ) ; } public addConstant ( value ) { this . values . push ( value ) ; } public addConstants ( values ) { this . values = this . values . concat ( values ) ; } public getConstants ( ) { return this . values ; } public clear ( ) { this . values = [ ] ; } public numConstants ( ) { return this . values . length ; } public unique ( ) { this . values = _ . uniq ( this . values . map ( val => val . toString ( ) ) ) ; } public sort ( type ? ) { this . values = ! type ? this . values . concat ( ) . sort ( ) : this . values . concat ( ) . sort ( valueComparator ( type ) ) ; } public toDisplayString ( ) { return 'constants' ; } }