Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 21x 21x 9x 9x 7x 7x 11x 17x 11x 11x 11x 1x | import { IDictionary } from '../utils';
import { IDatasource, ISimpleDatasource } from './interfaces';
import { MemoryDatasource } from './memory-datasource';
/**
* Datasource that stores simple data in memory.
*/
export class SimpleDatasource extends MemoryDatasource implements ISimpleDatasource {
constructor(datasource: IDatasource) {
super(datasource);
this.items = this.getInitValue('items', datasource.items, undefined);
}
public initialize(): void {
super.initialize();
this.get();
}
get items(): (string | number)[] {
return this.data.map((item: IDictionary<any>) => item.value);
}
set items(items: (string | number)[]) {
this.data = (items || []).map((item: string | number) => ({ value: item }));
this.allData = this.data;
this.originalValues = [];
this.translateData();
}
public clone() {
return {
...super.clone(),
items: this.items,
type: 'simple',
};
}
}
|