Skip to content

Commit

Permalink
named export
Browse files Browse the repository at this point in the history
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'
  • Loading branch information
aminya committed Jun 8, 2020
1 parent 28b90c9 commit 31df85f
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions lib/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ import * as weave from './misc/weave'
import * as colors from './misc/colors'
import * as scopes from './misc/scopes'

export default {
// TODO remove these from the export default and export them directly (prevents expensive copy)
// TODO don't use this.message use message directly (prevents expensive copy)
paths: paths,
blocks: blocks,
cells: cells,
words: words,
weave: weave,
colors: colors,
scopes: scopes,
exports.paths = paths
exports.blocks = blocks
exports.cells = cells
exports.words = words
exports.weave = weave
exports.colors = colors
exports.scopes = scopes

bufferLines(t, f) {
export function bufferLines(t, f) {
if (!f) { [t, f] = [null, t]; }
const buffer = [''];
const flush = (t == null) ? ()=>{} : debounce(( () => {
Expand All @@ -39,41 +36,41 @@ export default {
}
flush();
};
},
}

time(desc, p) {
export function time(desc, p) {
const s = () => new Date().getTime()/1000;
const t = s();
p.then(() => console.log(`${desc}: ${(s()-t).toFixed(2)}s`))
.catch(()=>{});
return p;
},
}

hook(obj, method, f) {
export function hook(obj, method, f) {
const souper = obj[method].bind(obj);
return obj[method] = (...a) => f(souper, ...a);
},
}

once(f) {
export function once(f) {
let done = false;
return function(...args) {
if (done) { return; }
done = true;
return f.call(this, ...args);
};
},
}

mutex() {
export function mutex() {
let wait = Promise.resolve();
return function(f) {
const current = wait;
let release = null;
wait = new Promise(resolve => release = resolve).catch(function() {});
return current.then(() => f.call(this, release));
};
},
}

exclusive(f) {
export function exclusive(f) {
const lock = module.exports.mutex();
return function(...args) {
return lock(release => {
Expand All @@ -82,10 +79,10 @@ export default {
return result;
});
};
},
}

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

0 comments on commit 31df85f

Please sign in to comment.