You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
536 B
26 lines
536 B
export function uniqueId() {
|
|
return 'f'
|
|
+ Math.random().toString(16).replace('.', '')
|
|
+ (+new Date()).toString(16);
|
|
}
|
|
|
|
export function keyBy(array, keyfunc) {
|
|
let result = {};
|
|
for(let item of array) {
|
|
if (typeof keyfunc == 'string') {
|
|
result[item[keyfunc]] = item;
|
|
} else {
|
|
result[keyfunc(item)] = item;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
export function objCopy(object) {
|
|
return JSON.parse(JSON.stringify(object));
|
|
}
|
|
|
|
export function castId(id) {
|
|
// TODO no-op after switching to UUIDs
|
|
return +id;
|
|
}
|
|
|