我在AWS上创建了一些Lambda函数用于测试目的(命名为test_function某些东西),然后在测试后我发现这些函数可以在prod env中使用.
是否可以重命名Lambda函数?如何?或者我应该创建一个新的并复制粘贴源代码?
在ES5中,我们可以这样写:
function(a){
/* istanbul ignore next */
a = a || 123;
}
Run Code Online (Sandbox Code Playgroud)
怎么忽略在ES6?
function(a = 123 ){
}
Run Code Online (Sandbox Code Playgroud)
我试过这个:
function(/* istanbul ignore next */a = 123 ){
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
没有一口气,我就跑了eslint ./src --fix.我无法弄清楚如何用gulp实现这一点.我尝试下面,将修复设置为true,但它不修复任何文件:
gulp.task('lint', ['./src/**.js'], () => {
return gulp.src()
.pipe($.eslint({fix:true}))
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
});
Run Code Online (Sandbox Code Playgroud)
我希望./src修复所有文件.我该如何实现这一目标?
我怎样才能正确投掷?它是连线的,对于同一个函数,throw和not.throw 都通过了测试
jsfiddle 上也提供了代码,https: //jsfiddle.net/8t5bf261/
class Person {
constructor(age) {
if (Object.prototype.toString.call(age) !== '[object Number]') throw 'NOT A NUMBER'
this.age = age;
}
howold() {
console.log(this.age);
}
}
var should = chai.should();
mocha.setup('bdd');
describe('Person', function() {
it('should throw if input is not a number', function() {
(function() {
var p1 = new Person('sadf');
}).should.not.throw;
(function() {
var p2 = new Person('sdfa');
}).should.throw;
})
})
mocha.run();Run Code Online (Sandbox Code Playgroud)
<div id="mocha"></div>
<link href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.4.5/mocha.css" rel="stylesheet" />
<script src="https://cdn.rawgit.com/jquery/jquery/2.1.4/dist/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.4.5/mocha.min.js"></script> …Run Code Online (Sandbox Code Playgroud)ecmascript-6 ×2
aws-lambda ×1
babeljs ×1
chai ×1
class ×1
eslint ×1
gulp ×1
istanbul ×1
javascript ×1
node.js ×1
rename ×1
throw ×1