33 lines
820 B
JavaScript
33 lines
820 B
JavaScript
|
class Phenomenon {
|
||
|
/**
|
||
|
* Name of the phenomenon
|
||
|
*/
|
||
|
get Name() {
|
||
|
return this._decoder.decode(new Uint8Array(this._ptr.slice(0, 64)));
|
||
|
}
|
||
|
set Name(v) {
|
||
|
this._data.set(this._encoder.encode(v), 0);
|
||
|
}
|
||
|
/**
|
||
|
* get the struct representation of the object
|
||
|
*/
|
||
|
get bytes() {
|
||
|
return new Uint8Array(this._ptr);
|
||
|
}
|
||
|
/**
|
||
|
* constructor
|
||
|
*/
|
||
|
constructor(init = {}, ptr = undefined) {
|
||
|
this._size = 64;
|
||
|
this._ptr = ptr.buffer || new ArrayBuffer(this._size);
|
||
|
this._data = new DataView(this._ptr);
|
||
|
|
||
|
this._encoder = new TextEncoder();
|
||
|
this._decoder = new TextDecoder();
|
||
|
for (const key of Object.keys(init)) {
|
||
|
this[key] = init[key];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default Phenomenon
|