cic-internal-integration/apps/cic-meta/src/custom.ts

28 lines
591 B
TypeScript
Raw Normal View History

2021-05-21 11:42:08 +02:00
import {Addressable, mergeKey, Syncable} from "@cicnet/crdt-meta";
class Custom extends Syncable implements Addressable {
name: string
value: Object
constructor(name:string, v:Object={}) {
super('', v);
Custom.toKey(name).then((cid) => {
this.id = cid;
2021-06-07 18:11:03 +02:00
this.name = name;
2021-05-21 11:42:08 +02:00
});
}
public static async toKey(item:string, identifier: string = ':cic.custom') {
return await mergeKey(Buffer.from(item), Buffer.from(identifier));
}
public key(): string {
return this.id;
}
}
export {
Custom,
}