bump package version to 1.0.1
[squeep-amqp-helper] / lib / publisher.js
index 19987f1fb37abc76d0f02dcbf9d666112242c0b4..0c7ac3d743d77679e51e334fdc26a9cdbc04e1ef 100644 (file)
@@ -16,11 +16,17 @@ class Publisher extends Base {
     persistent: true,
   };
 
+  /**
+   * @typedef {object} PublishOptions
+   * @property {number} timestamp timestamp in ms, defaults to current
+   * @property {boolean} persistent defaults to true
+   */
   /**
    * Send a message to an exchange.
-   * @param {String} name
-   * @param {*} content
-   * @param {Object} options
+   * @param {string} name name
+   * @param {*} content message content
+   * @param {PublishOptions} options options
+   * @returns {Promise<void>}
    */
   async publish(name, content, options) {
     const _scope = _fileScope('publish');
@@ -31,7 +37,7 @@ class Publisher extends Base {
       content = Buffer.from(typeof(content) === 'object' ? JSON.stringify(content) : content);
     }
 
-    const timestamp = (new Date()).getTime();
+    const timestamp = Date.now();
     options = {
       timestamp,
       ...Publisher.publishDefaults,
@@ -86,8 +92,7 @@ class Publisher extends Base {
 
   /**
    * Producer only needs to plumb the exchange it sends to.
-   * 
-   * @param {String} name
+   * @param {string} name name
    */
   async establishAMQPPlumbing(name) {
     const _scope = _fileScope('establishAMQPPlumbing');