Skip to content

Commit

Permalink
Migrate CI to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
earldouglas committed Jan 1, 2020
1 parent 837bc2b commit 76f9c48
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 42 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: build

on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [8.x, 10.x, 12.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm install
npm ci
npm run build --if-present
npm test
npm run coverage
npm run coveralls
env:
CI: true
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Teep

[![Build Status](https://travis-ci.org/earldouglas/teep.svg?branch=master)](https://travis-ci.org/earldouglas/teep)
[![Coverage Status](https://coveralls.io/repos/earldouglas/teep/badge.svg?branch=master&service=github)](https://coveralls.io/github/earldouglas/teep?branch=master)
![Build Status](https://github.com/earldouglas/teep/workflows/build/badge.svg)
[![Coverage Status](https://coveralls.io/repos/earldouglas/teep/badge.svg)](https://coveralls.io/github/earldouglas/teep)

Teep is a JavaScript library for functional programming. It works both
as a [Node.js module](https://www.npmjs.org/package/teep), and directly
Expand Down
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@
},
"scripts": {
"build": "tsc src/teep.ts --outDir .",
"test": "npm run-script build && istanbul cover _mocha -- -R spec",
"coveralls": "npm run-script test && cat ./coverage/lcov.info | coveralls"
"test": "jshint . --exclude node_modules && mocha",
"coverage": "istanbul cover _mocha -- -R spec",
"coveralls": "cat ./coverage/lcov.info | coveralls"
},
"jshintConfig": {
"node": true,
"globals": {
"Promise": false,
"describe": false,
"it": false
}
},
"devDependencies": {
"bluebird": "2.2.2",
"coveralls": "2.11.2",
"istanbul": "0.3.5",
"jshint": "2.9.4",
"mocha": "2.2.5",
"mocha-lcov-reporter": "0.0.1",
"typescript": "2.9"
Expand Down
34 changes: 19 additions & 15 deletions src/teep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ module edc {
keys: (o: Object): Array<any> => {
var ks = [];
for (var k in o) {
!o.hasOwnProperty(k) || ks.push(k);
if (o.hasOwnProperty(k)) {
ks.push(k);
}
}
return ks;
},
Expand Down Expand Up @@ -336,17 +338,17 @@ module edc {
}
apply(a: A): B {
return this.f(a);
};
}
map<C>(g: (B) => C): Reader<A,C> {
return new Reader((a) => {
return g(this.f(a));
});
};
}
flatMap<C>(g: (B) => Reader<A,C>): Reader<A,C> {
return new Reader((a) => {
return g(this.f(a)).apply(a);
});
};
}
}

var reader = <A,B>(f: (A) => B) => { return new Reader(f); }
Expand All @@ -362,21 +364,21 @@ module edc {
}
apply(k: (A) => any): void {
this.f(k);
};
}
map<B>(g: (A) => B): Future<B> {
return new Future((k: (B) => any) => {
return this.f((a: A) => {
k(g(a));
});
});
};
}
flatMap<B>(g: (A) => Future<B>): Future<B> {
return new Future((k: (B) => any) => {
return this.f((a: A) => {
g(a).apply(k);
});
});
};
}
sequence<B>(f2: Future<B>): Future<(A) => B> {
var a: A;
var b: B;
Expand All @@ -395,7 +397,7 @@ module edc {
kk();
});
});
};
}
}

var future = <A>(f: (A) => any) => { return new Future(f); }
Expand All @@ -407,17 +409,17 @@ module edc {
}
apply(a: A): Monad<B> {
return this.f(a);
};
}
map<C>(g: (B) => C): ReaderT<A,C> {
return new ReaderT((a) => {
return this.f(a).map(g);
});
};
}
flatMap<C>(g: (B) => ReaderT<A,C>): ReaderT<A,C> {
return new ReaderT((a) => {
return this.f(a).map(g).flatMap((r) => { return r.apply(a); });
});
};
}
}

