Flow XO Utilities
This package provides utility functions for the Flow XO platform and SDK.
Common utilities for Flow XO.
All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
limit
to getFlattenedFields() options
This limits length of the array returned
Usage:
Utils.getFlattenedFields(Object|Array, {limit: 100});
Utils.hasTZOffset()
Usage:
Utils.hasTZOffset('2017-02-22 13:26 -06:00') // true
Utils.applyTzOffset()
This doesn't make JS dates timezone aware. It 'pretends' to by shifting the date. Usage:
Utils.applyTzOffset(new Date('2017-02-22'), 'America/Chicago'); // Returns a date shifted to the timezone specified
today at 3pm
would get parsed as the next day at 3pm..parsed
property from parseDateTimeField
is completely backward compatible.Utils.parseDateTimeField()
Utils.parseDateTimeField()
Utils.parseDateTimeField(date [, Object])
takes a second optional parameter of object.
timezone
defaults to UTC
locale
defaults to en
Usage:
Utils.parseDateTimeField('today at 3pm', {
timezone: 'Europe/London',
locale: 'en-GB'
});
Upgraded Sugar Date module from 1.x to 2.x. See Sugar breaking changes
Date
object no longer gets extended with SugarDate by default. If you want to extend the Date
object you must call Utils.activateDateParser()
.
nonRetryableErrors
option to backoff module. This allows you to use your own 'non-retryable' error classes to halt the backoff if necessary.maxDuration
option to backoff module, to support abortion of backoff if the total operation time has or will exceed the maxDuration
parameter on the next retry.Backoff module is now invoked differently. Instead of creating a new Backoff
object, and passing in the minDelay
and maxDelay
, you now pass everything into the attempt
or attemptAsync
methods.
Assuming the following operation:
var operation = function() {
return new Promise(function (resolve, reject) {
request(options, function(err, res, body) {
if(err) {
return reject(err);
}
resolve(body);
}
});
Old (1.x) syntax:
var backoff = new Backoff(100, 1000);
backoff.attemptAsync(5, operation).then(res => {
// Do something with result
}, err => {
// Do something with error
})
New (2.0) syntax:
var options = {
minDelay: 100,
maxDelay: 1000,
maxAttempts: 5
};
backoff.attemptAsync(operation, options).then(res => {
// Do something with result
}, err => {
// Do something with error
})
NonRetryableError
to backoff module, to support early aborting of backoff.attemptAsync
method to backoff module.date + 90d
and date+90d
as well as date +90d
.null
values for datetime
or boolean
inputs.datetime
input annotated values.y
or n
as valid boolean values.length
property.null
.