-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathEmptyCell.js
41 lines (39 loc) · 837 Bytes
/
EmptyCell.js
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
39
40
41
import Cell from './Cell.js'
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
let r = Math.random() * 16 | 0;
let v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
/**
* Empty cells - in the fact table there is no data for them
* The cell is identified by a tuple
* */
export default class EmptyCell extends Cell {
constructor(data, options) {
if (!data.id) {
data.id = EmptyCell.generateId()
}
super(data, options)
}
/**
* @return {EmptyCell}
* */
static createEmptyCell(options) {
return new EmptyCell(options)
}
/**
* @param {Cell|{ id: string|number }} cell
* @return {boolean}
* */
static isEmptyCell(cell) {
return typeof cell.id === 'string'
}
/**
* @return {string}
* */
static generateId() {
return uuidv4()
}
}