Skip to content

Commit 9579f54

Browse files
committed
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 9579f54

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

lib/misc.js

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,7 @@ 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,
24-
25-
bufferLines(t, f) {
14+
export function bufferLines(t, f) {
2615
if (!f) { [t, f] = [null, t]; }
2716
const buffer = [''];
2817
const flush = (t == null) ? ()=>{} : debounce(( () => {
@@ -39,41 +28,41 @@ export default {
3928
}
4029
flush();
4130
};
42-
},
31+
}
4332

44-
time(desc, p) {
33+
export function time(desc, p) {
4534
const s = () => new Date().getTime()/1000;
4635
const t = s();
4736
p.then(() => console.log(`${desc}: ${(s()-t).toFixed(2)}s`))
4837
.catch(()=>{});
4938
return p;
50-
},
39+
}
5140

52-
hook(obj, method, f) {
41+
export function hook(obj, method, f) {
5342
const souper = obj[method].bind(obj);
5443
return obj[method] = (...a) => f(souper, ...a);
55-
},
44+
}
5645

57-
once(f) {
46+
export function once(f) {
5847
let done = false;
5948
return function(...args) {
6049
if (done) { return; }
6150
done = true;
6251
return f.call(this, ...args);
6352
};
64-
},
53+
}
6554

66-
mutex() {
55+
export function mutex() {
6756
let wait = Promise.resolve();
6857
return function(f) {
6958
const current = wait;
7059
let release = null;
7160
wait = new Promise(resolve => release = resolve).catch(function() {});
7261
return current.then(() => f.call(this, release));
7362
};
74-
},
63+
}
7564

76-
exclusive(f) {
65+
export function exclusive(f) {
7766
const lock = module.exports.mutex();
7867
return function(...args) {
7968
return lock(release => {
@@ -82,10 +71,10 @@ export default {
8271
return result;
8372
});
8473
};
85-
},
74+
}
8675

87-
// takes a time period in seconds and formats it as hh:mm:ss
88-
formatTimePeriod(dt) {
76+
// takes a time period in seconds and formats it as hh:mm:ss
77+
export function formatTimePeriod(dt) {
8978
if (dt <= 1) { return; }
9079
const h = Math.floor(dt/(60*60));
9180
const m = Math.floor((dt -= h*60*60)/60);
@@ -96,5 +85,12 @@ export default {
9685
parts[i] = dt < 10 ? `0${dt}` : `${dt}`;
9786
}
9887
return parts.join(':');
99-
}
100-
};
88+
}
89+
90+
exports.paths = paths
91+
exports.blocks = blocks
92+
exports.cells = cells
93+
exports.words = words
94+
exports.weave = weave
95+
exports.colors = colors
96+
exports.scopes = scopes

0 commit comments

Comments
 (0)