我的问题是关于使用更直接的回调结构与事件广播和收听之间的最佳实践.我没有使用broadcast/emit/on事件传播框架.相反,当一个已知事件发生时(在事件的源头),我一直在创建一个回调寄存器并触发注册的回调.这一切都是通过服务完成的.
广播/发射/开启范例的效率如何?我应该使用它吗?它是否与回调类型的结构一样有效?
谢谢.
这是算法:
// Precondition: n > 0
l = -1;
r = n;
while (l+1 != r) {
m = (l+r)/2;
// I && m == (l+r)/2
if (a[m] <= x) {
l = m;
} else {
r = m;
}
}
// Postcondition: -1 <= l < n
Run Code Online (Sandbox Code Playgroud)
我做了一些研究,并将不变量缩小到了if x is in a[0 .. n-1] then a[l] <= x < a[r].
我不知道如何从那里进步.前提似乎过于宽泛,所以我很难显示出来P -> I.
非常感谢任何帮助.这些是可用于证明算法正确性的逻辑规则:
algorithm correctness binary-search hoare-logic proof-of-correctness
Jest 通过以下方式缩短错误日志:
GraphQLError {
message: 'Cannot set property \'marketCap\' of undefined',
locations: [ { line: 3, column: 11 } ],
path: [ 'listings' ],
extensions:
{ code: 'INTERNAL_SERVER_ERROR',
exception: { stacktrace: [Array] }
}
} 0 [
GraphQLError {
message: 'Cannot set property \'marketCap\' of undefined',
locations: [ [Object] ],
path: [ 'listings' ],
extensions: { code: 'INTERNAL_SERVER_ERROR', exception: [Object] }
}
]
Run Code Online (Sandbox Code Playgroud)
如何强制它打印整个错误而不是使用[Array]and [Object]?
我试图访问实际位于另一个对象内的对象上的属性(名称).我在文件中初始化了对象:
var icons = {
"facebook": {name: 'facebook', icon_url: 'img/logos/facebook.png'}
};
Run Code Online (Sandbox Code Playgroud)
然后尝试使用以下代码检查对象:
var icon_current_class;
for(var icon in icons){
console.dir(icon);
//outputs an object named facebook but says it has no properties
if( $(this).hasClass( icon.name ) ){
icon_current_class = icon.name;
}else{
alert("Something went wrong. Please contact the mods.");
}
}
Run Code Online (Sandbox Code Playgroud)
当然,每次运行时,警报("出问题")都会消失.我已经尝试了很长时间才找到解决方案,但无济于事.有人可以帮忙吗?
应该docker-compose up --build不够?
这是我们的 Dockerfile:
FROM node:8.12.0-alpine
# Set app directory
WORKDIR /usr/src/app
# Install git in order to allow installing
# npm packages from Github
RUN set -xe \
&& apk add --no-cache git
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
# Bundle app source
COPY . .
ENV NODE_ENV development
EXPOSE 8080
CMD ["npm","start"]
Run Code Online (Sandbox Code Playgroud)
还有我们的 docker-compose …
javascript ×2
node.js ×2
algorithm ×1
angularjs ×1
correctness ×1
css ×1
docker ×1
for-in-loop ×1
hoare-logic ×1
html ×1
jestjs ×1
node-modules ×1
npm ×1
object ×1