Mirror: 🎩 A tiny but capable push & pull stream library for TypeScript and Flow

Fix up Flow types and add check script (#68)

+11
.flowconfig
···
+
[ignore]
+
+
[include]
+
+
[libs]
+
+
[lints]
+
+
[options]
+
+
[strict]
+4 -1
package.json
···
"scripts": {
"docs:dev": "gatsby develop",
"docs:build": "gatsby build",
-
"check": "tsc --noEmit",
+
"check:ts": "tsc --noEmit",
+
"check:flow": "flow focus-check ./src/helpers/Wonka_flow_test.js",
+
"check": "run-s check:ts check:flow",
"bs:clean": "bsb -clean-world",
"bs:build": "bsb -make-world",
"bs:watch": "bsb -make-world -w",
···
"callbag-iterate": "^1.0.0",
"callbag-take": "^1.4.0",
"coveralls": "^3.0.9",
+
"flow-bin": "^0.115.0",
"flowgen": "^1.10.0",
"gatsby": "^2.18.17",
"gatsby-plugin-netlify": "^2.1.30",
+2 -1
scripts/generate-flow-files.js
···
const basename = path.basename(fullpath, '.d.ts');
const filepath = path.dirname(fullpath);
const newpath = path.join(filepath, basename + '.js.flow');
-
return writeFile(newpath, preamble + flowdef);
+
const definition = flowdef.replace(/import/g, 'import type');
+
return writeFile(newpath, preamble + definition);
});
return Promise.all([...write, genEntry()]);
+16 -12
src/helpers/Wonka_deriving.ts
···
import { __ as block } from 'bs-platform/lib/es6/block';
import { talkbackPlaceholder } from './Wonka_helpers.bs';
-
import * as types from '../Wonka_types.gen';
-
type talkbackCb = (tb: types.talkbackT) => void;
+
import {
+
talkbackT,
+
signalT
+
} from '../Wonka_types.gen';
-
export const pull = (0 as any as types.talkbackT);
-
export const close = (1 as any as types.talkbackT);
+
type talkbackCb = (tb: talkbackT) => void;
-
export const start = <a>(tb: talkbackCb): types.signalT<a> => block(0, [tb]) as any;
-
export const push = <a>(x: a): types.signalT<a> => block(1, [x]) as any;
-
export const end = <a>(): types.signalT<a> => 0 as any;
+
export const pull = (0 as any as talkbackT);
+
export const close = (1 as any as talkbackT);
-
export const isStart = <a>(s: types.signalT<a>) =>
+
export const start = <a>(tb: talkbackCb): signalT<a> => block(0, [tb]) as any;
+
export const push = <a>(x: a): signalT<a> => block(1, [x]) as any;
+
export const end = <a>(): signalT<a> => 0 as any;
+
+
export const isStart = <a>(s: signalT<a>) =>
typeof s !== 'number' && (s as any).tag === 0;
-
export const isPush = <a>(s: types.signalT<a>) =>
+
export const isPush = <a>(s: signalT<a>) =>
typeof s !== 'number' && (s as any).tag === 1;
-
export const isEnd = <a>(s: types.signalT<a>) =>
+
export const isEnd = <a>(s: signalT<a>) =>
typeof s === 'number' && (s as any) === 0;
-
export const unboxPush = <a>(s: types.signalT<a>): a | null =>
+
export const unboxPush = <a>(s: signalT<a>): a | null =>
isPush(s) ? (s as any)[0] : null;
-
export const unboxStart = <a>(s: types.signalT<a>): talkbackCb =>
+
export const unboxStart = <a>(s: signalT<a>): talkbackCb =>
isStart(s) ? (s as any)[0] : (talkbackPlaceholder as any);
+9
src/helpers/Wonka_flow_test.js
···
+
// @flow
+
+
import * as Wonka from '../../';
+
+
Wonka.pipe(
+
Wonka.fromArray([1, 2, 3]),
+
Wonka.map(x => x * 2),
+
Wonka.publish
+
);
+5
yarn.lock
···
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08"
integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==
+
flow-bin@^0.115.0:
+
version "0.115.0"
+
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.115.0.tgz#22e3ad9e5c7198967de80138ba8a9154ff387960"
+
integrity sha512-xW+U2SrBaAr0EeLvKmXAmsdnrH6x0Io17P6yRJTNgrrV42G8KXhBAD00s6oGbTTqRyHD0nP47kyuU34zljZpaQ==
+
flowgen@^1.10.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/flowgen/-/flowgen-1.10.0.tgz#a041ae31d543d22166e7ba7c296b8445deb3c2e4"