Skip to content

Commit 2ca8c84

Browse files
committed
accept file buffers as well as filepath strings
1 parent 1bdbd5b commit 2ca8c84

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/tools.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ var tools = {};
88
*/
99
tools._parseHex = function(file) {
1010
try {
11-
var data = fs.readFileSync(file, {
12-
encoding: 'utf8'
13-
});
11+
var data;
12+
if (typeof file === 'string') {
13+
data = fs.readFileSync(file, {
14+
encoding: 'utf8'
15+
});
16+
} else {
17+
data = file;
18+
}
19+
1420
return intelhex.parse(data).data;
1521
} catch (error) {
1622
return error;

0 commit comments

Comments
 (0)