c3-exporter
Advanced tools
Comparing version 0.0.4 to 1.0.0
@@ -0,1 +1,7 @@ | ||
## 1.0.0 (2017-4-28) | ||
##### New Features | ||
* **render:** Change output to Buffer ([6dc36630](https://github.com/lgaticaq/c3-exporter/commit/6dc36630fc8fe22e2b2ed42feea3cb8e3428335f)) | ||
#### 0.0.4 (2017-4-26) | ||
@@ -2,0 +8,0 @@ |
@@ -23,2 +23,2 @@ const c3Exporter = require('c3-exporter') | ||
await c3Exporter(options) | ||
await c3Exporter(options) // A Buffer with content of image chart |
19
index.js
@@ -8,2 +8,3 @@ 'use strict' | ||
const os = require('os') | ||
const fs = require('fs') | ||
@@ -27,3 +28,19 @@ const render = (options, size = '320x320') => { | ||
} else { | ||
resolve(output) | ||
const chunks = [] | ||
let totalLength = 0 | ||
const fileStream = fs.createReadStream(output) | ||
fileStream.on('data', chunk => { | ||
chunks.push(chunk) | ||
totalLength += chunk.length | ||
}) | ||
fileStream.on('end', () => { | ||
fs.unlink(output, err => { | ||
if (err) { | ||
reject(err) | ||
} else { | ||
resolve(Buffer.concat(chunks, totalLength)) | ||
} | ||
}) | ||
}) | ||
fileStream.on('error', reject) | ||
} | ||
@@ -30,0 +47,0 @@ }) |
{ | ||
"name": "c3-exporter", | ||
"version": "0.0.4", | ||
"version": "1.0.0", | ||
"description": "Export c3 charts to png", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -41,5 +41,10 @@ # c3-exporter | ||
} | ||
const size = '320x320' // optional. Default is '320x320' | ||
c3Exporter(options).then(chart => { | ||
console.log(chart) // /tmp/user/chart-1954112493.png | ||
c3Exporter(options, size).then(content => { | ||
console.log(content) // A Buffer with content of image chart | ||
fs.writeFile('chart.png', content, err => { | ||
if (err) throw err | ||
console.log('Chart saved!') | ||
}) | ||
}).catch(console.error) | ||
@@ -46,0 +51,0 @@ ``` |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
10601
197
0
55
2