Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | "use strict";
const _ = require("lodash");
const TYPE = {
COUNT: 1,
LIST: 2,
ENTITY: 3,
LIST_STREAM: 4,
ENTITY_STREAM: 5,
};
exports.COUNT = TYPE.COUNT;
exports.LIST = TYPE.LIST;
exports.ENTITY = TYPE.ENTITY;
exports.LIST_STREAM = TYPE.LIST_STREAM;
exports.ENTITY_STREAM = TYPE.ENTITY_STREAM;
exports.probes = {};
exports.probes[TYPE.COUNT] = function (request) {
return request._isCount === true;
};
exports.probes[TYPE.LIST] = function (request, resource) {
return Boolean(request._isList) && !resource.entityTypeModel.hasStream;
};
exports.probes[TYPE.ENTITY] = function (request, resource) {
return Boolean(request._isEntity) && !resource.entityTypeModel.hasStream;
};
exports.probes[TYPE.LIST_STREAM] = function (request, resource) {
return !request._isEntity && Boolean(resource.entityTypeModel.hasStream);
};
exports.probes[TYPE.ENTITY_STREAM] = function (request, resource) {
return (
Boolean(request._isEntity) && Boolean(resource.entityTypeModel.hasStream)
);
};
exports.determine = function (request, resource) {
return _.find(TYPE, (value, key) =>
exports.probes[TYPE[key]](request, resource)
);
};
|