Skip to content

Commit f9a307e

Browse files
committed
Isomorphic: added support for browser
1 parent 060923c commit f9a307e

File tree

11 files changed

+42
-33
lines changed

11 files changed

+42
-33
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ jspm_packages
5252
.idea
5353
.idea/*.xml
5454
.DS_Store
55+
56+
dist

examples/basic/index.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

examples/basic/index.html renamed to examples/browser/index.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77
<title>OpenBCI Utilities</title>
88
</head>
99
<body>
10-
<button id="connect">
11-
Print something
12-
</button>
1310
<pre>See data in the console</pre>
14-
<script src="../../dist/openbciutilities.var.js"></script>
11+
<script src="../../dist/openbci-utilities.var.js"></script>
1512
<script src="./index.js"></script>
1613
</body>
1714
</html>

examples/browser/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
console.log(OpenBCIUtilities);

examples/node/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
const OpenBCIUtilities = require('../..');
3+
const { Constansts, Debug, Utilities } = require('../..');
4+
5+
console.log('OpenBCIUtilities', OpenBCIUtilities);
6+
console.log('Constansts', Constansts);
7+
console.log('Debug', Debug);
8+
console.log('Utilities', Utilities);

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "openbci-utilities",
33
"version": "0.3.0",
44
"description": "The official utility package of Node.js SDK for the OpenBCI Biosensor Boards.",
5-
"main": "dist/openbciutilities.umd.js",
5+
"main": "dist/openbci-utilities.umd.js",
66
"module": "src/index.js",
77
"scripts": {
88
"build": "webpack",
@@ -12,7 +12,9 @@
1212
"test-lint": "semistandard | snazzy",
1313
"test-cov": "istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec && codecov"
1414
},
15-
"files": ["dist"],
15+
"files": [
16+
"dist"
17+
],
1618
"keywords": [
1719
"openbci",
1820
"openbci-node",

src/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
module.exports.Constants = require('./openBCIConstants');
2-
module.exports.Debug = require('./openBCIDebug');
3-
module.exports.Utilities = require('./openBCIUtilities');
1+
import Constants from './openBCIConstants';
2+
import * as Debug from './openBCIDebug';
3+
import Utilities from './openBCIUtilities';
4+
5+
export default {
6+
Constants,
7+
Debug,
8+
Utilities
9+
};

src/openBCIConstants.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* OpenBCI Board
55
*/
66
'use strict';
7-
const _ = require('lodash');
8-
const Buffer = require('buffer/').Buffer;
7+
import _ from 'lodash';
8+
import { Buffer } from 'buffer/';
99

1010
/** Turning channels off */
1111
const obciChannelOff1 = '1';
@@ -1276,7 +1276,6 @@ const constantsModule = {
12761276
OBCIRegisterQuerySizeCytonFirmwareV3: obciRegisterQuerySizeCytonFirmwareV3,
12771277
OBCIRegisterQuerySizeCytonDaisyFirmwareV3: obciRegisterQuerySizeCytonDaisyFirmwareV3
12781278
};
1279-
module.exports = constantsModule;
12801279

12811280
/**
12821281
* @description To add a usability abstraction layer above channel setting commands. Due to the
@@ -1894,3 +1893,5 @@ function isPeripheralGanglion (peripheral) {
18941893
}
18951894
return false;
18961895
}
1896+
1897+
export default constantsModule;

src/openBCIDebug.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
const Buffer = require('buffer/').Buffer;
21

3-
module.exports = {
4-
debugBytes
5-
};
2+
import { Buffer } from 'buffer/';
63

74
/**
85
* @description Output passed bytes on the console as a hexdump, if enabled
96
* @param prefix - label to show to the left of bytes
107
* @param data - bytes to output, a buffer or string
118
* @private
129
*/
13-
function debugBytes (prefix, data) {
10+
export function debugBytes (prefix, data) {
1411
if (typeof data === 'string') data = new Buffer(data);
1512

1613
console.log('Debug bytes:');

src/openBCIUtilities.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
2-
const gaussian = require('gaussian');
3-
const k = require('./openBCIConstants');
4-
const StreamSearch = require('streamsearch');
5-
const Buffer = require('buffer/').Buffer;
6-
const _ = require('lodash');
2+
3+
import gaussian from 'gaussian';
4+
import k from './openBCIConstants';
5+
import StreamSearch from 'streamsearch';
6+
import { Buffer } from 'buffer/';
7+
import _ from 'lodash';
78

89
/** Constants for interpreting the EEG data */
910
// Reference voltage for ADC in ADS1299.
@@ -946,8 +947,6 @@ function decompressDeltas19Bit (buffer) {
946947
return receivedDeltas;
947948
}
948949

949-
module.exports = utilitiesModule;
950-
951950
function newImpedanceObject (channelNumber) {
952951
return {
953952
channel: channelNumber,
@@ -2146,3 +2145,5 @@ function makeTailByteFromPacketType (type) {
21462145
function isStopByte (byte) {
21472146
return (byte & 0xF0) === k.OBCIByteStop;
21482147
}
2148+
2149+
export default utilitiesModule;

0 commit comments

Comments
 (0)