Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/binary_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ var vm = require("vm");

var Context = require("./context").Context;

if (typeof window !== 'undefined')
window.Buffer = Buffer

var PRIMITIVE_TYPES = {
UInt8: 1,
UInt16LE: 2,
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
"devDependencies": {
"istanbul": "^0.4.5",
"mocha": "^3.5.3",
"prettier": "^1.9.2"
"opn-cli": "^3.1.0",
"prettier": "^1.9.2",
"webpack": "^4.6.0",
"webpack-cli": "^2.0.15"
},
"scripts": {
"fmt": "npx prettier --write '{lib,test,example}/**/*.js'",
"check-fmt": "npx prettier --list-different '{lib,test,example}/**/*.js'",
"test": "npx mocha --reporter spec",
"cover": "npx istanbul cover --report html node_modules/.bin/_mocha"
"cover": "npx istanbul cover --report html node_modules/.bin/_mocha",
"test-webpack": "npx webpack --config test/browser/webpack.config.js && opn test/browser/run-mocha.html"
},
"keywords": [
"binary",
Expand All @@ -36,6 +40,6 @@
"bugs": "http://github.com/keichi/binary-parser/issues",
"dependencies": {},
"engines": {
"node": ">=5.10.0"
"node": ">=5.10.0"
}
}
1 change: 1 addition & 0 deletions test/browser/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bundle.js*
2 changes: 2 additions & 0 deletions test/browser/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require('../primitive_parser')
require('../composite_parser')
18 changes: 18 additions & 0 deletions test/browser/run-mocha.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<html>
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link href="../../node_modules/mocha/mocha.css" rel="stylesheet" />
</head>
<body>
<div id="mocha"></div>
<script src="../../node_modules/mocha/mocha.js"></script>
<script>mocha.setup('bdd')</script>
<script src="bundle.js"></script>
<script>
mocha.fullTrace();
//mocha.checkLeaks();
mocha.run();
</script>
</body>
</html>
10 changes: 10 additions & 0 deletions test/browser/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const path = require('path')

module.exports = {
entry: path.resolve(__dirname, 'entry.js'),
output: {
path: __dirname,
filename: 'bundle.js',
},
mode: 'development',
}