我正在使用filter()数组助手遍历数组中的某些对象.我的想法是使用bind()创建一个动态过滤函数来遍历数组中的对象,但bind中的参数正以我所期望的不同方式使用.这是代码:
var products = [
{name:"lettuce", type:"vegetable"},
{name:"apple", type:"fruit"},
{name:"carrot", type:"vegetable"},
{name:"orange", type:"fruit"}
];
// this is the function used in filter()
function filterProducts(cat, product){
return product.type === cat;
}
// new array
var vegetables = products.filter(filterProducts.bind(products, "vegetable"));
Run Code Online (Sandbox Code Playgroud)
我假设过滤器帮助器在bind方法中的参数之后传递数组中的每个对象,所以首先是this在回调中考虑的产品,然后是我想要检查每个对象的类型,最后是对象本身.
问题是:你会建议这样做吗?我的意思是,这可以被视为一种好的做法,还是创建一个过滤每种类型而不是像这样做的函数会更好?
我正在使用 travis 将 docker 映像从 Github 部署到 AWS elastic beanstalk。该部分正常,实际部署以 0 退出,并且.zipS3 存储桶中有一个文件。
问题是,由于这是我第一次使用 AWS,所以我使用示例应用程序创建了应用程序,因为代码是从 Github 部署的,部署后我得到的健康状态为降级(红色感叹号),并显示以下消息:
ERROR
During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version.
Run Code Online (Sandbox Code Playgroud)
如果我去原因我发现这个:
我什至删除了示例应用程序并重新部署了已上传的应用程序并收到了该特定错误。正如您在上一条消息中看到的,我已经部署了 3 次,得到了相同的结果。
src最后,我从 S3 存储桶下载了 zip 文件,基本上在和文件夹中找到了 和public文件夹,以及根文件夹中的所有文件,例如package.json、.gitignore所有 docker 文件等。
我在 github 中创建了两个单独的存储库来测试这一点。第一个存储库是 …
amazon-web-services travis-ci docker amazon-elastic-beanstalk