mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
25 lines
386 B
JavaScript
25 lines
386 B
JavaScript
var makeAFailure = (function() {
|
|
function onSuccess(data) {}
|
|
|
|
function onFailure(data) {
|
|
throw new Error('failed!');
|
|
}
|
|
|
|
function invoke(data) {
|
|
var cb = null;
|
|
if (data.failed) {
|
|
cb = onFailure;
|
|
} else {
|
|
cb = onSuccess;
|
|
}
|
|
cb(data);
|
|
}
|
|
|
|
function test() {
|
|
var data = {failed: true, value: 42};
|
|
invoke(data);
|
|
}
|
|
|
|
return test;
|
|
})();
|