LoggerSerializers.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* eslint-disable
  2. no-return-assign,
  3. */
  4. // TODO: This file was created by bulk-decaffeinate.
  5. // Fix any style issues and re-enable lint.
  6. /*
  7. * decaffeinate suggestions:
  8. * DS102: Remove unnecessary code created because of implicit returns
  9. * DS207: Consider shorter variations of null checks
  10. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  11. */
  12. const _ = require('lodash')
  13. const showLength = function (thing) {
  14. if (thing != null ? thing.length : undefined) {
  15. return thing.length
  16. } else {
  17. return thing
  18. }
  19. }
  20. const showUpdateLength = function (update) {
  21. if ((update != null ? update.op : undefined) instanceof Array) {
  22. const copy = _.cloneDeep(update)
  23. copy.op.forEach(function (element, index) {
  24. if (element?.i?.length != null) {
  25. copy.op[index].i = element.i.length
  26. }
  27. if (element?.d?.length != null) {
  28. copy.op[index].d = element.d.length
  29. }
  30. if (element?.c?.length != null) {
  31. return (copy.op[index].c = element.c.length)
  32. }
  33. })
  34. return copy
  35. } else {
  36. return update
  37. }
  38. }
  39. module.exports = {
  40. // replace long values with their length
  41. lines: showLength,
  42. oldLines: showLength,
  43. newLines: showLength,
  44. docLines: showLength,
  45. newDocLines: showLength,
  46. ranges: showLength,
  47. update: showUpdateLength,
  48. }