Permalink
Browse files

ENH semistandard lint

  • Loading branch information...
1 parent e3061c0 commit 3e99a77e88033b902523ba4cd0043c8fcf0a357c @aj-ptw aj-ptw committed Oct 3, 2016
Showing with 11,428 additions and 11,613 deletions.
  1. +1 −0 .eslintrc
  2. +2 −1 .npmignore
  3. +1 −0 README.md
  4. +6 −1 changelog.md
  5. +55 −60 examples/timeSync/timeSync.js
  6. +2,191 −2,219 openBCIBoard.js
  7. +1,042 −1,044 openBCIConstants.js
  8. +1,085 −1,101 openBCISample.js
  9. +327 −330 openBCISimulator.js
  10. +22 −3 package.json
  11. +1,165 −1,164 test/OpenBCIConstants-test.js
  12. +1,341 −1,322 test/OpenBCISample-test.js
  13. +575 −595 test/openBCIBoard-Impedance-test.js
  14. +2,950 −2,964 test/openBCIBoard-test.js
  15. +665 −674 test/openBCISimulator-test.js
  16. +0 −135 test_mocks/openbci-hardware.js
View
@@ -0,0 +1 @@
+{"extends": ["standard"], "parser": "babel-eslint"}
View
@@ -17,4 +17,5 @@ node_modules
.DS_Store
public
myOutput.txt
-*.tgz
+*.tgz
+openBCISerialFormat
View
@@ -4,6 +4,7 @@
[![codecov](https://codecov.io/gh/OpenBCI/OpenBCI_NodeJS/branch/master/graph/badge.svg)](https://codecov.io/gh/OpenBCI/OpenBCI_NodeJS)
[![Dependency Status](https://david-dm.org/OpenBCI/OpenBCI_NodeJS.svg)](https://david-dm.org/OpenBCI/OpenBCI_NodeJS)
[![npm](https://img.shields.io/npm/dm/openbci.svg?maxAge=2592000)](http://npmjs.com/package/openbci)
+[![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-square)](https://github.com/Flet/semistandard)
# OpenBCI Node.js SDK
View
@@ -1,3 +1,9 @@
+# 1.4.0
+
+### Enhancements
+
+* Implement and adapt semi-standard code style. Closes #83
+
# 1.3.3
### New Features
@@ -9,7 +15,6 @@
* Fixed log statement on impedance setting function
* Remove event emitter with time sync on reject of sync clock full
-
# 1.3.2
### Enhancements
@@ -11,83 +11,78 @@ var OpenBCIBoard = require('openbci').OpenBCIBoard;
var ourBoard = new OpenBCIBoard({});
-const resyncPeriodMin = 5; // re sync every five minutes
-const secondsInMinute = 60;
var sampleRate = 250; // Default to 250, ALWAYS verify with a call to `.sampleRate()` after 'ready' event!
var timeSyncPossible = false;
ourBoard.autoFindOpenBCIBoard().then(portName => {
- if(portName) {
- /**
- * Connect to the board with portName
- * i.e. ourBoard.connect(portName).....
- */
- // Call to connect
- ourBoard.connect(portName).then(() => {
- console.log(`connected`);
-
- })
- .catch(err => {
- console.log(`connect: ${err}`);
- });
- } else {
- /**Unable to auto find OpenBCI board*/
- }
+ if (portName) {
+ /**
+ * Connect to the board with portName
+ * i.e. ourBoard.connect(portName).....
+ */
+ // Call to connect
+ ourBoard.connect(portName).then(() => {
+ console.log(`connected`);
+ })
+ .catch(err => {
+ console.log(`connect: ${err}`);
+ });
+ } else {
+ /** Unable to auto find OpenBCI board */
+ }
});
var readyFunc = () => {
- // Get the sample rate after 'ready'
- sampleRate = ourBoard.sampleRate();
- // Find out if you can even time sync, you must be using v2 and this is only accurate after a `.softReset()` call which is called internally on `.connect()`. We parse the `.softReset()` response for the presence of firmware version 2 properties.
- timeSyncPossible = ourBoard.usingVersionTwoFirmware();
-
- if (timeSyncPossible) {
- ourBoard.streamStart()
- .catch(err => {
- console.log(`stream start: ${err}`);
- });
- } else {
- killFunc();
- }
+ // Get the sample rate after 'ready'
+ sampleRate = ourBoard.sampleRate();
+ // Find out if you can even time sync, you must be using v2 and this is only accurate after a `.softReset()` call which is called internally on `.connect()`. We parse the `.softReset()` response for the presence of firmware version 2 properties.
+ timeSyncPossible = ourBoard.usingVersionTwoFirmware();
-}
+ if (timeSyncPossible) {
+ ourBoard.streamStart()
+ .catch(err => {
+ console.log(`stream start: ${err}`);
+ });
+ } else {
+ killFunc();
+ }
+};
var killFunc = () => {
- ourBoard.disconnect()
+ ourBoard.disconnect()
.then(() => {
- process.kill();
+ process.kill();
});
-}
+};
var sampleFunc = sample => {
- // Resynchronize every every second
- if (sample._count % (sampleRate * 1) === 0) {
- ourBoard.syncClocksFull()
- .then(syncObj => {
- // Sync was successful
- if (syncObj.valid) {
- // Log the object to check it out!
- console.log(`timeOffset`,syncObj.timeOffsetMaster);
- } else {
- // Retry it
- console.log(`Was not able to sync... retry!`);
- }
- });
- }
-
- if (sample.timeStamp) { // true after the first successful sync
- if (sample.timeStamp < 10 * 60 * 60 * 1000) { // Less than 10 hours
- console.log(`Bad time sync ${sample.timeStamp}`);
+ // Resynchronize every every second
+ if (sample._count % (sampleRate * 1) === 0) {
+ ourBoard.syncClocksFull()
+ .then(syncObj => {
+ // Sync was successful
+ if (syncObj.valid) {
+ // Log the object to check it out!
+ console.log(`timeOffset`, syncObj.timeOffsetMaster);
+ } else {
+ // Retry it
+ console.log(`Was not able to sync... retry!`);
}
- }
+ });
+ }
- // Stop after one minute
- if (sample._count > sampleRate * 60) {
- killFunc();
+ if (sample.timeStamp) { // true after the first successful sync
+ if (sample.timeStamp < 10 * 60 * 60 * 1000) { // Less than 10 hours
+ console.log(`Bad time sync ${sample.timeStamp}`);
}
+ }
-}
+ // Stop after one minute
+ if (sample._count > sampleRate * 60) {
+ killFunc();
+ }
+};
// Subscribe to your functions
-ourBoard.on('ready',readyFunc);
-ourBoard.on('sample',sampleFunc);
+ourBoard.on('ready', readyFunc);
+ourBoard.on('sample', sampleFunc);
Oops, something went wrong.

0 comments on commit 3e99a77

Please sign in to comment.