Skip to content

Commit cd65202

Browse files
committed
Removed jspm, introduced gulp for building
1 parent 18bf813 commit cd65202

File tree

10 files changed

+1047
-142
lines changed

10 files changed

+1047
-142
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
jspm_packages
1+
node_modules/
2+
build/
3+
.DS_Store
4+
test_build/

README.md

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
Experiment to reproduce erlang style processes in browser. The api follows the one from Erlang. All are found on the `ProcessSystem` class
2-
3-
4-
### Running Examples
5-
6-
* `jspm install`
7-
* `python -m SimpleHTTPServer 8000`
8-
9-
Going to `localhost:8000` will show links to examples.
1+
Experiment to reproduce Erlang style processes in browser. The api follows the one from Erlang. All are found on the `ProcessSystem` class
102

113
One example is an implementation of a GenServer. The other example is 2 processes talking
124
to each other.
@@ -15,38 +7,38 @@ to each other.
157

168
* First, import the ProcessSystem create a new instance of one.
179
```javascript
18-
import { ProcessSystem } from "processes";
10+
const ProcessSystem = require("erlang-processes");
1911
let system = new ProcessSystem();
2012
```
21-
22-
* Now you can spawn processes using the system.
13+
14+
* Now you can spawn processes using the system.
2315

2416
A process will switch to other processes when yield is used and will run until it completes.
25-
17+
2618
```javascript
2719
var pid1 = system.spawn(function*(){
2820
while(true){
29-
21+
3022
yield system.receive(function(value){
3123
return console.log(value);
3224
});
33-
25+
3426
system.send(pid2, "message from 1");
3527
}
3628
});
37-
29+
3830
system.register("Sally", pid1);
39-
31+
4032
var pid2 = system.spawn(function*(){
4133
while(true){
4234
system.send("Sally", "message from 2");
43-
35+
4436
yield system.receive(function(value){
4537
return console.log(value);
4638
});
4739
}
4840
});
49-
41+
5042
```
5143

5244
### API
@@ -88,13 +80,13 @@ to each other.
8880
* `init(args)` - Must return an array containing a symbol and the initial state
8981
* `handle_call(action, from, state)` - Called when `GenServer.call` is called. This function is given the action, the pid of the calling process, and the current state. Must return `[reply, return_value, new_state]` where reply is a symbol ,usually `Symbol.for("reply"), the value to return to the process, and lastly, the new state of the GenServer.
9082
* `handle_cast(action, state)` - Called when `GenServer.cast` is called. his function is given the action, and the current state. Must return `[reply, return_value, new_state]` where reply is a symbol ,usually `Symbol.for("noreply")`, and lastly, the new state of the GenServer.
91-
83+
9284
#### GenServer Example
9385

9486
An example of a Stack using a GenServer
9587

9688
```javascript
97-
import { ProcessSystem, GenServer } from "processes";
89+
const ProcessSystem = require("erlang-processes");
9890
self.system = self.system || new ProcessSystem();
9991

10092
const Stack = {
@@ -124,4 +116,4 @@ self.system.spawn(function*(){
124116
let c = yield* ProcessSystem.run(GenServer.call, [pid, "pop"]);
125117
console.log(c); // "world"
126118
});
127-
```
119+
```

config.js

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

gulpfile.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
const gulp = require('gulp');
2+
const mocha = require('gulp-mocha');
3+
const babel = require('gulp-babel');
4+
const eslint = require('gulp-eslint');
5+
const sourcemaps = require('gulp-sourcemaps');
6+
const rollup = require('gulp-rollup');
7+
const rename = require("gulp-rename");
8+
const del = require('del');
9+
10+
const testPath = './test/**/*.spec.js';
11+
const libPath = './src/**/*.js';
12+
const buildPath = './build/**/*.js';
13+
14+
gulp.task('remove_flow', function() {
15+
return gulp.src([libPath])
16+
.pipe(babel({
17+
sourceMaps: false,
18+
presets: ["react"]
19+
}))
20+
.pipe(gulp.dest('./build'));
21+
});
22+
23+
gulp.task('rollup', ['remove_flow'], function() {
24+
return gulp.src('./build/index.js', {read: false})
25+
.pipe(rollup())
26+
.pipe(gulp.dest('./lib'));
27+
});
28+
29+
gulp.task('babel', ['rollup'], function() {
30+
return gulp.src('./lib/index.js')
31+
.pipe(sourcemaps.init())
32+
.pipe(babel({
33+
"presets": ["es2015", "react", "stage-0"]
34+
}))
35+
.pipe(sourcemaps.write())
36+
.pipe(rename("processes.js"))
37+
.pipe(gulp.dest('./lib'));
38+
});
39+
40+
41+
gulp.task('build', ['babel'], function() {
42+
return del.sync(['./build', './lib/index.js']);
43+
});
44+
45+
gulp.task('build_test', function() {
46+
return gulp.src([testPath])
47+
.pipe(sourcemaps.init())
48+
.pipe(babel({
49+
"presets": ["es2015", "react", "stage-0"]
50+
}))
51+
.pipe(sourcemaps.write())
52+
.pipe(gulp.dest('./test_build'));
53+
});
54+
55+
gulp.task('lint', function () {
56+
return gulp.src([libPath, testPath])
57+
.pipe(eslint())
58+
.pipe(eslint.format())
59+
});
60+
61+
gulp.task('test', ['lint', 'build', 'build_test'], function () {
62+
return gulp.src('./test_build/**/*.spec.js')
63+
.pipe(mocha({reporter: 'nyan'}));
64+
});

index.html

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

0 commit comments

Comments
 (0)