utils.js 448 B

1234567891011121314151617181920
  1. const IDS = new WeakMap()
  2. const INCREMENT = {
  3. Connection: 1,
  4. ConnectionPool: 1,
  5. Request: 1,
  6. Transaction: 1,
  7. PreparedStatement: 1
  8. }
  9. module.exports = {
  10. objectHasProperty: (object, property) => Object.prototype.hasOwnProperty.call(object, property),
  11. INCREMENT: INCREMENT,
  12. IDS: {
  13. get: IDS.get.bind(IDS),
  14. add: (object, type, id) => {
  15. if (id) return IDS.set(object, id)
  16. IDS.set(object, INCREMENT[type]++)
  17. }
  18. }
  19. }