special-query.js 835 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (c) 2015-present, Vitaly Tomilov
  3. *
  4. * See the LICENSE file at the top-level directory of this distribution
  5. * for licensing information.
  6. *
  7. * Removal or modification of this copyright notice is prohibited.
  8. */
  9. const specialQueryType = {
  10. result: 0,
  11. multiResult: 1,
  12. stream: 2
  13. };
  14. class SpecialQuery {
  15. constructor(type) {
  16. this.isResult = type === specialQueryType.result; // type used implicitly
  17. this.isStream = type === specialQueryType.stream;
  18. this.isMultiResult = type === specialQueryType.multiResult;
  19. }
  20. }
  21. const cache = {
  22. resultQuery: new SpecialQuery(specialQueryType.result),
  23. multiResultQuery: new SpecialQuery(specialQueryType.multiResult),
  24. streamQuery: new SpecialQuery(specialQueryType.stream)
  25. };
  26. module.exports = Object.assign({SpecialQuery}, cache);