mutant
mutant copied to clipboard
Use on-idle package instead of window.requestIdleCallback ?
I'm trying to write a small command line tool for ssb-chess at the moment, and I ran into the issue that I'm using mutant within a command line (node) environment, but mutant/once-idle uses the window object which is only available in the browser.
How do you feel about using https://www.npmjs.com/package/on-idle instead? If you're happy to do so, I can make a pull request.
Or is your philosophy that mutant shouldn't be used within nodejs?
/home/happy0/projects/ssb-chess/node_modules/patchcore/node_modules/mutant/once-idle.js:12
window.requestIdleCallback(flush)
^
ReferenceError: window is not defined
at module.exports (/home/happy0/projects/ssb-chess/node_modules/patchcore/node_modules/mutant/once-idle.js:12:5)
at Object.cachedBacklinks (/home/happy0/projects/ssb-chess/node_modules/patchcore/backlinks/obs-cache.js:71:7)
at pullFilterReduceObs (/home/happy0/projects/ssb-chess/node_modules/patchcore/backlinks/obs-filter.js:63:29)
at backlinks.obs.filter (/home/happy0/projects/ssb-chess/node_modules/patchcore/backlinks/obs-filter.js:109:14)
at getCachedFilteredBacklinks (/home/happy0/projects/ssb-chess/ssb_ctrl/backlinks_obs.js:31:12)
at getSituationObservable (/home/happy0/projects/ssb-chess/ssb_ctrl/game.js:134:26)
at Object.getSituation (/home/happy0/projects/ssb-chess/ssb_ctrl/game.js:239:40)
at getSituation (/home/happy0/projects/ssb-chess/ctrl/pgn.js:49:23)
at /home/happy0/projects/ssb-chess/node_modules/pull-stream/throughs/async-map.js:28:13
at next (/home/happy0/projects/ssb-chess-dump/node_modules/pull-iterable/index.js:15:5)
at Function.read.resolve (/home/happy0/projects/ssb-chess-dump/node_modules/pull-defer/source.js:20:13)
at view.get (/home/happy0/projects/ssb-chess-dump/node_modules/ssb-chess-db/index.js:67:18)
at get (/home/happy0/projects/ssb-chess-dump/node_modules/flumeview-reduce/inject.js:115:11)
at Object.cb (/home/happy0/projects/ssb-chess-dump/node_modules/flumedb/wrap.js:45:11)
at Array.<anonymous> (/home/happy0/projects/ssb-chess-dump/node_modules/flumedb/wrap.js:12:23)
at trigger (/home/happy0/projects/ssb-chess-dump/node_modules/obv/index.js:8:34)
Hey @Happy0 - I love a good discussion first, rather than jumping into implementing anything. That's it. Just saying I'm loving your approach.
thanks @avioli :3