Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 31df85f

Browse files
committedJun 8, 2020
named export
These all use named import (Except julia-client.coffee which is updated in other PR) File misc.js Found usages (14 usages found) Unclassified usage (5 usages found) lib\connection\process (2 usages found) basic.js (1 usage found) 6 import { paths, mutex } from '../../misc' remote.js (1 usage found) 5 import { paths, mutex } from '../../misc' lib\runtime (3 usages found) console.js (1 usage found) 6 import { paths } from '../misc' debugger.js (1 usage found) 8 import { blocks, cells, paths } from '../misc' frontend.js (1 usage found) 5 import { colors } from '../misc' Usage in string literals (9 usages found) lib (2 usages found) connection.coffee (1 usage found) 1 {time} = require './misc' julia-client.coffee (1 usage found) 19 misc: require './misc' lib\connection (3 usages found) ipc.coffee (1 usage found) 5 {bufferLines} = require '../misc' local.coffee (1 usage found) 1 {paths} = require '../misc' terminal.coffee (1 usage found) 6 {paths} = require '../misc' lib\connection\process (1 usage found) server.coffee (1 usage found) 7 {exclusive} = require '../../misc' lib\runtime (1 usage found) evaluation.coffee (1 usage found) 7 {paths, blocks, cells, words, weave} = require '../misc' lib\ui (2 usages found) progress.coffee (1 usage found) 3 {formatTimePeriod} = require '../misc' views.coffee (1 usage found) 4 {once} = require '../misc'
1 parent 28b90c9 commit 31df85f

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed
 

‎lib/misc.js

+21-25
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ import * as weave from './misc/weave'
1111
import * as colors from './misc/colors'
1212
import * as scopes from './misc/scopes'
1313

14-
export default {
15-
// TODO remove these from the export default and export them directly (prevents expensive copy)
16-
// TODO don't use this.message use message directly (prevents expensive copy)
17-
paths: paths,
18-
blocks: blocks,
19-
cells: cells,
20-
words: words,
21-
weave: weave,
22-
colors: colors,
23-
scopes: scopes,
14+
exports.paths = paths
15+
exports.blocks = blocks
16+
exports.cells = cells
17+
exports.words = words
18+
exports.weave = weave
19+
exports.colors = colors
20+
exports.scopes = scopes
2421

25-
bufferLines(t, f) {
22+
export function bufferLines(t, f) {
2623
if (!f) { [t, f] = [null, t]; }
2724
const buffer = [''];
2825
const flush = (t == null) ? ()=>{} : debounce(( () => {
@@ -39,41 +36,41 @@ export default {
3936
}
4037
flush();
4138
};
42-
},
39+
}
4340

44-
time(desc, p) {
41+
export function time(desc, p) {
4542
const s = () => new Date().getTime()/1000;
4643
const t = s();
4744
p.then(() => console.log(`${desc}: ${(s()-t).toFixed(2)}s`))
4845
.catch(()=>{});
4946
return p;
50-
},
47+
}
5148

52-
hook(obj, method, f) {
49+
export function hook(obj, method, f) {
5350
const souper = obj[method].bind(obj);
5451
return obj[method] = (...a) => f(souper, ...a);
55-
},
52+
}
5653

57-
once(f) {
54+
export function once(f) {
5855
let done = false;
5956
return function(...args) {
6057
if (done) { return; }
6158
done = true;
6259
return f.call(this, ...args);
6360
};
64-
},
61+
}
6562

66-
mutex() {
63+
export function mutex() {
6764
let wait = Promise.resolve();
6865
return function(f) {
6966
const current = wait;
7067
let release = null;
7168
wait = new Promise(resolve => release = resolve).catch(function() {});
7269
return current.then(() => f.call(this, release));
7370
};
74-
},
71+
}
7572

76-
exclusive(f) {
73+
export function exclusive(f) {
7774
const lock = module.exports.mutex();
7875
return function(...args) {
7976
return lock(release => {
@@ -82,10 +79,10 @@ export default {
8279
return result;
8380
});
8481
};
85-
},
82+
}
8683

87-
// takes a time period in seconds and formats it as hh:mm:ss
88-
formatTimePeriod(dt) {
84+
// takes a time period in seconds and formats it as hh:mm:ss
85+
export function formatTimePeriod(dt) {
8986
if (dt <= 1) { return; }
9087
const h = Math.floor(dt/(60*60));
9188
const m = Math.floor((dt -= h*60*60)/60);
@@ -96,5 +93,4 @@ export default {
9693
parts[i] = dt < 10 ? `0${dt}` : `${dt}`;
9794
}
9895
return parts.join(':');
99-
}
10096
};

0 commit comments

Comments
 (0)
Please sign in to comment.