From 2edd35a83955e976f68c2be0dda3cd67a3248b44 Mon Sep 17 00:00:00 2001 From: Brandon Ros Date: Wed, 10 Aug 2022 01:25:20 -0400 Subject: [PATCH] commonjs -> ecmascript modules --- index.js | 1 - index.mjs | 2 ++ lib/{retry.js => retry.mjs} | 6 +++++- lib/{retry_operation.js => retry_operation.mjs} | 3 ++- package.json | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) delete mode 100644 index.js create mode 100644 index.mjs rename lib/{retry.js => retry.mjs} (96%) rename lib/{retry_operation.js => retry_operation.mjs} (99%) diff --git a/index.js b/index.js deleted file mode 100644 index ee62f3a..0000000 --- a/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./lib/retry'); \ No newline at end of file diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6615177 --- /dev/null +++ b/index.mjs @@ -0,0 +1,2 @@ +import retry from './lib/retry.mjs' +export default retry diff --git a/lib/retry.js b/lib/retry.mjs similarity index 96% rename from lib/retry.js rename to lib/retry.mjs index 5e85e79..2fe9da6 100644 --- a/lib/retry.js +++ b/lib/retry.mjs @@ -1,4 +1,6 @@ -var RetryOperation = require('./retry_operation'); +import RetryOperation from './retry_operation.mjs' + +var exports = {} exports.operation = function(options) { var timeouts = exports.timeouts(options); @@ -98,3 +100,5 @@ exports.wrap = function(obj, options, methods) { obj[method].options = options; } }; + +export default exports diff --git a/lib/retry_operation.js b/lib/retry_operation.mjs similarity index 99% rename from lib/retry_operation.js rename to lib/retry_operation.mjs index 105ce72..2c03fb7 100644 --- a/lib/retry_operation.js +++ b/lib/retry_operation.mjs @@ -21,7 +21,6 @@ function RetryOperation(timeouts, options) { this._cachedTimeouts = this._timeouts.slice(0); } } -module.exports = RetryOperation; RetryOperation.prototype.reset = function() { this._attempts = 1; @@ -160,3 +159,5 @@ RetryOperation.prototype.mainError = function() { return mainError; }; + +export default RetryOperation diff --git a/package.json b/package.json index 4e72bef..bd601f6 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "directories": { "lib": "./lib" }, - "main": "index.js", + "main": "index.mjs", "engines": { "node": ">= 4" },