This file contains hidden or 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
function createUser(username, callback) { | |
var connection = DatabaseClient.connect(); | |
var users = connection.collection('users'); | |
var query = users.query({username: username}); | |
return query.then(function(existing){ | |
if(existing) throw new Error("User already exists: " + username); | |
else return users.create({username: username}); | |
}).fin(function(connection){ return connection.call('close'); }); | |
} |
This file contains hidden or 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
function createUser(username, callback) { | |
var connection = DatabaseClient.connect(); | |
var users = connection.call('collection', 'users'); | |
var query = users.call('query', {username: username}); | |
return query.then(function(existing){ | |
if(existing) throw new Error("User already exists: " + username); | |
else return users.call('create', {username: username}); | |
}).fin(function(connection){ return connection.call('close'); }); | |
} |
This file contains hidden or 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
(function(){ | |
function check(e, selector, fn){ | |
var target = e.target, | |
els = this.getElements(selector), | |
isOverOut = /^(mouseover|mouseout)$/.test(e.type); | |
for (var i = els.length; i--; ){ | |
var el = els[i]; | |
if (el == target || el.hasChild(target)){ |