A helper for declaring your assumptions about method arguments.
function someFunction(a, b, c) {
args(someFunction, function(){
args.expect(a).toBeDefined();
args.expect(c).not.toBeTruthy();
});
}
function someFunction(a, b, c) {
args(someFunction, () => {
args.expect(a).toBeDefined();
args.expect(c).not.toBeTruthy();
});
}
function someFunction(a, b, c, success, err) {
if (args(someFunction,
function(){
args.expect(a).toBeDefined();
},
err)) {
return;
}
}
It is very easy to misuse javascript functions
I had been using Catel for some time and after some initial skepticism found their argument checking extremely useful. In fact I am really convinced that such partial design by contract at arguments level is even more important for such nonrestrictive language as Javascript.
Assertions code for args.expect was heavily borrowed from Jasmine