Skip to content

Commit

Permalink
Merge pull request #9 from CorayThan/master
Browse files Browse the repository at this point in the history
Adding embedded type definition files.
  • Loading branch information
anvaka committed Dec 7, 2018
2 parents 6258f6d + d5bb7f5 commit 563c61b
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Type definitions for ngraph.graph v0.0.14
// Project: https://github.com/anvaka/ngraph.graph
// Definitions by: Nathan Westlake <https://github.com/CorayThan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

declare module "ngraph.graph" {

type NodeId = string | number

interface Link {
id: string,
fromId: NodeId,
toId: NodeId,
data: any
}

interface Node {
id: NodeId,
links: Link[],
data: any
}

interface Coordinates {
x: number,
y: number
}

interface Graph {
addNode: (node: NodeId, nodeCoordinates: Coordinates) => Node
addLink: (from: NodeId, to: NodeId, data?: any) => Link
removeLink: (link: Link) => boolean
removeNode: (nodeId: NodeId) => boolean
getNode: (nodeId: NodeId) => Node | undefined
hasNode: (nodeId: NodeId) => Node | undefined
getLink: (fromNodeId: NodeId, toNodeId: NodeId) => Link | null
hasLink: (fromNodeId: NodeId, toNodeId: NodeId) => Link | null
getNodesCount: () => number
getLinksCount: () => number
getLinks: Link[]
forEachNode: (callbackPerNode: (node: Node) => void) => void
forEachLinkedNode: (nodeId: NodeId, callbackPerNode: (node: Node, link: Link) => void, oriented: boolean) => void
forEachLink: (callbackPerLink: (link: Link) => void) => void
beginUpdate: () => void
endUpdate: () => void
clear: () => void
}

export default function createGraph(options?: { multigraph: boolean }): Graph

}

0 comments on commit 563c61b

Please sign in to comment.