-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const listKeys = (x= {}) => { | ||
Check failure on line 1 in src/imports/api/mixins/asyncReadyMixin.js GitHub Actions / Javascript lint
Check failure on line 1 in src/imports/api/mixins/asyncReadyMixin.js GitHub Actions / Javascript lint
Check failure on line 1 in src/imports/api/mixins/asyncReadyMixin.js GitHub Actions / Javascript lint
|
||
for (const nameKey in x) { | ||
console.debug(nameKey, typeof x) | ||
Check failure on line 3 in src/imports/api/mixins/asyncReadyMixin.js GitHub Actions / Javascript lint
|
||
} | ||
} | ||
export const asyncReadyMixin = function (options) { | ||
const { name, run } = options | ||
const body = run.toString().split(/\n+/g) | ||
options.isAsyncReady = body[1].includes('return Promise.asyncApply(() => {') | ||
addToList(name, options.isAsyncReady) | ||
|
||
return options | ||
} | ||
|
||
const internal = { list: [] } | ||
|
||
global.getAsyncReadySummary = ({ printNames } = {}) => { | ||
const { list } = internal | ||
const max = list.length | ||
let ready = 0 | ||
list.forEach(([name, isReady]) => { | ||
if (isReady) { | ||
ready++ | ||
} | ||
else if (printNames) { | ||
console.log('Not Async Ready:', name) | ||
Check failure on line 26 in src/imports/api/mixins/asyncReadyMixin.js GitHub Actions / Javascript lint
|
||
} | ||
}) | ||
const notReady = max - ready | ||
const divisor = max || 1 | ||
const notReadyPerc = 100 * notReady / divisor | ||
const readyPerc = 100 * ready / divisor | ||
console.log('-------------------') | ||
Check failure on line 33 in src/imports/api/mixins/asyncReadyMixin.js GitHub Actions / Javascript lint
|
||
console.log('Async Ready Summary') | ||
Check failure on line 34 in src/imports/api/mixins/asyncReadyMixin.js GitHub Actions / Javascript lint
|
||
console.log('-------------------') | ||
Check failure on line 35 in src/imports/api/mixins/asyncReadyMixin.js GitHub Actions / Javascript lint
|
||
console.log('count', max) | ||
Check failure on line 36 in src/imports/api/mixins/asyncReadyMixin.js GitHub Actions / Javascript lint
|
||
console.log('ready', ready, `(${readyPerc.toFixed(2)}%)`) | ||
Check failure on line 37 in src/imports/api/mixins/asyncReadyMixin.js GitHub Actions / Javascript lint
|
||
console.log('todo!', notReady, `(${notReadyPerc.toFixed(2)}%)`) | ||
Check failure on line 38 in src/imports/api/mixins/asyncReadyMixin.js GitHub Actions / Javascript lint
|
||
} | ||
|
||
const addToList = (name, isAsyncReady) => { | ||
internal.list.push([name, isAsyncReady]) | ||
} |