var readerT = <A,B>(f: (A) => Monad<B>) => { return new ReaderT(f); }
Expand All @@ -440,20 +442,20 @@ module edc {
}
apply(s: S): StateTuple<S,A> {
return this.f(s);
};
}
map<B>(g: (A) => B): State<S,B> {
return state((s: S) => {
var sa: StateTuple<S,A> = this.f(s);
return new StateTuple(sa.state, g(sa.value));
});
};
}
flatMap<B>(g: (A) => State<S,B>): State<S,B> {
return state((s: S) => {
var sa: StateTuple<S,A> = this.f(s);
var sb: State<S,B> = g(sa.value);
return sb.apply(sa.state);
});
};
}
}

export var teep = {
Expand All @@ -478,6 +480,8 @@ module edc {
});
};

!exports || setExports();
if (exports) {
setExports();
}

}
21 changes: 6 additions & 15 deletions teep.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ var edc;
keys: function (o) {
var ks = [];
for (var k in o) {
!o.hasOwnProperty(k) || ks.push(k);
if (o.hasOwnProperty(k)) {
ks.push(k);
}
}
return ks;
}
Expand Down Expand Up @@ -287,21 +289,18 @@ var edc;
Reader.prototype.apply = function (a) {
return this.f(a);
};
;
Reader.prototype.map = function (g) {
var _this = this;
return new Reader(function (a) {
return g(_this.f(a));
});
};
;
Reader.prototype.flatMap = function (g) {
var _this = this;
return new Reader(function (a) {
return g(_this.f(a)).apply(a);
});
};
;
return Reader;
}());
var reader = function (f) { return new Reader(f); };
Expand All @@ -315,7 +314,6 @@ var edc;
Future.prototype.apply = function (k) {
this.f(k);
};
;
Future.prototype.map = function (g) {
var _this = this;
return new Future(function (k) {
Expand All @@ -324,7 +322,6 @@ var edc;
});
});
};
;
Future.prototype.flatMap = function (g) {
var _this = this;
return new Future(function (k) {
Expand All @@ -333,7 +330,6 @@ var edc;
});
});
};
;
Future.prototype.sequence = function (f2) {
var _this = this;
var a;
Expand All @@ -354,7 +350,6 @@ var edc;
});
});
};
;
return Future;
}());
var future = function (f) { return new Future(f); };
Expand All @@ -365,21 +360,18 @@ var edc;
ReaderT.prototype.apply = function (a) {
return this.f(a);
};
;
ReaderT.prototype.map = function (g) {
var _this = this;
return new ReaderT(function (a) {
return _this.f(a).map(g);
});
};
;
ReaderT.prototype.flatMap = function (g) {
var _this = this;
return new ReaderT(function (a) {
return _this.f(a).map(g).flatMap(function (r) { return r.apply(a); });
});
};
;
return ReaderT;
}());
var readerT = function (f) { return new ReaderT(f); };
Expand All @@ -398,15 +390,13 @@ var edc;
State.prototype.apply = function (s) {
return this.f(s);
};
;
State.prototype.map = function (g) {
var _this = this;
return state(function (s) {
var sa = _this.f(s);
return new StateTuple(sa.state, g(sa.value));
});
};
;
State.prototype.flatMap = function (g) {
var _this = this;
return state(function (s) {
Expand All @@ -415,7 +405,6 @@ var edc;
return sb.apply(sa.state);
});
};
;
return State;
}());
edc.teep = {
Expand All @@ -438,5 +427,7 @@ var edc;
exports[k] = edc.teep[k];
});
};
!exports || setExports();
if (exports) {
setExports();
}
})(edc || (edc = {}));
6 changes: 3 additions & 3 deletions test/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if (!global.Promise) { global.Promise = require('bluebird'); }

var assert = require("assert")
var assert = require("assert");
var teep = require('../teep.js');

describe('examples', function () {
Expand Down Expand Up @@ -496,15 +496,15 @@ describe('examples', function () {
return k(db.answer + x);
});
});
};
}

function verify(x, done) {
return function (y) {
if (x === y) {
done();
}
};
};
}

it('apply', function (done) {
teep.readerT(getAnswer).apply(db).apply(verify(42, done));
Expand Down

0 comments on commit 76f9c48

Please sign in to comment.