Skip to content

Commit

Permalink
Port of initial flow annotations to Typescript approach.
Browse files Browse the repository at this point in the history
  • Loading branch information
Psigio committed Mar 6, 2018
1 parent 5534f1e commit 8ce8b03
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions build_src.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const commonjs = require('rollup-plugin-commonjs');
const json = require('rollup-plugin-json');
const includePaths = require('rollup-plugin-includepaths');
const colors = require('colors/safe');
const flow = require('rollup-plugin-flow');
const typescript = require('rollup-plugin-typescript');


module.exports = function buildSrc() {
Expand All @@ -29,7 +29,7 @@ module.exports = function buildSrc() {
.rollup({
input: './modules/id.js',
plugins: [
flow(),
typescript(),
includePaths({
paths: [
'node_modules/d3/node_modules' // for npm 2
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// @flow
// A per-domain session mutex backed by a cookie and dead man's
// switch. If the session crashes, the mutex will auto-release
// after 5 seconds.

// This is a type alias (https://flow.org/en/docs/types/aliases/) which allows flow to understand the object returned by utilSessionMutex in other files.
type utilSessionMutexType = {
export interface utilSessionMutexType {
lock: () => boolean,
unlock: () => void,
locked: () => boolean
};

// This accepts a string and returns an object that complies with utilSessionMutexType
export function utilSessionMutex(name: string): utilSessionMutexType {
var mutex = {};
var intervalID: ?IntervalID; // This indicates a Maybe type - intervalId can be null so we need to use "?IntervalID", not "IntervalID"
var mutex = <utilSessionMutexType>{};
var intervalID: number;

function renew() {
var expires = new Date();
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"license": "ISC",
"scripts": {
"all": "npm-run-all -s clean flow build dist",
"all": "npm-run-all -s clean build dist",
"build": "node development_server.js",
"clean": "shx rm -f dist/*.js dist/*.map dist/*.css dist/img/*.svg",
"dist": "npm-run-all -p dist:**",
Expand Down Expand Up @@ -73,6 +73,7 @@
"rollup-plugin-includepaths": "~0.2.2",
"rollup-plugin-json": "~2.2.0",
"rollup-plugin-node-resolve": "~3.0.0",
"rollup-plugin-typescript": "^0.8.1",
"shelljs": "^0.8.0",
"shx": "^0.2.1",
"sinon": "^4.0.0",
Expand All @@ -92,4 +93,4 @@
"engines": {
"node": ">=4.0.0"
}
}
}

0 comments on commit 8ce8b03

Please sign in to comment.