Comparing version 2.4.0 to 2.4.1
@@ -174,5 +174,12 @@ const opentracing = require('opentracing') | ||
if (opts.hasOwnProperty('delay')) { | ||
parsedOpts.delay = (typeof opts.delay === 'string') | ||
? ms(opts.delay) | ||
: opts.delay | ||
if (typeof opts.delay === 'string') { | ||
parsedOpts.delay = ms(opts.delay) | ||
parsedOpts.schedule = null | ||
} else if (opts.delay instanceof Date && !isNaN(opts.delay)) { | ||
parsedOpts.delay = null | ||
parsedOpts.schedule = opts.delay | ||
} else { | ||
parsedOpts.delay = opts.delay | ||
parsedOpts.schedule = null | ||
} | ||
} | ||
@@ -192,3 +199,3 @@ | ||
) { | ||
throw new Error('Invalid schedule date or delay duration when attempting to send a delayed emission') | ||
throw new Error('Invalid delay date or duration when attempting to send a delayed emission') | ||
} | ||
@@ -195,0 +202,0 @@ |
{ | ||
"name": "remit", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"description": "A small set of functionality used to create microservices that don't need to be aware of one-another's existence.", | ||
@@ -17,12 +17,12 @@ "main": "index.js", | ||
"dependencies": { | ||
"amqplib": "^0.5.1", | ||
"callable-instance": "^1.0.0", | ||
"amqplib": "^0.5.3", | ||
"callable-instance": "^1.0.1", | ||
"callsite": "^1.0.0", | ||
"cls-hooked": "^4.2.2", | ||
"eventemitter3": "^3.0.0", | ||
"generic-pool": "^3.1.7", | ||
"eventemitter3": "^3.1.0", | ||
"generic-pool": "^3.7.1", | ||
"ms": "^2.1.1", | ||
"opentracing": "^0.14.3", | ||
"serialize-error": "^2.1.0", | ||
"ulid": "^2.2.0" | ||
"serialize-error": "^4.0.0", | ||
"ulid": "^2.3.0" | ||
}, | ||
@@ -60,7 +60,7 @@ "repository": { | ||
"devDependencies": { | ||
"chai": "^4.1.1", | ||
"coveralls": "^3.0.0", | ||
"mocha": "^5.0.0", | ||
"nyc": "^11.1.0" | ||
"chai": "^4.2.0", | ||
"coveralls": "^3.0.3", | ||
"mocha": "^6.0.2", | ||
"nyc": "^13.3.0" | ||
} | ||
} |
@@ -76,8 +76,22 @@ /* global describe, it, before, expect */ | ||
it('should parse timestrings in a delay option', function () { | ||
it('should parse timestrings and dates in a delay option', function () { | ||
const emit = emitRemit.emit('options-timestring-test') | ||
emit.options({delay: 20000}) | ||
expect(emit._options).to.have.property('delay', 20000) | ||
expect(emit._options).to.have.property('schedule', null) | ||
const d = new Date() | ||
d.setSeconds(d.getSeconds() + 15) | ||
emit.options({delay: d}) | ||
expect(emit._options).to.have.property('delay', null) | ||
expect(emit._options).to.have.property('schedule', d) | ||
emit.options({delay: '30m'}) | ||
expect(emit._options).to.have.property('delay', 1800000) | ||
expect(emit._options).to.have.property('schedule', null) | ||
emit.options({delay: '2s'}) | ||
expect(emit._options).to.have.property('delay', 2000) | ||
expect(emit._options).to.have.property('schedule', null) | ||
}) | ||
@@ -182,3 +196,3 @@ | ||
.emit('emit-usage') | ||
.options({schedule: d}) | ||
.options({delay: d}) | ||
.send({bar: 'baz'}) | ||
@@ -185,0 +199,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94855
2083
+ Addedserialize-error@4.1.0(transitive)
+ Addedtype-fest@0.3.1(transitive)
- Removedserialize-error@2.1.0(transitive)
Updatedamqplib@^0.5.3
Updatedcallable-instance@^1.0.1
Updatedeventemitter3@^3.1.0
Updatedgeneric-pool@^3.7.1
Updatedserialize-error@^4.0.0
Updatedulid@^2.3.0