什么是惯用的方式做一些像承诺的while循环.所以:
如果条件仍然有效,请再做一次然后再做其他事情.
dosomething.then(possilblydomoresomethings).then(finish)
Run Code Online (Sandbox Code Playgroud)
我是这样做的,我想知道是否有更好/更多的自我方式?
var q = require('q');
var index = 1;
var useless = function(){
var currentIndex = index;
console.log(currentIndex)
var deferred = q.defer();
setTimeout(function(){
if(currentIndex > 10)
deferred.resolve(false);
else deferred.resolve(true);
},500);
return deferred.promise;
}
var control = function(cont){
var deferred = q.defer();
if(cont){
index = index + 1;
useless().then(control).then(function(){
deferred.resolve();
});
}
else deferred.resolve();
return deferred.promise;
}
var chain = useless().then(control).then(function(){console.log('done')});
Run Code Online (Sandbox Code Playgroud)
输出:1 2 3 4 5 6 7 8 9 10 11完成
我的一个合作伙伴的印象是,在SQL Server 2008中向表中添加索引时,PK的索引也会添加到该索引中.因此,如果您使用更宽的主键,那么该键也将包含在新索引中,大大增加了上面使用的磁盘空间,超出了已经为PK索引支付的惩罚.我之前没有听说过,到目前为止我的搜索结果是空的.
希望有人在这里指出相关文档,以确认或否认这一点.请?
sql-server indexing primary-key clustered-index sql-server-2008
我正在尝试使用Jasmine(带有yaml配置的gem)来测试Backbone.js应用程序.我正在使用像Todo示例那样的下划线模板.
template: _.template($('#item-template').html())
Run Code Online (Sandbox Code Playgroud)
我的问题是我无法在模型/视图之前加载模板,因此模板调用会导致这些类在加载时出错.
我已经阅读了关于jasmine-jquery插件来做夹具但问题是我的src文件(模型/视图)正在加载并且在我获得spec文件之前失败并且能够设置所需的灯具.
如何尽早加载模板,它们可用于重置我的类?
我的商店在IIS 7上使用MVC3/FUBU.我最近投入了一些工作,我想使用日志解析器从IIS日志中收集指标.我以前做了很多次但是因为MVC3路由的形式是/ api/person //地址/日志保存/ api/person/123/address/456在uristem列中.
有没有人对如何从IIS日志中获取有关特定路由的数据有任何想法?
作为一个例子:日志像这样:
cs-uri-stem
/api/person/123/address/456
/api/person/121/address/33
/api/person/1555/address/5555
Run Code Online (Sandbox Code Playgroud)
输出如:总命中数= 3
backbone.js ×1
bdd ×1
fubumvc ×1
iis-logs ×1
indexing ×1
jasmine ×1
loops ×1
node.js ×1
primary-key ×1
promise ×1
q ×1
rest ×1
sql-server ×1
templates ×1