### Table of Contents - [constructor](#constructor) - [addNodeToCheck](#addnodetocheck) - [getDestPort](#getdestport) - [getInstance](#getinstance) - [createInstance](#createinstance) - [createStateRoot](#createstateroot) - [registerContainer](#registercontainer) ## constructor [index.js:16-22](https://github.com/primea/js-primea-hypervisor/blob/317d79e49cb56dd81cb9c94072cd24ad6a825757/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/317d79e49cb56dd81cb9c94072cd24ad6a825757/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/317d79e49cb56dd81cb9c94072cd24ad6a825757/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:73-83](https://github.com/primea/js-primea-hypervisor/blob/317d79e49cb56dd81cb9c94072cd24ad6a825757/index.js#L73-L83 "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:95-119](https://github.com/primea/js-primea-hypervisor/blob/317d79e49cb56dd81cb9c94072cd24ad6a825757/index.js#L95-L119 "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:127-134](https://github.com/primea/js-primea-hypervisor/blob/317d79e49cb56dd81cb9c94072cd24ad6a825757/index.js#L127-L134 "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:142-147](https://github.com/primea/js-primea-hypervisor/blob/317d79e49cb56dd81cb9c94072cd24ad6a825757/index.js#L142-L147 "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