### Table of Contents - [constructor](#constructor) - [addNodeToCheck](#addnodetocheck) - [getDestPort](#getdestport) - [getInstance](#getinstance) - [createInstance](#createinstance) - [createStateRoot](#createstateroot) - [registerContainer](#registercontainer) - [getHashFromObj](#gethashfromobj) ## constructor [index.js:16-22](https://github.com/primea/js-primea-hypervisor/blob/b507f49239a73767abbee979b4e637a6ca469764/index.js#L16-L22 "Source code on GitHub") The Hypervisor manages the container instances by instantiating them and destorying them when possible. It also facilitates localating Containers **Parameters** - `dag` **Graph** an instance of [ipfs.dag](https://github.com/ipfs/interface-ipfs-core/tree/master/API/dag#dag-api) - `state` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** the starting state (optional, default `{}`) ## addNodeToCheck [index.js:28-30](https://github.com/primea/js-primea-hypervisor/blob/b507f49239a73767abbee979b4e637a6ca469764/index.js#L28-L30 "Source code on GitHub") add a potaintail node in the state graph to check for garbage collection **Parameters** - `id` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** ## getDestPort [index.js:37-43](https://github.com/primea/js-primea-hypervisor/blob/b507f49239a73767abbee979b4e637a6ca469764/index.js#L37-L43 "Source code on GitHub") given a port, this finds the corridsponeding endpoint port of the channel **Parameters** - `port` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** ## getInstance [index.js:68-78](https://github.com/primea/js-primea-hypervisor/blob/b507f49239a73767abbee979b4e637a6ca469764/index.js#L68-L78 "Source code on GitHub") gets an existsing container instances **Parameters** - `id` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the containers ID Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** ## createInstance [index.js:90-114](https://github.com/primea/js-primea-hypervisor/blob/b507f49239a73767abbee979b4e637a6ca469764/index.js#L90-L114 "Source code on GitHub") creates an new container instances and save it in the state **Parameters** - `type` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the type of container to create - `code` **any** - `entryPorts` **[array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** (optional, default `[]`) - `id` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `{nonce:0,parent:null}`) - `id.nonce` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** - `id.parent` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** ## createStateRoot [index.js:122-129](https://github.com/primea/js-primea-hypervisor/blob/b507f49239a73767abbee979b4e637a6ca469764/index.js#L122-L129 "Source code on GitHub") creates a state root starting from a given container and a given number of ticks **Parameters** - `ticks` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the number of ticks at which to create the state root Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** ## registerContainer [index.js:137-142](https://github.com/primea/js-primea-hypervisor/blob/b507f49239a73767abbee979b4e637a6ca469764/index.js#L137-L142 "Source code on GitHub") regirsters a container with the hypervisor **Parameters** - `type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the type - `Constructor` **Class** a Class for instantiating the container - `args` **any** any args that the contructor takes ## getHashFromObj [index.js:149-151](https://github.com/primea/js-primea-hypervisor/blob/b507f49239a73767abbee979b4e637a6ca469764/index.js#L149-L151 "Source code on GitHub") get a hash from a POJO **Parameters** - `obj` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)**