### Table of Contents - [constructor](#constructor) - [addNodeToCheck](#addnodetocheck) - [getDestPort](#getdestport) - [getInstance](#getinstance) - [createInstance](#createinstance) - [createStateRoot](#createstateroot) - [registerContainer](#registercontainer) ## constructor [index.js:16-29](https://github.com/primea/js-primea-hypervisor/blob/add087e94722a8b77695d21eca754a562d7e79f5/index.js#L16-L29 "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 `{'/':Tree.emptyTreeState}`) ## addNodeToCheck [index.js:35-37](https://github.com/primea/js-primea-hypervisor/blob/add087e94722a8b77695d21eca754a562d7e79f5/index.js#L35-L37 "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:44-51](https://github.com/primea/js-primea-hypervisor/blob/add087e94722a8b77695d21eca754a562d7e79f5/index.js#L44-L51 "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:105-116](https://github.com/primea/js-primea-hypervisor/blob/add087e94722a8b77695d21eca754a562d7e79f5/index.js#L105-L116 "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:128-165](https://github.com/primea/js-primea-hypervisor/blob/add087e94722a8b77695d21eca754a562d7e79f5/index.js#L128-L165 "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 - `message` (optional, default `new Message()`) - `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)** - `code` **any** - `entryPorts` **[array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** ## createStateRoot [index.js:187-196](https://github.com/primea/js-primea-hypervisor/blob/add087e94722a8b77695d21eca754a562d7e79f5/index.js#L187-L196 "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:204-209](https://github.com/primea/js-primea-hypervisor/blob/add087e94722a8b77695d21eca754a562d7e79f5/index.js#L204-L209 "Source code on GitHub") regirsters a container with the hypervisor **Parameters** - `Constructor` **Class** a Class for instantiating the container - `args` **any** any args that the contructor takes - `typeId` **interger** the container's type identification ID (optional, default `Constructor.typeId`)