UNPKG

elm-monitor

Version:

Monitor your elm program with redux-devtools

3 lines (2 loc) 1.46 kB
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n=n||self).elmMonitor=e()}(this,function(){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],i=t[1],r=t.slice(2);if(!e(o))throw Error("`a` not a type string");return e(i)&&0===r.length?[o+":"+i]:Array.isArray(i)&&e(i[0])&&i.length<=2&&0===r.length?n([o+":"+i[0]].concat(i.slice(1))):[o,i].concat(r)}(n),o=t[0],i=t.slice(1);return i.length>0?{type:o+"*",payload:i.length>1?i:i[0]}:{type:o}},o=function(e){return new Promise(function(t,o){var i=n.Main.init();i.ports.sendParsedData.subscribe(function n(e){"Ok"in e?t(e.Ok):o(e.Err),i.ports.sendParsedData.unsubscribe(n)}),i.ports.listenToInput.send(e)})};return 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 i=[].slice.call(arguments),r="string"==typeof i[0]&&i[0].match(/^\[Monitor:(init|update)\]: (.+)$/);if(r){var s=r[1],c=r[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,i)}}}}); //# sourceMappingURL=index.umd.js.map