Integration with TypeScript Download code
Installation
If you wish to use Ogma within a TypeScript application, we suggest you adding it as a dependency to your project. This can be done in two ways:
Using tar.gz
Download Ogma as ogma.tar.gz archive from github and put it in your project folder. Then install it, using npm
npm install --save path/to/ogma-release.tar.gz
Through npm
If you are developing locally and your account has access to this release repository, you can also install directly.
npm install --save linkurious/ogma-release
Usage
import Ogma from 'ogma';
const ogma = new Ogma();
ogma.addNode({id: 0});
You can import some other interfaces from the file if you wish to use them in your code, e.g:
import Ogma, {Node, Color} from 'ogma';
function getColor(node: Node) : Color {
return node.getAttribute('color');
}
const ogma = new Ogma();
const node = ogma.addNode({id: 0, attributes: { color: 'blue' }});
console.log(getColor(node));