Skip to content

Commit

Permalink
Merge pull request #34 from neurosity/ts
Browse files Browse the repository at this point in the history
TypeScript migration
  • Loading branch information
alexcastillo authored Oct 23, 2020
2 parents 384e1b5 + 30bf515 commit 6ea95a6
Show file tree
Hide file tree
Showing 89 changed files with 13,275 additions and 539 deletions.
6 changes: 0 additions & 6 deletions .babelrc

This file was deleted.

6 changes: 6 additions & 0 deletions .esdoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"source": "./src",
"destination": "./docs",
"plugins": [
{
"name": "esdoc-typescript-plugin",
"option": {
"enable": true
}
},
{
"name": "esdoc-standard-plugin",
"option": {
Expand Down
241 changes: 0 additions & 241 deletions .eslintrc.json

This file was deleted.

5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ node_modules
npm-debug.log
.idea
dist
package-lock.json
build
.DS_Store
*/.DS_Store
docs
docs
.cache
.env
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,41 @@ Get started by installing the library:
npm install @neurosity/pipes
```

## Getting started

```bash
npm install @neurosity/pipes
```

Then import the module

##### ESM

```js
import { epoch } from "@neurosity/pipes";
```

##### Node

```js
const { epoch } = require("@neurosity/pipes");
```

##### Browser

```html
<script type="module">
import { epoch } from "./node_modules/neurosity/pipes/esm/eeg-pipes.mjs";
</script>
<script nomodule src="./node_modules/neurosity/pipes/browser/eeg-pipes.js">
```
##### Electron
```js
import { epoch } from "@neurosity/pipes/dist/electron";
```
## Usage
An Observable of EEG data is required to work with pipes. This can be done by using `fromEvent` from RxJS in order to push callback events into an Observable stream.
Expand All @@ -42,11 +77,7 @@ const eeg$ = fromEvent(bci, "data");
Now we have an Observable of EEG data that support Pipeable operators.
```js
eeg$
.pipe
// ...
()
.subscribe();
eeg$.pipe().subscribe();
```
The following are some libraries that provide EEG as RxJS observables out of the box:
Expand Down Expand Up @@ -201,4 +232,4 @@ A PSD represents the absolute power of different frequency bins in an Epoch of E
## Generating documentation
To generate the docs, run `yarn esdoc`
To generate the docs, run `npm run build:docs`
2 changes: 1 addition & 1 deletion examples/addInfo.js → examples/addInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { createEEG, addInfo } = require("../");
import { createEEG, addInfo } from "../src";

const eeg1$ = createEEG().pipe(addInfo({ samplingRate: 250 }));

Expand Down
2 changes: 1 addition & 1 deletion examples/createEEG.js → examples/createEEG.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { createEEG } = require("..");
import { createEEG } from "../src";

// defaults to muse-lsl.csv
const eeg$ = createEEG();
Expand Down
8 changes: 4 additions & 4 deletions examples/epoching.js → examples/epoching.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { createEEG, addInfo, epoch } = require("..");
import { createEEG, addInfo, epoch } from "../src";

const eeg1$ = createEEG().pipe(
addInfo({ samplingRate: 256 }),
Expand All @@ -15,9 +15,9 @@ const eeg3$ = createEEG({ samplingRate: 1000 }).pipe(
);

// Should leave info.samplingRate = 128 intact
const eeg4$ = createEEG({samplingRate: 128}).pipe(
addInfo({samplingRate: 128}),
epoch({duration: 256, interval: 250 }),
const eeg4$ = createEEG({ samplingRate: 128 }).pipe(
addInfo({ samplingRate: 128 }),
epoch({ duration: 256, interval: 250 })
);

eeg2$.subscribe(console.log);
Loading

0 comments on commit 6ea95a6

Please sign in to comment.