elm-monitor
Version:
Monitor your elm program with redux-devtools
3 lines (2 loc) • 1.28 kB
JavaScript
var n=require("./parser").Elm,e=function(n){return"string"==typeof n&&/^⟨.+⟩$/.test(n)},t=function(n){var t=function n(t){if(e(t))return[t];var o=t[0],r=t[1],i=t.slice(2);if(!e(o))throw Error("`a` not a type string");return e(r)&&0===i.length?[o+":"+r]:Array.isArray(r)&&e(r[0])&&r.length<=2&&0===i.length?n([o+":"+r[0]].concat(r.slice(1))):[o,r].concat(i)}(n),o=t[0],r=t.slice(1);return r.length>0?{type:o+"*",payload:r.length>1?r:r[0]}:{type:o}},o=function(e){return new Promise(function(t,o){var r=n.Main.init();r.ports.sendParsedData.subscribe(function n(e){"Ok"in e?t(e.Ok):o(e.Err),r.ports.sendParsedData.unsubscribe(n)}),r.ports.listenToInput.send(e)})};module.exports=function(){if(window.__REDUX_DEVTOOLS_EXTENSION__&&window.console){var n=window.__REDUX_DEVTOOLS_EXTENSION__.connect({features:{pause:!0,export:!0}}),e=window.console.log.bind(window.console);window.console.log=function(){var r=[].slice.call(arguments),i="string"==typeof r[0]&&r[0].match(/^\[Monitor:(init|update)\]: (.+)$/);if(i){var s=i[1],c=i[2];switch(s){case"init":o(c).then(function(e){n.init(e)},function(n){console.error(n)});break;case"update":o(c).then(function(e){var o=e[1];n.send(t(e[0]),o)},function(n){console.error(n)})}}else e.apply(void 0,r)}}};
//# sourceMappingURL=index.js.map