UNPKG

golos-lib-js

Version:

Golos-js the JavaScript library with API for GOLOS blockchain

45 lines (44 loc) 974 B
"use strict"; var _my_hash = require("./my_hash.js"); class Libs { constructor(rootObj) { this.rootObj = rootObj; rootObj.libs = this; } add = lib => { const { rootObj } = this; const { libName } = lib; if (!libName) throw new Error('Lib should have field libName'); if (!libName.split) throw new Error('libName should be string'); if (rootObj.libs[libName]) { rootObj.libs[libName] = lib; return false; } else { rootObj.libs[libName] = lib; return true; } }; remove = libOrName => { const { rootObj } = this; let libName = libOrName; if (!libName.split) { libName = libName.libName; if (!libName) throw new Error('Lib should have field libName'); } if (rootObj.libs[libName]) { delete rootObj.libs[libName]; return true; } return false; }; libHash = () => { return _my_hash.MY_HASH; }; } module.exports = Libs;