Created
May 16, 2012 14:10
-
-
Save hebuliang/2710635 to your computer and use it in GitHub Desktop.
jSQL count function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count: function(key) { | |
var count = 0, scope = key.split('.'); | |
if(key === '*') | |
this._buffer = this._currentDB; | |
for(var key in this._currentDB) { | |
if (this._currentDB.hasOwnProperty(key)) { | |
var tmp = this._currentDB[key]; | |
for(var i=0,j=0; i<(j=scope.length); i++) { | |
tmp = tmp[scope[i]]; | |
if(!!tmp && i == j - 1) count++; | |
} | |
} | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment