diff --git a/mithril.js b/mithril.js index ee63e707..a82f9524 100644 --- a/mithril.js +++ b/mithril.js @@ -7,18 +7,15 @@ function createStream() { return stream._state.value } initStream(stream, arguments) - if (arguments.length > 0) updateStream(stream, arguments[0], undefined) - return stream } function initStream(stream, args) { stream.constructor = createStream stream._state = {id: guid++, value: undefined, error: undefined, state: 0, derive: undefined, recover: undefined, deps: {}, parents: [], errorStream: undefined, endStream: undefined} stream.map = map, stream.ap = ap, stream.of = createStream - stream.valueOf = valueOf, stream.toJSON = toJSON + stream.valueOf = valueOf, stream.toJSON = toJSON, stream.toString = valueOf stream.run = run, stream.catch = doCatch - Object.defineProperties(stream, { error: {get: function() { if (!stream._state.errorStream) { @@ -130,10 +127,8 @@ function initDependency(dep, streams, derive, recover) { state.derive = derive state.recover = recover state.parents = streams.filter(notEnded) - registerDependency(dep, state.parents) updateDependency(dep, true) - return dep } function registerDependency(stream, parents) { @@ -1066,7 +1061,6 @@ m.route = function($window, renderer, pubsub) { route.prefix = router.setPrefix route.set = router.setPath route.get = router.getPath - return route }(window, renderService, redrawService) m.mount = function(renderer, pubsub) { diff --git a/mithril.min.js b/mithril.min.js new file mode 100644 index 00000000..7bb133aa --- /dev/null +++ b/mithril.min.js @@ -0,0 +1,38 @@ +(function(){function y(){function a(){0=B&&r>=w;){var v=c[B],x=g[w];if(v===x)B++,w++;else if(null!=v&&null!=x&&v.key===x.key)B++,w++,k(a,v,x,e,d(c,B,f),t,p),t&&v.tag===x.tag&&m(a,l(v),f);else if(v=c[u],v===x)u--,w++;else if(null!=v&&null!=x&&v.key===x.key)k(a,v,x,e,d(c,u+1,f),t,p),m(a,l(v),d(c,B,f)),u--,w++;else break}for(;u>=B&&r>=w;){v=c[u];x=g[r];if(v===x)u--;else if(null!=v&&null!= +x&&v.key===x.key)k(a,v,x,e,d(c,u+1,f),t,p),t&&v.tag===x.tag&&m(a,l(v),f),f=v.dom,u--;else{if(!n){n=c;var v=u,q={},y;for(y=0;ya.indexOf("?")?"?":"&";a+=f+e}return a}function e(a){try{return""!==a?JSON.parse(a):null}catch(b){throw Error(a);}}function f(a){return a.responseText}var k=0,l;return{xhr:function(d){var m=z.stream();void 0!==d.initialValue&&m(d.initialValue);var k="boolean"===typeof d.useBody?d.useBody:"GET"!==d.method&&"TRACE"!==d.method;"function"!== +typeof d.serialize&&(d.serialize=JSON.stringify);"function"!==typeof d.deserialize&&(d.deserialize=e);"function"!==typeof d.extract&&(d.extract=f);d.url=b(d.url,d.data);k?d.data=d.serialize(d.data):d.url=h(d.url,d.data);var p=new a.XMLHttpRequest;p.open(d.method,d.url,"boolean"===typeof d.async?d.async:!0,"string"===typeof d.user?d.user:void 0,"string"===typeof d.password?d.password:void 0);d.serialize===JSON.stringify&&k&&p.setRequestHeader("Content-Type","application/json; charset=utf-8");d.deserialize=== +e&&p.setRequestHeader("Accept","application/json, text/*");"function"===typeof d.config&&(p=d.config(p,d)||p);p.onreadystatechange=function(){if(4===p.readyState){try{var a=d.deserialize(d.extract(p,d));if(200<=p.status&&300>p.status){if("function"===typeof d.type)if(a instanceof Array)for(var b=0;b