@@ -16,6 +16,7 @@ module.exports = Choo
1616var  HISTORY_OBJECT  =  { } 
1717
1818function  Choo  ( opts )  { 
19+   var  timing  =  nanotiming ( 'choo.constructor' ) 
1920  if  ( ! ( this  instanceof  Choo ) )  return  new  Choo ( opts ) 
2021  opts  =  opts  ||  { } 
2122
@@ -37,7 +38,7 @@ function Choo (opts) {
3738  // properties for internal use only 
3839  this . _historyEnabled  =  opts . history  ===  undefined  ? true  : opts . history 
3940  this . _hrefEnabled  =  opts . href  ===  undefined  ? true  : opts . href 
40-   this . _hashEnabled  =  opts . hash  ===  undefined  ? true  : opts . hash 
41+   this . _hashEnabled  =  opts . hash  ===  undefined  ? false  : opts . hash 
4142  this . _hasWindow  =  typeof  window  !==  'undefined' 
4243  this . _cache  =  opts . cache 
4344  this . _loaded  =  false 
@@ -72,12 +73,15 @@ function Choo (opts) {
7273      if  ( self . _hasWindow )  document . title  =  title 
7374    } ) 
7475  } 
76+   timing ( ) 
7577} 
7678
7779Choo . prototype . route  =  function  ( route ,  handler )  { 
80+   var  routeTiming  =  nanotiming ( "choo.route('"  +  route  +  "')" ) 
7881  assert . equal ( typeof  route ,  'string' ,  'choo.route: route should be type string' ) 
7982  assert . equal ( typeof  handler ,  'function' ,  'choo.handler: route should be type function' ) 
8083  this . router . on ( route ,  handler ) 
84+   routeTiming ( ) 
8185} 
8286
8387Choo . prototype . use  =  function  ( cb )  { 
@@ -94,6 +98,7 @@ Choo.prototype.use = function (cb) {
9498
9599Choo . prototype . start  =  function  ( )  { 
96100  assert . equal ( typeof  window ,  'object' ,  'choo.start: window was not found. .start() must be called in a browser, use .toString() if running in Node' ) 
101+   var  startTiming  =  nanotiming ( 'choo.start' ) 
97102
98103  var  self  =  this 
99104  if  ( this . _historyEnabled )  { 
@@ -139,11 +144,11 @@ Choo.prototype.start = function () {
139144  } 
140145
141146  this . _setCache ( this . state ) 
147+   this . _matchRoute ( this . state ) 
142148  this . _stores . forEach ( function  ( initStore )  { 
143149    initStore ( self . state ) 
144150  } ) 
145151
146-   this . _matchRoute ( this . state ) 
147152  this . _tree  =  this . _prerender ( this . state ) 
148153  assert . ok ( this . _tree ,  'choo.start: no valid DOM node returned for location '  +  this . state . href ) 
149154
@@ -168,13 +173,16 @@ Choo.prototype.start = function () {
168173    self . _loaded  =  true 
169174  } ) 
170175
176+   startTiming ( ) 
171177  return  this . _tree 
172178} 
173179
174180Choo . prototype . mount  =  function  mount  ( selector )  { 
181+   var  mountTiming  =  nanotiming ( "choo.mount('"  +  selector  +  "')" ) 
175182  if  ( typeof  window  !==  'object' )  { 
176183    assert . ok ( typeof  selector  ===  'string' ,  'choo.mount: selector should be type String' ) 
177184    this . selector  =  selector 
185+     mountTiming ( ) 
178186    return  this 
179187  } 
180188
@@ -202,6 +210,7 @@ Choo.prototype.mount = function mount (selector) {
202210
203211    renderTiming ( ) 
204212  } ) 
213+   mountTiming ( ) 
205214} 
206215
207216Choo . prototype . toString  =  function  ( location ,  state )  { 
@@ -214,12 +223,12 @@ Choo.prototype.toString = function (location, state) {
214223  assert . equal ( typeof  state ,  'object' ,  'choo.toString: state should be type object' ) 
215224
216225  this . _setCache ( state ) 
226+   this . _matchRoute ( state ,  location ) 
217227  this . emitter . removeAllListeners ( ) 
218228  this . _stores . forEach ( function  ( initStore )  { 
219229    initStore ( state ) 
220230  } ) 
221231
222-   this . _matchRoute ( state ,  location ) 
223232  var  html  =  this . _prerender ( state ) 
224233  assert . ok ( html ,  'choo.toString: no valid value returned for the route '  +  location ) 
225234  assert ( ! Array . isArray ( html ) ,  'choo.toString: return value was an array for the route '  +  location ) 
0 commit comments