Skip to content

Commit a26e52b

Browse files
committed
nodejs module
1 parent fbf75f0 commit a26e52b

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "trianglify",
3+
"version": "0.0.1",
4+
"description": "Trianglify is a javascript library for generating colorful triangle meshes that can be used as SVG images and CSS backgrounds.",
5+
"main": "trianglify.js",
6+
"dependencies": {
7+
"d3": "3",
8+
"jsdom": "0.10",
9+
"xmldom": "0.1",
10+
"btoa": "1"
11+
},
12+
"directories": {
13+
"example": "examples"
14+
},
15+
"repository": {
16+
"type": "git",
17+
"url": "git://github.com/qrohlf/trianglify.git"
18+
},
19+
"keywords": [
20+
"svg",
21+
"d3.js",
22+
"visualization"
23+
],
24+
"author": "Quinn Rohlf <qr@qrohlf.com>",
25+
"license": "GPLv3",
26+
"bugs": {
27+
"url": "https://github.com/qrohlf/trianglify/issues"
28+
},
29+
"homepage": "https://github.com/qrohlf/trianglify"
30+
}

trianglify.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ function Trianglify(options) {
1616
}
1717
}
1818

19+
//nodejs stuff
20+
if (typeof module !== 'undefined' && module.exports) {
21+
d3 = require("d3");
22+
document = require("jsdom").jsdom();
23+
XMLSerializer = require("xmldom").XMLSerializer;
24+
btoa = require('btoa');
25+
module.exports = Trianglify;
26+
}
27+
1928
Trianglify.randomColor = function() {
2029
var keys = Object.keys(colorbrewer);
2130
var palette = colorbrewer[keys[Math.floor(Math.random()*keys.length)]];

0 commit comments

Comments
 (0)