@dereekb/util 11.0.12 → 11.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fetch/index.cjs.js +140 -25
- package/fetch/index.esm.js +74 -4
- package/fetch/package.json +1 -1
- package/fetch/src/lib/fetch.d.ts +23 -0
- package/fetch/src/lib/fetch.limit.d.ts +33 -0
- package/fetch/src/lib/index.d.ts +1 -0
- package/fetch/src/lib/provider.d.ts +7 -0
- package/index.cjs.js +211 -0
- package/index.esm.js +228 -1
- package/package.json +1 -1
- package/src/lib/number/number.d.ts +12 -0
- package/src/lib/promise/index.d.ts +1 -0
- package/src/lib/promise/promise.limit.d.ts +131 -0
- package/test/CHANGELOG.md +8 -0
- package/test/package.json +1 -1
package/fetch/index.cjs.js
CHANGED
|
@@ -4922,7 +4922,7 @@ function fetchTimeout(inputFetch) {
|
|
|
4922
4922
|
* @returns
|
|
4923
4923
|
*/
|
|
4924
4924
|
|
|
4925
|
-
function _await$
|
|
4925
|
+
function _await$3(value, then, direct) {
|
|
4926
4926
|
if (direct) {
|
|
4927
4927
|
return then ? then(value) : value;
|
|
4928
4928
|
}
|
|
@@ -4931,13 +4931,13 @@ function _await$2(value, then, direct) {
|
|
|
4931
4931
|
}
|
|
4932
4932
|
return then ? value.then(then) : value;
|
|
4933
4933
|
} /**
|
|
4934
|
-
*
|
|
4935
|
-
*
|
|
4936
|
-
* @param
|
|
4934
|
+
* Default FetchHabdler
|
|
4935
|
+
* @param request
|
|
4936
|
+
* @param makeFetch
|
|
4937
4937
|
* @returns
|
|
4938
4938
|
*/
|
|
4939
4939
|
|
|
4940
|
-
function _async$
|
|
4940
|
+
function _async$3(f) {
|
|
4941
4941
|
return function () {
|
|
4942
4942
|
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
4943
4943
|
args[i] = arguments[i];
|
|
@@ -4956,7 +4956,7 @@ function _invokeIgnored(body) {
|
|
|
4956
4956
|
return result.then(_empty);
|
|
4957
4957
|
}
|
|
4958
4958
|
}
|
|
4959
|
-
function _invoke(body, then) {
|
|
4959
|
+
function _invoke$1(body, then) {
|
|
4960
4960
|
var result = body();
|
|
4961
4961
|
if (result && result.then) {
|
|
4962
4962
|
return result.then(then);
|
|
@@ -4974,7 +4974,7 @@ function _call(body, then, direct) {
|
|
|
4974
4974
|
return Promise.reject(e);
|
|
4975
4975
|
}
|
|
4976
4976
|
}
|
|
4977
|
-
function _catch(body, recover) {
|
|
4977
|
+
function _catch$1(body, recover) {
|
|
4978
4978
|
try {
|
|
4979
4979
|
var result = body();
|
|
4980
4980
|
} catch (e) {
|
|
@@ -5005,9 +5005,17 @@ function fetchService(config) {
|
|
|
5005
5005
|
};
|
|
5006
5006
|
return factory;
|
|
5007
5007
|
}
|
|
5008
|
+
const DEFAULT_FETCH_HANDLER = (request, makeFetch) => makeFetch(request);
|
|
5009
|
+
/**
|
|
5010
|
+
* Creates a function that wraps fetch and uses a FetchRequestFactory to generate a Request before invoking Fetch.
|
|
5011
|
+
*
|
|
5012
|
+
* @param config
|
|
5013
|
+
* @returns
|
|
5014
|
+
*/
|
|
5008
5015
|
function configureFetch(config) {
|
|
5009
5016
|
const {
|
|
5010
5017
|
makeFetch: inputMakeFetch = fetch,
|
|
5018
|
+
fetchHandler = DEFAULT_FETCH_HANDLER,
|
|
5011
5019
|
useTimeout,
|
|
5012
5020
|
requireOkResponse: inputRequireOkResponse,
|
|
5013
5021
|
mapResponse
|
|
@@ -5022,9 +5030,9 @@ function configureFetch(config) {
|
|
|
5022
5030
|
makeFetch = fetchOk(makeFetch);
|
|
5023
5031
|
}
|
|
5024
5032
|
const makeFetchRequest = fetchRequestFactory(config);
|
|
5025
|
-
return _async$
|
|
5026
|
-
return _await$
|
|
5027
|
-
let response =
|
|
5033
|
+
return _async$3(function (input, init) {
|
|
5034
|
+
return _await$3(makeFetchRequest(input, init), function (request) {
|
|
5035
|
+
let response = fetchHandler(request, makeFetch);
|
|
5028
5036
|
if (mapResponse) {
|
|
5029
5037
|
response = mapResponse(response);
|
|
5030
5038
|
}
|
|
@@ -5032,10 +5040,18 @@ function configureFetch(config) {
|
|
|
5032
5040
|
});
|
|
5033
5041
|
});
|
|
5034
5042
|
}
|
|
5043
|
+
/**
|
|
5044
|
+
* The deafult FetchRequestFactory implementation that uses window/global Request.
|
|
5045
|
+
*
|
|
5046
|
+
* @param input
|
|
5047
|
+
* @param init
|
|
5048
|
+
* @returns
|
|
5049
|
+
*/
|
|
5050
|
+
const DEFAULT_FETCH_REQUEST_FACTORY = (input, init) => new Request(input, init);
|
|
5035
5051
|
function fetchRequestFactory(config) {
|
|
5036
|
-
const asFetchRequest = _async$
|
|
5052
|
+
const asFetchRequest = _async$3(function (input) {
|
|
5037
5053
|
const _isPromiseLike = util.isPromiseLike(input);
|
|
5038
|
-
return _await$
|
|
5054
|
+
return _await$3(input, function (awaitedInput) {
|
|
5039
5055
|
if (isFetchRequest(awaitedInput)) {
|
|
5040
5056
|
return awaitedInput;
|
|
5041
5057
|
} else {
|
|
@@ -5044,7 +5060,7 @@ function fetchRequestFactory(config) {
|
|
|
5044
5060
|
}, !_isPromiseLike);
|
|
5045
5061
|
});
|
|
5046
5062
|
const {
|
|
5047
|
-
makeRequest =
|
|
5063
|
+
makeRequest = DEFAULT_FETCH_REQUEST_FACTORY,
|
|
5048
5064
|
baseUrl: inputBaseUrl,
|
|
5049
5065
|
baseRequest: inputBaseRequest,
|
|
5050
5066
|
timeout,
|
|
@@ -5058,11 +5074,11 @@ function fetchRequestFactory(config) {
|
|
|
5058
5074
|
const result = new URL(urlPath, baseUrl);
|
|
5059
5075
|
return result;
|
|
5060
5076
|
} : undefined;
|
|
5061
|
-
const buildRequestWithFixedUrl = buildUrl ? _async$
|
|
5077
|
+
const buildRequestWithFixedUrl = buildUrl ? _async$3(function (input) {
|
|
5062
5078
|
let relativeUrl;
|
|
5063
5079
|
let baseRequest;
|
|
5064
5080
|
let request;
|
|
5065
|
-
return _invoke(function () {
|
|
5081
|
+
return _invoke$1(function () {
|
|
5066
5082
|
if (typeof input === 'string') {
|
|
5067
5083
|
relativeUrl = input;
|
|
5068
5084
|
} else return _invokeIgnored(function () {
|
|
@@ -5074,16 +5090,16 @@ function fetchRequestFactory(config) {
|
|
|
5074
5090
|
request = input;
|
|
5075
5091
|
}
|
|
5076
5092
|
} else {
|
|
5077
|
-
return _await$
|
|
5093
|
+
return _await$3(makeRequest(input), function (_makeRequest) {
|
|
5078
5094
|
request = _makeRequest;
|
|
5079
5095
|
});
|
|
5080
5096
|
}
|
|
5081
5097
|
});
|
|
5082
5098
|
}, function () {
|
|
5083
|
-
return _invoke(function () {
|
|
5099
|
+
return _invoke$1(function () {
|
|
5084
5100
|
if (!request) {
|
|
5085
5101
|
const url = buildUrl(relativeUrl);
|
|
5086
|
-
return _await$
|
|
5102
|
+
return _await$3(makeRequest(url.href, baseRequest), function (_makeRequest2) {
|
|
5087
5103
|
request = _makeRequest2;
|
|
5088
5104
|
});
|
|
5089
5105
|
}
|
|
@@ -5096,7 +5112,7 @@ function fetchRequestFactory(config) {
|
|
|
5096
5112
|
if (inputBaseRequest != null || timeout != null) {
|
|
5097
5113
|
const combineRequestInits = function combineRequestInits(request, requestInit) {
|
|
5098
5114
|
return _call(computeBaseRequest, function (baseRequest) {
|
|
5099
|
-
return _await$
|
|
5115
|
+
return _await$3(requestInit, function (_requestInit) {
|
|
5100
5116
|
const merged = mergeRequestInits(baseRequest, _requestInit);
|
|
5101
5117
|
const timeout = merged.timeout === undefined ? request.timeout : merged.timeout;
|
|
5102
5118
|
return Object.assign({}, merged, {
|
|
@@ -5124,12 +5140,12 @@ function fetchRequestFactory(config) {
|
|
|
5124
5140
|
} else {
|
|
5125
5141
|
buildRequestInit = (_, x) => x;
|
|
5126
5142
|
}
|
|
5127
|
-
return _async$
|
|
5128
|
-
return _catch(function () {
|
|
5129
|
-
return _await$
|
|
5130
|
-
return _await$
|
|
5143
|
+
return _async$3(function (input, init) {
|
|
5144
|
+
return _catch$1(function () {
|
|
5145
|
+
return _await$3(buildRequestWithFixedUrl(input), function (fixedRequest) {
|
|
5146
|
+
return _await$3(buildRequestInit(fixedRequest, init), function (_buildRequestInit) {
|
|
5131
5147
|
init = _buildRequestInit;
|
|
5132
|
-
return _await$
|
|
5148
|
+
return _await$3(makeRequest(fixedRequest, init), function (request) {
|
|
5133
5149
|
request.timeout = timeout; // copy/set timeout on the request directly
|
|
5134
5150
|
return request;
|
|
5135
5151
|
});
|
|
@@ -5191,6 +5207,93 @@ function isFetchRequest(input) {
|
|
|
5191
5207
|
return Boolean(input.url);
|
|
5192
5208
|
}
|
|
5193
5209
|
|
|
5210
|
+
function _await$2(value, then, direct) {
|
|
5211
|
+
if (direct) {
|
|
5212
|
+
return then ? then(value) : value;
|
|
5213
|
+
}
|
|
5214
|
+
if (!value || !value.then) {
|
|
5215
|
+
value = Promise.resolve(value);
|
|
5216
|
+
}
|
|
5217
|
+
return then ? value.then(then) : value;
|
|
5218
|
+
}
|
|
5219
|
+
function _catch(body, recover) {
|
|
5220
|
+
try {
|
|
5221
|
+
var result = body();
|
|
5222
|
+
} catch (e) {
|
|
5223
|
+
return recover(e);
|
|
5224
|
+
}
|
|
5225
|
+
if (result && result.then) {
|
|
5226
|
+
return result.then(void 0, recover);
|
|
5227
|
+
}
|
|
5228
|
+
return result;
|
|
5229
|
+
}
|
|
5230
|
+
function _invoke(body, then) {
|
|
5231
|
+
var result = body();
|
|
5232
|
+
if (result && result.then) {
|
|
5233
|
+
return result.then(then);
|
|
5234
|
+
}
|
|
5235
|
+
return then(result);
|
|
5236
|
+
}
|
|
5237
|
+
function _continue(value, then) {
|
|
5238
|
+
return value && value.then ? value.then(then) : then(value);
|
|
5239
|
+
}
|
|
5240
|
+
function _async$2(f) {
|
|
5241
|
+
return function () {
|
|
5242
|
+
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
5243
|
+
args[i] = arguments[i];
|
|
5244
|
+
}
|
|
5245
|
+
try {
|
|
5246
|
+
return Promise.resolve(f.apply(this, args));
|
|
5247
|
+
} catch (e) {
|
|
5248
|
+
return Promise.reject(e);
|
|
5249
|
+
}
|
|
5250
|
+
};
|
|
5251
|
+
}
|
|
5252
|
+
function rateLimitedFetchHandler(config) {
|
|
5253
|
+
const {
|
|
5254
|
+
updateWithResponse,
|
|
5255
|
+
maxRetries: inputMaxRetries
|
|
5256
|
+
} = config;
|
|
5257
|
+
const maxRetries = inputMaxRetries != null ? inputMaxRetries : 1;
|
|
5258
|
+
const _rateLimiter = config.rateLimiter;
|
|
5259
|
+
const fetchHandler = function fetchHandler(request, makeFetch) {
|
|
5260
|
+
const tryFetch = _async$2(function (retriesAttempted) {
|
|
5261
|
+
// wait for the rate limiter
|
|
5262
|
+
return _await$2(_rateLimiter.waitForRateLimit(), function () {
|
|
5263
|
+
let response;
|
|
5264
|
+
let fetchResponseError;
|
|
5265
|
+
return _continue(_catch(function () {
|
|
5266
|
+
return _await$2(makeFetch(request), function (_makeFetch) {
|
|
5267
|
+
response = _makeFetch;
|
|
5268
|
+
});
|
|
5269
|
+
}, function (e) {
|
|
5270
|
+
fetchResponseError = e;
|
|
5271
|
+
response = fetchResponseError.response;
|
|
5272
|
+
}), function () {
|
|
5273
|
+
return _await$2(updateWithResponse(response, fetchResponseError), function (shouldRetry) {
|
|
5274
|
+
return _invoke(function () {
|
|
5275
|
+
if (shouldRetry && retriesAttempted < maxRetries) {
|
|
5276
|
+
return _await$2(tryFetch(retriesAttempted + 1), function (_tryFetch) {
|
|
5277
|
+
response = _tryFetch;
|
|
5278
|
+
});
|
|
5279
|
+
} else {
|
|
5280
|
+
if (fetchResponseError != null) {
|
|
5281
|
+
throw fetchResponseError;
|
|
5282
|
+
}
|
|
5283
|
+
}
|
|
5284
|
+
}, function (_result) {
|
|
5285
|
+
return response;
|
|
5286
|
+
});
|
|
5287
|
+
});
|
|
5288
|
+
});
|
|
5289
|
+
});
|
|
5290
|
+
});
|
|
5291
|
+
return tryFetch(0);
|
|
5292
|
+
};
|
|
5293
|
+
fetchHandler._rateLimiter = _rateLimiter;
|
|
5294
|
+
return fetchHandler;
|
|
5295
|
+
}
|
|
5296
|
+
|
|
5194
5297
|
function _await$1(value, then, direct) {
|
|
5195
5298
|
if (direct) {
|
|
5196
5299
|
return then ? then(value) : value;
|
|
@@ -5694,11 +5797,21 @@ function fetchJsonRequestInitFunction(config = {}) {
|
|
|
5694
5797
|
}
|
|
5695
5798
|
const fetchJsonRequestInit = fetchJsonRequestInitFunction();
|
|
5696
5799
|
|
|
5697
|
-
|
|
5800
|
+
/**
|
|
5801
|
+
* Default FetchService implementation that uses the native Fetch api.
|
|
5802
|
+
*/
|
|
5803
|
+
const fetchApiFetchService = fetchService({
|
|
5698
5804
|
makeFetch: fetch,
|
|
5699
5805
|
makeRequest: (x, y) => new Request(x, y)
|
|
5700
5806
|
});
|
|
5807
|
+
// MARK: Compat
|
|
5808
|
+
/**
|
|
5809
|
+
* @deprecated use fetchApiFetchService instead. This is an alias.
|
|
5810
|
+
*/
|
|
5811
|
+
const nodeFetchService = fetchApiFetchService;
|
|
5701
5812
|
|
|
5813
|
+
exports.DEFAULT_FETCH_HANDLER = DEFAULT_FETCH_HANDLER;
|
|
5814
|
+
exports.DEFAULT_FETCH_REQUEST_FACTORY = DEFAULT_FETCH_REQUEST_FACTORY;
|
|
5702
5815
|
exports.FETCH_PAGE_FACTORY_DEFAULT_MAX_PAGE = FETCH_PAGE_FACTORY_DEFAULT_MAX_PAGE;
|
|
5703
5816
|
exports.FetchPageLimitReachedError = FetchPageLimitReachedError;
|
|
5704
5817
|
exports.FetchPageNoNextPageError = FetchPageNoNextPageError;
|
|
@@ -5707,6 +5820,7 @@ exports.FetchResponseError = FetchResponseError;
|
|
|
5707
5820
|
exports.FetchTimeoutError = FetchTimeoutError;
|
|
5708
5821
|
exports.JsonResponseParseError = JsonResponseParseError;
|
|
5709
5822
|
exports.configureFetch = configureFetch;
|
|
5823
|
+
exports.fetchApiFetchService = fetchApiFetchService;
|
|
5710
5824
|
exports.fetchJsonBodyString = fetchJsonBodyString;
|
|
5711
5825
|
exports.fetchJsonFunction = fetchJsonFunction;
|
|
5712
5826
|
exports.fetchJsonRequestInit = fetchJsonRequestInit;
|
|
@@ -5731,6 +5845,7 @@ exports.mergeRequestHeaders = mergeRequestHeaders;
|
|
|
5731
5845
|
exports.mergeRequestInits = mergeRequestInits;
|
|
5732
5846
|
exports.nodeFetchService = nodeFetchService;
|
|
5733
5847
|
exports.queryParamsToSearchParams = queryParamsToSearchParams;
|
|
5848
|
+
exports.rateLimitedFetchHandler = rateLimitedFetchHandler;
|
|
5734
5849
|
exports.requireOkResponse = requireOkResponse;
|
|
5735
5850
|
exports.returnNullHandleFetchJsonParseErrorFunction = returnNullHandleFetchJsonParseErrorFunction;
|
|
5736
5851
|
exports.throwJsonResponseParseErrorFunction = throwJsonResponseParseErrorFunction;
|
package/fetch/index.esm.js
CHANGED
|
@@ -4946,6 +4946,18 @@ function fetchService(config) {
|
|
|
4946
4946
|
|
|
4947
4947
|
// MARK: Make Fetch
|
|
4948
4948
|
|
|
4949
|
+
/**
|
|
4950
|
+
* Custom fetch handler that takes in a Request and fetch function and returns a Response.
|
|
4951
|
+
*/
|
|
4952
|
+
|
|
4953
|
+
/**
|
|
4954
|
+
* Default FetchHabdler
|
|
4955
|
+
* @param request
|
|
4956
|
+
* @param makeFetch
|
|
4957
|
+
* @returns
|
|
4958
|
+
*/
|
|
4959
|
+
const DEFAULT_FETCH_HANDLER = (request, makeFetch) => makeFetch(request);
|
|
4960
|
+
|
|
4949
4961
|
/**
|
|
4950
4962
|
* Creates a function that wraps fetch and uses a FetchRequestFactory to generate a Request before invoking Fetch.
|
|
4951
4963
|
*
|
|
@@ -4955,6 +4967,7 @@ function fetchService(config) {
|
|
|
4955
4967
|
function configureFetch(config) {
|
|
4956
4968
|
const {
|
|
4957
4969
|
makeFetch: inputMakeFetch = fetch,
|
|
4970
|
+
fetchHandler = DEFAULT_FETCH_HANDLER,
|
|
4958
4971
|
useTimeout,
|
|
4959
4972
|
requireOkResponse: inputRequireOkResponse,
|
|
4960
4973
|
mapResponse
|
|
@@ -4971,7 +4984,7 @@ function configureFetch(config) {
|
|
|
4971
4984
|
const makeFetchRequest = fetchRequestFactory(config);
|
|
4972
4985
|
return async (input, init) => {
|
|
4973
4986
|
const request = await makeFetchRequest(input, init);
|
|
4974
|
-
let response =
|
|
4987
|
+
let response = fetchHandler(request, makeFetch);
|
|
4975
4988
|
if (mapResponse) {
|
|
4976
4989
|
response = mapResponse(response);
|
|
4977
4990
|
}
|
|
@@ -4981,9 +4994,17 @@ function configureFetch(config) {
|
|
|
4981
4994
|
|
|
4982
4995
|
// MARK: Request
|
|
4983
4996
|
|
|
4997
|
+
/**
|
|
4998
|
+
* The deafult FetchRequestFactory implementation that uses window/global Request.
|
|
4999
|
+
*
|
|
5000
|
+
* @param input
|
|
5001
|
+
* @param init
|
|
5002
|
+
* @returns
|
|
5003
|
+
*/
|
|
5004
|
+
const DEFAULT_FETCH_REQUEST_FACTORY = (input, init) => new Request(input, init);
|
|
4984
5005
|
function fetchRequestFactory(config) {
|
|
4985
5006
|
const {
|
|
4986
|
-
makeRequest =
|
|
5007
|
+
makeRequest = DEFAULT_FETCH_REQUEST_FACTORY,
|
|
4987
5008
|
baseUrl: inputBaseUrl,
|
|
4988
5009
|
baseRequest: inputBaseRequest,
|
|
4989
5010
|
timeout,
|
|
@@ -5118,6 +5139,46 @@ function isFetchRequest(input) {
|
|
|
5118
5139
|
return Boolean(input.url);
|
|
5119
5140
|
}
|
|
5120
5141
|
|
|
5142
|
+
/**
|
|
5143
|
+
* A FetchRequestFactory with PromiseRateLimiter
|
|
5144
|
+
*/
|
|
5145
|
+
|
|
5146
|
+
function rateLimitedFetchHandler(config) {
|
|
5147
|
+
const {
|
|
5148
|
+
updateWithResponse,
|
|
5149
|
+
maxRetries: inputMaxRetries
|
|
5150
|
+
} = config;
|
|
5151
|
+
const maxRetries = inputMaxRetries != null ? inputMaxRetries : 1;
|
|
5152
|
+
const _rateLimiter = config.rateLimiter;
|
|
5153
|
+
const fetchHandler = async (request, makeFetch) => {
|
|
5154
|
+
async function tryFetch(retriesAttempted) {
|
|
5155
|
+
// wait for the rate limiter
|
|
5156
|
+
await _rateLimiter.waitForRateLimit();
|
|
5157
|
+
let response;
|
|
5158
|
+
let fetchResponseError;
|
|
5159
|
+
try {
|
|
5160
|
+
response = await makeFetch(request);
|
|
5161
|
+
} catch (e) {
|
|
5162
|
+
fetchResponseError = e;
|
|
5163
|
+
response = fetchResponseError.response;
|
|
5164
|
+
}
|
|
5165
|
+
const shouldRetry = await updateWithResponse(response, fetchResponseError);
|
|
5166
|
+
if (shouldRetry && retriesAttempted < maxRetries) {
|
|
5167
|
+
response = await tryFetch(retriesAttempted + 1);
|
|
5168
|
+
} else {
|
|
5169
|
+
// re-throw the fetch response error if it exists and we cannot retry
|
|
5170
|
+
if (fetchResponseError != null) {
|
|
5171
|
+
throw fetchResponseError;
|
|
5172
|
+
}
|
|
5173
|
+
}
|
|
5174
|
+
return response;
|
|
5175
|
+
}
|
|
5176
|
+
return tryFetch(0);
|
|
5177
|
+
};
|
|
5178
|
+
fetchHandler._rateLimiter = _rateLimiter;
|
|
5179
|
+
return fetchHandler;
|
|
5180
|
+
}
|
|
5181
|
+
|
|
5121
5182
|
class FetchPageNoNextPageError extends FetchRequestFactoryError {
|
|
5122
5183
|
constructor(page) {
|
|
5123
5184
|
super(`There was no next page for this.`);
|
|
@@ -5621,9 +5682,18 @@ function fetchJsonRequestInitFunction(config = {}) {
|
|
|
5621
5682
|
}
|
|
5622
5683
|
const fetchJsonRequestInit = fetchJsonRequestInitFunction();
|
|
5623
5684
|
|
|
5624
|
-
|
|
5685
|
+
/**
|
|
5686
|
+
* Default FetchService implementation that uses the native Fetch api.
|
|
5687
|
+
*/
|
|
5688
|
+
const fetchApiFetchService = fetchService({
|
|
5625
5689
|
makeFetch: fetch,
|
|
5626
5690
|
makeRequest: (x, y) => new Request(x, y)
|
|
5627
5691
|
});
|
|
5628
5692
|
|
|
5629
|
-
|
|
5693
|
+
// MARK: Compat
|
|
5694
|
+
/**
|
|
5695
|
+
* @deprecated use fetchApiFetchService instead. This is an alias.
|
|
5696
|
+
*/
|
|
5697
|
+
const nodeFetchService = fetchApiFetchService;
|
|
5698
|
+
|
|
5699
|
+
export { DEFAULT_FETCH_HANDLER, DEFAULT_FETCH_REQUEST_FACTORY, FETCH_PAGE_FACTORY_DEFAULT_MAX_PAGE, FetchPageLimitReachedError, FetchPageNoNextPageError, FetchRequestFactoryError, FetchResponseError, FetchTimeoutError, JsonResponseParseError, configureFetch, fetchApiFetchService, fetchJsonBodyString, fetchJsonFunction, fetchJsonRequestInit, fetchJsonRequestInitFunction, fetchOk, fetchPageFactory, fetchRequestFactory, fetchService, fetchTimeout, fetchURL, fetchURLQueryKeyValueStringTuples, fetchURLSearchParamsObjectToURLSearchParams, headersToHeadersTuple, isFetchRequest, isURL, isURLSearchParams, iterateFetchPages, iterateFetchPagesByEachItem, iterateFetchPagesByItems, makeUrlSearchParams, mergeRequestHeaders, mergeRequestInits, nodeFetchService, queryParamsToSearchParams, rateLimitedFetchHandler, requireOkResponse, returnNullHandleFetchJsonParseErrorFunction, throwJsonResponseParseErrorFunction };
|
package/fetch/package.json
CHANGED
package/fetch/src/lib/fetch.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export type FetchServiceConfig = Required<Pick<ConfigureFetchInput, 'makeFetch'
|
|
|
20
20
|
*/
|
|
21
21
|
export declare function fetchService(config: FetchServiceConfig): FetchService;
|
|
22
22
|
export type MapFetchResponseFunction = MapFunction<Promise<Response>, Promise<Response>>;
|
|
23
|
+
/**
|
|
24
|
+
* Custom fetch handler that takes in a Request and fetch function and returns a Response.
|
|
25
|
+
*/
|
|
26
|
+
export type FetchHandler = (request: Request, makeFetch: typeof fetch) => Promise<Response>;
|
|
23
27
|
export interface ConfigureFetchInput extends FetchRequestFactoryInput {
|
|
24
28
|
makeFetch?: typeof fetch;
|
|
25
29
|
/**
|
|
@@ -34,6 +38,10 @@ export interface ConfigureFetchInput extends FetchRequestFactoryInput {
|
|
|
34
38
|
* Default: false
|
|
35
39
|
*/
|
|
36
40
|
requireOkResponse?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* (Optional) Custom fetch handler.
|
|
43
|
+
*/
|
|
44
|
+
fetchHandler?: FetchHandler;
|
|
37
45
|
/**
|
|
38
46
|
* (Optional) MapFetchResponseFunction
|
|
39
47
|
*
|
|
@@ -41,6 +49,13 @@ export interface ConfigureFetchInput extends FetchRequestFactoryInput {
|
|
|
41
49
|
*/
|
|
42
50
|
mapResponse?: MapFetchResponseFunction;
|
|
43
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Default FetchHabdler
|
|
54
|
+
* @param request
|
|
55
|
+
* @param makeFetch
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
export declare const DEFAULT_FETCH_HANDLER: FetchHandler;
|
|
44
59
|
/**
|
|
45
60
|
* Creates a function that wraps fetch and uses a FetchRequestFactory to generate a Request before invoking Fetch.
|
|
46
61
|
*
|
|
@@ -81,6 +96,14 @@ export interface FetchRequestFactoryInput {
|
|
|
81
96
|
export type FetchRequestInitFactory = (currRequest: PromiseOrValue<Request>, init?: PromiseOrValue<RequestInit>) => PromiseOrValue<RequestInitWithTimeout | undefined>;
|
|
82
97
|
export type FetchRequestFactory = (input: RequestInfo | URL, init?: RequestInit | undefined) => PromiseOrValue<Request>;
|
|
83
98
|
export type AbortControllerFactory = Factory<AbortController>;
|
|
99
|
+
/**
|
|
100
|
+
* The deafult FetchRequestFactory implementation that uses window/global Request.
|
|
101
|
+
*
|
|
102
|
+
* @param input
|
|
103
|
+
* @param init
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
export declare const DEFAULT_FETCH_REQUEST_FACTORY: FetchRequestFactory;
|
|
84
107
|
export declare function fetchRequestFactory(config: FetchRequestFactoryInput): FetchRequestFactory;
|
|
85
108
|
export declare function mergeRequestInits<T extends RequestInit>(base: T, requestInit?: T | undefined): T;
|
|
86
109
|
export declare function mergeRequestHeaders(inputHeadersArray: Maybe<HeadersInit>[]): [string, string][];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Maybe, type PromiseOrValue, type PromiseRateLimiter } from '@dereekb/util';
|
|
2
|
+
import { type FetchHandler } from './fetch';
|
|
3
|
+
import { type FetchResponseError } from './error';
|
|
4
|
+
/**
|
|
5
|
+
* A FetchRequestFactory with PromiseRateLimiter
|
|
6
|
+
*/
|
|
7
|
+
export type RateLimitedFetchHandler<T extends PromiseRateLimiter = PromiseRateLimiter> = FetchHandler & {
|
|
8
|
+
/**
|
|
9
|
+
* Internal limiter used by the RateLimitedFetchRequestFactory.
|
|
10
|
+
*/
|
|
11
|
+
readonly _rateLimiter: T;
|
|
12
|
+
};
|
|
13
|
+
export interface RateLimitedFetchHandlerConfig<T extends PromiseRateLimiter> {
|
|
14
|
+
/**
|
|
15
|
+
* Rate limiter configuration. Should be based on the target API.
|
|
16
|
+
*/
|
|
17
|
+
readonly rateLimiter: T;
|
|
18
|
+
/**
|
|
19
|
+
* The maximum number of retries to try.
|
|
20
|
+
*
|
|
21
|
+
* Defaults to 1.
|
|
22
|
+
*/
|
|
23
|
+
readonly maxRetries?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Update the fetch handler with the response, ideally setting/updating the time at which the rate limiter can be reset.
|
|
26
|
+
*
|
|
27
|
+
* Return true if the response should be retried. Should typically also only return true if the response is a throttle error by the remote server.
|
|
28
|
+
*
|
|
29
|
+
* The response is only allowed to be retried once not guranteed to be retried if it returns true on a second retry.
|
|
30
|
+
*/
|
|
31
|
+
updateWithResponse(response: Response, fetchResponseError?: Maybe<FetchResponseError>): PromiseOrValue<boolean>;
|
|
32
|
+
}
|
|
33
|
+
export declare function rateLimitedFetchHandler<T extends PromiseRateLimiter>(config: RateLimitedFetchHandlerConfig<T>): RateLimitedFetchHandler<T>;
|
package/fetch/src/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { type FetchService } from './fetch';
|
|
2
|
+
/**
|
|
3
|
+
* Default FetchService implementation that uses the native Fetch api.
|
|
4
|
+
*/
|
|
5
|
+
export declare const fetchApiFetchService: FetchService;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use fetchApiFetchService instead. This is an alias.
|
|
8
|
+
*/
|
|
2
9
|
export declare const nodeFetchService: FetchService;
|
package/index.cjs.js
CHANGED
|
@@ -4795,6 +4795,20 @@ const sortCompareNumberFunction = (a, b) => a - b;
|
|
|
4795
4795
|
function minAndMaxNumber(values) {
|
|
4796
4796
|
return minAndMaxFunction(sortCompareNumberFunction)(values);
|
|
4797
4797
|
}
|
|
4798
|
+
/**
|
|
4799
|
+
* Returns the lorgathirm of y with base x.
|
|
4800
|
+
*
|
|
4801
|
+
* Example:
|
|
4802
|
+
* - (log2(16)): x = 2, y = 16 -> 4 (2^4 = 16)
|
|
4803
|
+
* - (log10(100)): x = 10, y = 100 -> 2 (10^2 = 100)
|
|
4804
|
+
*
|
|
4805
|
+
* @param x
|
|
4806
|
+
* @param y
|
|
4807
|
+
* @returns
|
|
4808
|
+
*/
|
|
4809
|
+
function getBaseLog(x, y) {
|
|
4810
|
+
return Math.log(y) / Math.log(x);
|
|
4811
|
+
}
|
|
4798
4812
|
|
|
4799
4813
|
function roundingFunction(type) {
|
|
4800
4814
|
let fn;
|
|
@@ -13747,6 +13761,200 @@ function performTasksFromFactoryInParallelFunction(config) {
|
|
|
13747
13761
|
};
|
|
13748
13762
|
}
|
|
13749
13763
|
|
|
13764
|
+
function exponentialPromiseRateLimiter(initialConfig) {
|
|
13765
|
+
const DEFAULT_START_LIMIT_AT = 1;
|
|
13766
|
+
const DEFAULT_COOLDOWN_RATE = 1;
|
|
13767
|
+
const DEFAULT_EXPONENT_RATE = 2;
|
|
13768
|
+
const DEFAULT_MAX_WAIT_TIME = MS_IN_HOUR;
|
|
13769
|
+
let config = {
|
|
13770
|
+
startLimitAt: DEFAULT_START_LIMIT_AT,
|
|
13771
|
+
cooldownRate: DEFAULT_COOLDOWN_RATE,
|
|
13772
|
+
exponentRate: DEFAULT_EXPONENT_RATE,
|
|
13773
|
+
maxWaitTime: DEFAULT_MAX_WAIT_TIME
|
|
13774
|
+
};
|
|
13775
|
+
let currentCount = 0;
|
|
13776
|
+
let countForMaxWaitTime = Number.MAX_SAFE_INTEGER;
|
|
13777
|
+
let timeOfLastExecution = new Date();
|
|
13778
|
+
let enabled = true;
|
|
13779
|
+
setConfig(initialConfig != null ? initialConfig : config);
|
|
13780
|
+
function getConfig() {
|
|
13781
|
+
return Object.assign({}, config);
|
|
13782
|
+
}
|
|
13783
|
+
function getEnabled() {
|
|
13784
|
+
return enabled;
|
|
13785
|
+
}
|
|
13786
|
+
function setEnabled(nextEnabled) {
|
|
13787
|
+
enabled = nextEnabled;
|
|
13788
|
+
}
|
|
13789
|
+
function setConfig(newConfig, andReset = false) {
|
|
13790
|
+
var _newConfig$startLimit, _newConfig$cooldownRa, _newConfig$maxWaitTim, _newConfig$exponentRa;
|
|
13791
|
+
const startLimitAt = Math.max(0, (_newConfig$startLimit = newConfig.startLimitAt) != null ? _newConfig$startLimit : DEFAULT_START_LIMIT_AT);
|
|
13792
|
+
const cooldownRate = (_newConfig$cooldownRa = newConfig.cooldownRate) != null ? _newConfig$cooldownRa : DEFAULT_COOLDOWN_RATE;
|
|
13793
|
+
const maxWaitTime = (_newConfig$maxWaitTim = newConfig.maxWaitTime) != null ? _newConfig$maxWaitTim : DEFAULT_MAX_WAIT_TIME;
|
|
13794
|
+
const exponentRate = (_newConfig$exponentRa = newConfig.exponentRate) != null ? _newConfig$exponentRa : DEFAULT_EXPONENT_RATE;
|
|
13795
|
+
config = {
|
|
13796
|
+
startLimitAt,
|
|
13797
|
+
cooldownRate,
|
|
13798
|
+
maxWaitTime,
|
|
13799
|
+
exponentRate
|
|
13800
|
+
};
|
|
13801
|
+
// calculate max count for max wait time to use for determining rounding of nextWaitTime
|
|
13802
|
+
countForMaxWaitTime = getBaseLog(exponentRate, maxWaitTime / MS_IN_SECOND + 1);
|
|
13803
|
+
if (andReset) {
|
|
13804
|
+
reset();
|
|
13805
|
+
}
|
|
13806
|
+
}
|
|
13807
|
+
function reset() {
|
|
13808
|
+
currentCount = 0;
|
|
13809
|
+
timeOfLastExecution = new Date();
|
|
13810
|
+
}
|
|
13811
|
+
function _nextWaitTime(increasedExecutions) {
|
|
13812
|
+
if (!enabled) {
|
|
13813
|
+
return 0;
|
|
13814
|
+
}
|
|
13815
|
+
const {
|
|
13816
|
+
cooldownRate
|
|
13817
|
+
} = config;
|
|
13818
|
+
const msSinceLastExecution = Date.now() - timeOfLastExecution.getTime();
|
|
13819
|
+
const cooldown = msSinceLastExecution * cooldownRate / MS_IN_SECOND; // the cooldown amount
|
|
13820
|
+
const count = Math.max(currentCount - cooldown, 0);
|
|
13821
|
+
const effectiveCount = Math.max(0, count - config.startLimitAt);
|
|
13822
|
+
if (increasedExecutions) {
|
|
13823
|
+
currentCount = count + increasedExecutions;
|
|
13824
|
+
timeOfLastExecution = new Date();
|
|
13825
|
+
}
|
|
13826
|
+
if (effectiveCount >= countForMaxWaitTime) {
|
|
13827
|
+
return config.maxWaitTime;
|
|
13828
|
+
} else {
|
|
13829
|
+
return (Math.pow(config.exponentRate, Math.max(effectiveCount, 0)) - 1) * MS_IN_SECOND;
|
|
13830
|
+
}
|
|
13831
|
+
}
|
|
13832
|
+
function getNextWaitTime(increase) {
|
|
13833
|
+
return _nextWaitTime(increase != null ? increase : 0);
|
|
13834
|
+
}
|
|
13835
|
+
function waitForRateLimit() {
|
|
13836
|
+
const waitTime = _nextWaitTime(1);
|
|
13837
|
+
return waitForMs(waitTime);
|
|
13838
|
+
}
|
|
13839
|
+
return {
|
|
13840
|
+
waitForRateLimit,
|
|
13841
|
+
getNextWaitTime,
|
|
13842
|
+
getConfig,
|
|
13843
|
+
setConfig,
|
|
13844
|
+
getEnabled,
|
|
13845
|
+
setEnabled,
|
|
13846
|
+
reset
|
|
13847
|
+
};
|
|
13848
|
+
}
|
|
13849
|
+
/**
|
|
13850
|
+
* Creates a ResetPeriodPromiseRateLimiter.
|
|
13851
|
+
*
|
|
13852
|
+
* @param limit
|
|
13853
|
+
*/
|
|
13854
|
+
function resetPeriodPromiseRateLimiter(initialConfig) {
|
|
13855
|
+
const DEFAULT_EXPONENT_RATE = 1.5;
|
|
13856
|
+
const exponentialLimiter = exponentialPromiseRateLimiter(Object.assign({
|
|
13857
|
+
exponentRate: DEFAULT_EXPONENT_RATE,
|
|
13858
|
+
maxWaitTime: MS_IN_SECOND * 8
|
|
13859
|
+
}, initialConfig));
|
|
13860
|
+
let resetPeriod = MS_IN_MINUTE;
|
|
13861
|
+
let nextResetAt = new Date();
|
|
13862
|
+
let limit = 0;
|
|
13863
|
+
let remaining = 0;
|
|
13864
|
+
let enabled = true;
|
|
13865
|
+
setConfig(initialConfig, true);
|
|
13866
|
+
function _checkRemainingReset() {
|
|
13867
|
+
if (nextResetAt && isPast(nextResetAt)) {
|
|
13868
|
+
reset();
|
|
13869
|
+
}
|
|
13870
|
+
}
|
|
13871
|
+
function getEnabled() {
|
|
13872
|
+
return enabled;
|
|
13873
|
+
}
|
|
13874
|
+
function setEnabled(nextEnabled) {
|
|
13875
|
+
enabled = nextEnabled;
|
|
13876
|
+
}
|
|
13877
|
+
function reset() {
|
|
13878
|
+
remaining = limit;
|
|
13879
|
+
nextResetAt = new Date(Date.now() + resetPeriod);
|
|
13880
|
+
// do not reset the exponential limiter
|
|
13881
|
+
}
|
|
13882
|
+
|
|
13883
|
+
function getResetAt() {
|
|
13884
|
+
return nextResetAt;
|
|
13885
|
+
}
|
|
13886
|
+
function getTimeUntilNextReset() {
|
|
13887
|
+
return Math.max(0, nextResetAt.getTime() - Date.now());
|
|
13888
|
+
}
|
|
13889
|
+
function setNextResetAt(date) {
|
|
13890
|
+
nextResetAt = date;
|
|
13891
|
+
}
|
|
13892
|
+
function getRemainingLimit() {
|
|
13893
|
+
_checkRemainingReset();
|
|
13894
|
+
return remaining;
|
|
13895
|
+
}
|
|
13896
|
+
function setRemainingLimit(nextRemaining) {
|
|
13897
|
+
remaining = nextRemaining;
|
|
13898
|
+
}
|
|
13899
|
+
function setConfig(config, andReset = false) {
|
|
13900
|
+
var _config$limit, _config$resetPeriod, _config$cooldownRate, _config$exponentRate, _config$maxWaitTime, _config$resetAt;
|
|
13901
|
+
limit = (_config$limit = config.limit) != null ? _config$limit : limit;
|
|
13902
|
+
resetPeriod = (_config$resetPeriod = config.resetPeriod) != null ? _config$resetPeriod : resetPeriod;
|
|
13903
|
+
const exponentialLimiterConfig = {
|
|
13904
|
+
cooldownRate: (_config$cooldownRate = config.cooldownRate) != null ? _config$cooldownRate : Math.max(0.1, resetPeriod / MS_IN_SECOND),
|
|
13905
|
+
exponentRate: (_config$exponentRate = config.exponentRate) != null ? _config$exponentRate : DEFAULT_EXPONENT_RATE,
|
|
13906
|
+
maxWaitTime: (_config$maxWaitTime = config.maxWaitTime) != null ? _config$maxWaitTime : MS_IN_SECOND * 8
|
|
13907
|
+
};
|
|
13908
|
+
exponentialLimiter.setConfig(exponentialLimiterConfig, andReset);
|
|
13909
|
+
if (andReset) {
|
|
13910
|
+
reset();
|
|
13911
|
+
}
|
|
13912
|
+
nextResetAt = (_config$resetAt = config.resetAt) != null ? _config$resetAt : nextResetAt;
|
|
13913
|
+
}
|
|
13914
|
+
function _nextWaitTime(increasedExecutions) {
|
|
13915
|
+
if (!enabled) {
|
|
13916
|
+
return 0;
|
|
13917
|
+
}
|
|
13918
|
+
function computeNextWaitTime() {
|
|
13919
|
+
remaining -= increasedExecutions;
|
|
13920
|
+
return exponentialLimiter.getNextWaitTime(increasedExecutions);
|
|
13921
|
+
}
|
|
13922
|
+
let waitTime = 0;
|
|
13923
|
+
if (remaining > 0) {
|
|
13924
|
+
waitTime = computeNextWaitTime();
|
|
13925
|
+
} else {
|
|
13926
|
+
// if none remaining, try and reset
|
|
13927
|
+
_checkRemainingReset();
|
|
13928
|
+
if (remaining > 0) {
|
|
13929
|
+
waitTime = computeNextWaitTime();
|
|
13930
|
+
} else {
|
|
13931
|
+
waitTime = getTimeUntilNextReset();
|
|
13932
|
+
}
|
|
13933
|
+
}
|
|
13934
|
+
return waitTime;
|
|
13935
|
+
}
|
|
13936
|
+
function getNextWaitTime(increase) {
|
|
13937
|
+
return _nextWaitTime(increase != null ? increase : 0);
|
|
13938
|
+
}
|
|
13939
|
+
function waitForRateLimit() {
|
|
13940
|
+
const waitTime = _nextWaitTime(1);
|
|
13941
|
+
return waitForMs(waitTime);
|
|
13942
|
+
}
|
|
13943
|
+
return {
|
|
13944
|
+
getRemainingLimit,
|
|
13945
|
+
setRemainingLimit,
|
|
13946
|
+
getTimeUntilNextReset,
|
|
13947
|
+
getResetAt,
|
|
13948
|
+
setNextResetAt,
|
|
13949
|
+
setConfig,
|
|
13950
|
+
reset,
|
|
13951
|
+
getNextWaitTime,
|
|
13952
|
+
waitForRateLimit,
|
|
13953
|
+
getEnabled,
|
|
13954
|
+
setEnabled
|
|
13955
|
+
};
|
|
13956
|
+
}
|
|
13957
|
+
|
|
13750
13958
|
function _await$1(value, then, direct) {
|
|
13751
13959
|
if (direct) {
|
|
13752
13960
|
return then ? then(value) : value;
|
|
@@ -16168,6 +16376,7 @@ exports.expandFlattenTreeFunction = expandFlattenTreeFunction;
|
|
|
16168
16376
|
exports.expandIndexSet = expandIndexSet;
|
|
16169
16377
|
exports.expandTreeFunction = expandTreeFunction;
|
|
16170
16378
|
exports.expandTrees = expandTrees;
|
|
16379
|
+
exports.exponentialPromiseRateLimiter = exponentialPromiseRateLimiter;
|
|
16171
16380
|
exports.extendLatLngBound = extendLatLngBound;
|
|
16172
16381
|
exports.filterAndMapFunction = filterAndMapFunction;
|
|
16173
16382
|
exports.filterEmptyValues = filterEmptyValues;
|
|
@@ -16237,6 +16446,7 @@ exports.forwardFunction = forwardFunction;
|
|
|
16237
16446
|
exports.fractionalHoursToMinutes = fractionalHoursToMinutes;
|
|
16238
16447
|
exports.generateIfDoesNotExist = generateIfDoesNotExist;
|
|
16239
16448
|
exports.getArrayNextIndex = getArrayNextIndex;
|
|
16449
|
+
exports.getBaseLog = getBaseLog;
|
|
16240
16450
|
exports.getDayOffset = getDayOffset;
|
|
16241
16451
|
exports.getDayTomorrow = getDayTomorrow;
|
|
16242
16452
|
exports.getDayYesterday = getDayYesterday;
|
|
@@ -16605,6 +16815,7 @@ exports.replaceLastCharacterIfIsFunction = replaceLastCharacterIfIsFunction;
|
|
|
16605
16815
|
exports.replaceMultipleFilePathsInSlashPath = replaceMultipleFilePathsInSlashPath;
|
|
16606
16816
|
exports.replaceStringsFunction = replaceStringsFunction;
|
|
16607
16817
|
exports.requireModelKey = requireModelKey;
|
|
16818
|
+
exports.resetPeriodPromiseRateLimiter = resetPeriodPromiseRateLimiter;
|
|
16608
16819
|
exports.restoreOrder = restoreOrder;
|
|
16609
16820
|
exports.restoreOrderWithValues = restoreOrderWithValues;
|
|
16610
16821
|
exports.reverseCompareFn = reverseCompareFn;
|
package/index.esm.js
CHANGED
|
@@ -5457,6 +5457,21 @@ function minAndMaxNumber(values) {
|
|
|
5457
5457
|
return minAndMaxFunction(sortCompareNumberFunction)(values);
|
|
5458
5458
|
}
|
|
5459
5459
|
|
|
5460
|
+
/**
|
|
5461
|
+
* Returns the lorgathirm of y with base x.
|
|
5462
|
+
*
|
|
5463
|
+
* Example:
|
|
5464
|
+
* - (log2(16)): x = 2, y = 16 -> 4 (2^4 = 16)
|
|
5465
|
+
* - (log10(100)): x = 10, y = 100 -> 2 (10^2 = 100)
|
|
5466
|
+
*
|
|
5467
|
+
* @param x
|
|
5468
|
+
* @param y
|
|
5469
|
+
* @returns
|
|
5470
|
+
*/
|
|
5471
|
+
function getBaseLog(x, y) {
|
|
5472
|
+
return Math.log(y) / Math.log(x);
|
|
5473
|
+
}
|
|
5474
|
+
|
|
5460
5475
|
// MARK: Rounding
|
|
5461
5476
|
|
|
5462
5477
|
function roundingFunction(type) {
|
|
@@ -15272,6 +15287,218 @@ function performTasksFromFactoryInParallelFunction(config) {
|
|
|
15272
15287
|
};
|
|
15273
15288
|
}
|
|
15274
15289
|
|
|
15290
|
+
/**
|
|
15291
|
+
* Interface for a rate limiter.
|
|
15292
|
+
*/
|
|
15293
|
+
|
|
15294
|
+
/**
|
|
15295
|
+
* Interface for a PromiseRateLimiter that can be enabled or disabled.
|
|
15296
|
+
*/
|
|
15297
|
+
|
|
15298
|
+
// MARK: Exponential Limiter
|
|
15299
|
+
|
|
15300
|
+
function exponentialPromiseRateLimiter(initialConfig) {
|
|
15301
|
+
const DEFAULT_START_LIMIT_AT = 1;
|
|
15302
|
+
const DEFAULT_COOLDOWN_RATE = 1;
|
|
15303
|
+
const DEFAULT_EXPONENT_RATE = 2;
|
|
15304
|
+
const DEFAULT_MAX_WAIT_TIME = MS_IN_HOUR;
|
|
15305
|
+
let config = {
|
|
15306
|
+
startLimitAt: DEFAULT_START_LIMIT_AT,
|
|
15307
|
+
cooldownRate: DEFAULT_COOLDOWN_RATE,
|
|
15308
|
+
exponentRate: DEFAULT_EXPONENT_RATE,
|
|
15309
|
+
maxWaitTime: DEFAULT_MAX_WAIT_TIME
|
|
15310
|
+
};
|
|
15311
|
+
let currentCount = 0;
|
|
15312
|
+
let countForMaxWaitTime = Number.MAX_SAFE_INTEGER;
|
|
15313
|
+
let timeOfLastExecution = new Date();
|
|
15314
|
+
let enabled = true;
|
|
15315
|
+
setConfig(initialConfig != null ? initialConfig : config);
|
|
15316
|
+
function getConfig() {
|
|
15317
|
+
return Object.assign({}, config);
|
|
15318
|
+
}
|
|
15319
|
+
function getEnabled() {
|
|
15320
|
+
return enabled;
|
|
15321
|
+
}
|
|
15322
|
+
function setEnabled(nextEnabled) {
|
|
15323
|
+
enabled = nextEnabled;
|
|
15324
|
+
}
|
|
15325
|
+
function setConfig(newConfig, andReset = false) {
|
|
15326
|
+
var _newConfig$startLimit, _newConfig$cooldownRa, _newConfig$maxWaitTim, _newConfig$exponentRa;
|
|
15327
|
+
const startLimitAt = Math.max(0, (_newConfig$startLimit = newConfig.startLimitAt) != null ? _newConfig$startLimit : DEFAULT_START_LIMIT_AT);
|
|
15328
|
+
const cooldownRate = (_newConfig$cooldownRa = newConfig.cooldownRate) != null ? _newConfig$cooldownRa : DEFAULT_COOLDOWN_RATE;
|
|
15329
|
+
const maxWaitTime = (_newConfig$maxWaitTim = newConfig.maxWaitTime) != null ? _newConfig$maxWaitTim : DEFAULT_MAX_WAIT_TIME;
|
|
15330
|
+
const exponentRate = (_newConfig$exponentRa = newConfig.exponentRate) != null ? _newConfig$exponentRa : DEFAULT_EXPONENT_RATE;
|
|
15331
|
+
config = {
|
|
15332
|
+
startLimitAt,
|
|
15333
|
+
cooldownRate,
|
|
15334
|
+
maxWaitTime,
|
|
15335
|
+
exponentRate
|
|
15336
|
+
};
|
|
15337
|
+
|
|
15338
|
+
// calculate max count for max wait time to use for determining rounding of nextWaitTime
|
|
15339
|
+
countForMaxWaitTime = getBaseLog(exponentRate, maxWaitTime / MS_IN_SECOND + 1);
|
|
15340
|
+
if (andReset) {
|
|
15341
|
+
reset();
|
|
15342
|
+
}
|
|
15343
|
+
}
|
|
15344
|
+
function reset() {
|
|
15345
|
+
currentCount = 0;
|
|
15346
|
+
timeOfLastExecution = new Date();
|
|
15347
|
+
}
|
|
15348
|
+
function _nextWaitTime(increasedExecutions) {
|
|
15349
|
+
if (!enabled) {
|
|
15350
|
+
return 0;
|
|
15351
|
+
}
|
|
15352
|
+
const {
|
|
15353
|
+
cooldownRate
|
|
15354
|
+
} = config;
|
|
15355
|
+
const msSinceLastExecution = Date.now() - timeOfLastExecution.getTime();
|
|
15356
|
+
const cooldown = msSinceLastExecution * cooldownRate / MS_IN_SECOND; // the cooldown amount
|
|
15357
|
+
const count = Math.max(currentCount - cooldown, 0);
|
|
15358
|
+
const effectiveCount = Math.max(0, count - config.startLimitAt);
|
|
15359
|
+
if (increasedExecutions) {
|
|
15360
|
+
currentCount = count + increasedExecutions;
|
|
15361
|
+
timeOfLastExecution = new Date();
|
|
15362
|
+
}
|
|
15363
|
+
if (effectiveCount >= countForMaxWaitTime) {
|
|
15364
|
+
return config.maxWaitTime;
|
|
15365
|
+
} else {
|
|
15366
|
+
return (Math.pow(config.exponentRate, Math.max(effectiveCount, 0)) - 1) * MS_IN_SECOND;
|
|
15367
|
+
}
|
|
15368
|
+
}
|
|
15369
|
+
function getNextWaitTime(increase) {
|
|
15370
|
+
return _nextWaitTime(increase != null ? increase : 0);
|
|
15371
|
+
}
|
|
15372
|
+
function waitForRateLimit() {
|
|
15373
|
+
const waitTime = _nextWaitTime(1);
|
|
15374
|
+
return waitForMs(waitTime);
|
|
15375
|
+
}
|
|
15376
|
+
return {
|
|
15377
|
+
waitForRateLimit,
|
|
15378
|
+
getNextWaitTime,
|
|
15379
|
+
getConfig,
|
|
15380
|
+
setConfig,
|
|
15381
|
+
getEnabled,
|
|
15382
|
+
setEnabled,
|
|
15383
|
+
reset
|
|
15384
|
+
};
|
|
15385
|
+
}
|
|
15386
|
+
|
|
15387
|
+
// MARK: Count Down limiter
|
|
15388
|
+
|
|
15389
|
+
/**
|
|
15390
|
+
* A rate limiter that resets every specific period of time and has a limited amount of items that can go out.
|
|
15391
|
+
*/
|
|
15392
|
+
|
|
15393
|
+
/**
|
|
15394
|
+
* Creates a ResetPeriodPromiseRateLimiter.
|
|
15395
|
+
*
|
|
15396
|
+
* @param limit
|
|
15397
|
+
*/
|
|
15398
|
+
function resetPeriodPromiseRateLimiter(initialConfig) {
|
|
15399
|
+
const DEFAULT_EXPONENT_RATE = 1.5;
|
|
15400
|
+
const exponentialLimiter = exponentialPromiseRateLimiter(Object.assign({
|
|
15401
|
+
exponentRate: DEFAULT_EXPONENT_RATE,
|
|
15402
|
+
maxWaitTime: MS_IN_SECOND * 8
|
|
15403
|
+
}, initialConfig));
|
|
15404
|
+
let resetPeriod = MS_IN_MINUTE;
|
|
15405
|
+
let nextResetAt = new Date();
|
|
15406
|
+
let limit = 0;
|
|
15407
|
+
let remaining = 0;
|
|
15408
|
+
let enabled = true;
|
|
15409
|
+
setConfig(initialConfig, true);
|
|
15410
|
+
function _checkRemainingReset() {
|
|
15411
|
+
if (nextResetAt && isPast(nextResetAt)) {
|
|
15412
|
+
reset();
|
|
15413
|
+
}
|
|
15414
|
+
}
|
|
15415
|
+
function getEnabled() {
|
|
15416
|
+
return enabled;
|
|
15417
|
+
}
|
|
15418
|
+
function setEnabled(nextEnabled) {
|
|
15419
|
+
enabled = nextEnabled;
|
|
15420
|
+
}
|
|
15421
|
+
function reset() {
|
|
15422
|
+
remaining = limit;
|
|
15423
|
+
nextResetAt = new Date(Date.now() + resetPeriod);
|
|
15424
|
+
// do not reset the exponential limiter
|
|
15425
|
+
}
|
|
15426
|
+
|
|
15427
|
+
function getResetAt() {
|
|
15428
|
+
return nextResetAt;
|
|
15429
|
+
}
|
|
15430
|
+
function getTimeUntilNextReset() {
|
|
15431
|
+
return Math.max(0, nextResetAt.getTime() - Date.now());
|
|
15432
|
+
}
|
|
15433
|
+
function setNextResetAt(date) {
|
|
15434
|
+
nextResetAt = date;
|
|
15435
|
+
}
|
|
15436
|
+
function getRemainingLimit() {
|
|
15437
|
+
_checkRemainingReset();
|
|
15438
|
+
return remaining;
|
|
15439
|
+
}
|
|
15440
|
+
function setRemainingLimit(nextRemaining) {
|
|
15441
|
+
remaining = nextRemaining;
|
|
15442
|
+
}
|
|
15443
|
+
function setConfig(config, andReset = false) {
|
|
15444
|
+
var _config$limit, _config$resetPeriod, _config$cooldownRate, _config$exponentRate, _config$maxWaitTime, _config$resetAt;
|
|
15445
|
+
limit = (_config$limit = config.limit) != null ? _config$limit : limit;
|
|
15446
|
+
resetPeriod = (_config$resetPeriod = config.resetPeriod) != null ? _config$resetPeriod : resetPeriod;
|
|
15447
|
+
const exponentialLimiterConfig = {
|
|
15448
|
+
cooldownRate: (_config$cooldownRate = config.cooldownRate) != null ? _config$cooldownRate : Math.max(0.1, resetPeriod / MS_IN_SECOND),
|
|
15449
|
+
exponentRate: (_config$exponentRate = config.exponentRate) != null ? _config$exponentRate : DEFAULT_EXPONENT_RATE,
|
|
15450
|
+
maxWaitTime: (_config$maxWaitTime = config.maxWaitTime) != null ? _config$maxWaitTime : MS_IN_SECOND * 8
|
|
15451
|
+
};
|
|
15452
|
+
exponentialLimiter.setConfig(exponentialLimiterConfig, andReset);
|
|
15453
|
+
if (andReset) {
|
|
15454
|
+
reset();
|
|
15455
|
+
}
|
|
15456
|
+
nextResetAt = (_config$resetAt = config.resetAt) != null ? _config$resetAt : nextResetAt;
|
|
15457
|
+
}
|
|
15458
|
+
function _nextWaitTime(increasedExecutions) {
|
|
15459
|
+
if (!enabled) {
|
|
15460
|
+
return 0;
|
|
15461
|
+
}
|
|
15462
|
+
function computeNextWaitTime() {
|
|
15463
|
+
remaining -= increasedExecutions;
|
|
15464
|
+
return exponentialLimiter.getNextWaitTime(increasedExecutions);
|
|
15465
|
+
}
|
|
15466
|
+
let waitTime = 0;
|
|
15467
|
+
if (remaining > 0) {
|
|
15468
|
+
waitTime = computeNextWaitTime();
|
|
15469
|
+
} else {
|
|
15470
|
+
// if none remaining, try and reset
|
|
15471
|
+
_checkRemainingReset();
|
|
15472
|
+
if (remaining > 0) {
|
|
15473
|
+
waitTime = computeNextWaitTime();
|
|
15474
|
+
} else {
|
|
15475
|
+
waitTime = getTimeUntilNextReset();
|
|
15476
|
+
}
|
|
15477
|
+
}
|
|
15478
|
+
return waitTime;
|
|
15479
|
+
}
|
|
15480
|
+
function getNextWaitTime(increase) {
|
|
15481
|
+
return _nextWaitTime(increase != null ? increase : 0);
|
|
15482
|
+
}
|
|
15483
|
+
function waitForRateLimit() {
|
|
15484
|
+
const waitTime = _nextWaitTime(1);
|
|
15485
|
+
return waitForMs(waitTime);
|
|
15486
|
+
}
|
|
15487
|
+
return {
|
|
15488
|
+
getRemainingLimit,
|
|
15489
|
+
setRemainingLimit,
|
|
15490
|
+
getTimeUntilNextReset,
|
|
15491
|
+
getResetAt,
|
|
15492
|
+
setNextResetAt,
|
|
15493
|
+
setConfig,
|
|
15494
|
+
reset,
|
|
15495
|
+
getNextWaitTime,
|
|
15496
|
+
waitForRateLimit,
|
|
15497
|
+
getEnabled,
|
|
15498
|
+
setEnabled
|
|
15499
|
+
};
|
|
15500
|
+
}
|
|
15501
|
+
|
|
15275
15502
|
/**
|
|
15276
15503
|
* Function that uses an array of Factories to produce Promises, one after the other, to attempt to return the value.
|
|
15277
15504
|
*
|
|
@@ -17157,4 +17384,4 @@ async function iterateFilteredPages(inputPage, loadFn, iterFn) {
|
|
|
17157
17384
|
return count;
|
|
17158
17385
|
}
|
|
17159
17386
|
|
|
17160
|
-
export { ALL_DOUBLE_SLASHES_REGEX, ALL_SLASHES_REGEX, ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX, ASSERTION_ERROR_CODE, ASSERTION_HANDLER, AUTH_ADMIN_ROLE, AUTH_ONBOARDED_ROLE, AUTH_ROLE_CLAIMS_DEFAULT_CLAIM_VALUE, AUTH_ROLE_CLAIMS_DEFAULT_EMPTY_VALUE, AUTH_TOS_SIGNED_ROLE, AUTH_USER_ROLE, AbstractUniqueModel, Assert, AssertMax, AssertMin, AssertionError, AssertionIssueHandler, BooleanStringKeyArrayUtility, BooleanStringKeyArrayUtilityInstance, CATCH_ALL_HANDLE_RESULT_KEY, CUT_VALUE_TO_ZERO_PRECISION, DATE_NOW_VALUE, DEFAULT_LAT_LNG_STRING_VALUE, DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG, DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG, DEFAULT_READABLE_ERROR_CODE, DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS, DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT, DEFAULT_UNKNOWN_MODEL_TYPE_STRING, DOLLAR_AMOUNT_PRECISION, DOLLAR_AMOUNT_STRING_REGEX, DataDoesNotExistError, DataIsExpiredError, Day, DestroyFunctionObject, E164PHONE_NUMBER_REGEX, E164PHONE_NUMBER_WITH_EXTENSION_REGEX, E164PHONE_NUMBER_WITH_OPTIONAL_EXTENSION_REGEX, FINAL_PAGE, FIRST_PAGE, FRACTIONAL_HOURS_PRECISION_FUNCTION, FullStorageObject, HAS_PORT_NUMBER_REGEX, HAS_WEBSITE_DOMAIN_NAME_REGEX, HOURS_IN_DAY, HTTP_OR_HTTPS_REGEX, HashSet, ISO8601_DAY_STRING_REGEX, ISO8601_DAY_STRING_START_REGEX, ISO_8601_DATE_STRING_REGEX, KeyValueTypleValueFilter, LAT_LNG_PATTERN, LAT_LNG_PATTERN_MAX_PRECISION, LAT_LONG_100KM_PRECISION, LAT_LONG_100M_PRECISION, LAT_LONG_10CM_PRECISION, LAT_LONG_10KM_PRECISION, LAT_LONG_10M_PRECISION, LAT_LONG_1CM_PRECISION, LAT_LONG_1KM_PRECISION, LAT_LONG_1MM_PRECISION, LAT_LONG_1M_PRECISION, LAT_LONG_GRAINS_OF_SAND_PRECISION, LEADING_SLASHES_REGEX, MAP_IDENTITY, MAX_BITWISE_SET_SIZE, MAX_LATITUDE_VALUE, MAX_LONGITUDE_VALUE, MINUTES_IN_DAY, MINUTES_IN_HOUR, MINUTE_OF_DAY_MAXMIMUM, MINUTE_OF_DAY_MINIUMUM, MIN_LATITUDE_VALUE, MIN_LONGITUDE_VALUE, MONTH_DAY_SLASH_DATE_STRING_REGEX, MS_IN_DAY, MS_IN_HOUR, MS_IN_MINUTE, MS_IN_SECOND, MemoryStorageInstance, ModelRelationUtility, NOOP_MODIFIER, NUMBER_STRING_DENCODER_64, NUMBER_STRING_DENCODER_64_DEFAULT_NEGATIVE_PREFIX, NUMBER_STRING_DENCODER_64_DIGITS, PHONE_EXTENSION_NUMBER_REGEX, PRIMATIVE_KEY_DENCODER_VALUE, PageCalculator, PropertyDescriptorUtility, REGEX_SPECIAL_CHARACTERS, REGEX_SPECIAL_CHARACTERS_SET, RelationChange, SECONDS_IN_MINUTE, SHARED_MEMORY_STORAGE, SLASH_PATH_FILE_TYPE_SEPARATOR, SLASH_PATH_SEPARATOR, SORT_VALUE_EQUAL, SORT_VALUE_GREATER_THAN, SORT_VALUE_LESS_THAN, SPLIT_STRING_TREE_NODE_ROOT_VALUE, ServerErrorResponse, SetDeltaChange, SimpleStorageObject, StorageObject, StorageObjectUtility, StoredDataError, SyncState, TOTAL_LATITUDE_RANGE, TOTAL_LONGITUDE_RANGE, TOTAL_SPAN_OF_LONGITUDE, TRAILING_FILE_TYPE_SEPARATORS_REGEX, TRAILING_SLASHES_REGEX, TimeAM, TimerCancelledError, TimerInstance, TypedServiceRegistryInstance, UNLOADED_PAGE, US_STATE_CODE_STRING_REGEX, UTC_DATE_STRING_REGEX, UTC_TIMEZONE_STRING, UTF_8_START_CHARACTER, UTF_PRIVATE_USAGE_AREA_START, UnauthorizedServerErrorResponse, WEBSITE_TLD_DETECTION_REGEX, WEB_PROTOCOL_PREFIX_REGEX, ZIP_CODE_STRING_REGEX, addHttpToUrl, addLatLngPoints, addModifiers, addPlusPrefixToNumber, addPrefix, addPrefixFunction, addSuffix, addSuffixFunction, addToSet, addToSetCopy, addToSplitStringTree, allFalsyOrEmptyKeys, allIndexesInIndexRange, allKeyValueTuples, allMaybeSoKeys, allNonUndefinedKeys, allObjectsAreEqual, allValuesAreMaybeNot, allValuesAreNotMaybe, allowValueOnceFilter, applyBestFit, applySplitStringTreeWithMultipleValues, applyToMultipleFields, approximateTimerEndDate, areEqualContext, areEqualPOJOValues, arrayContainsDuplicateValue, arrayContentsDiffer, arrayDecision, arrayDecisionFunction, arrayFactory, arrayInputFactory, arrayToLowercase, arrayToMap, arrayToObject, arrayToUppercase, asArray, asDecisionFunction, asGetter, asIndexRangeCheckFunctionConfig, asIterable, asMinuteOfDay, asNumber, asObjectCopyFactory, asPromise, asSet, assignValuesToPOJO, assignValuesToPOJOFunction, authClaims, authRoleClaimsService, authRolesSetHasRoles, baseWebsiteUrl, batch, batchCalc, bitwiseObjectDencoder, bitwiseObjectEncoder, bitwiseObjectdecoder, bitwiseSetDecoder, bitwiseSetDencoder, booleanFactory, booleanKeyArrayUtility, boundNumber, boundNumberFunction, boundToRectangle, build, cachedGetter, capLatValue, capitalizeFirstLetter, caseInsensitiveFilterByIndexOfDecisionFactory, caseInsensitiveString, catchAllHandlerKey, chainMapFunction, chainMapSameFunctions, coerceToEmailParticipants, combineMaps, compareEqualityWithValueFromItemsFunction, compareEqualityWithValueFromItemsFunctionFactory, compareFnOrder, compareWithMappedValuesFunction, computeNextFractionalHour, computeNextFreeIndexFunction, concatArrays, concatArraysUnique, containsAllStringsAnyCase, containsAllValues, containsAnyStringAnyCase, containsAnyValue, containsAnyValueFromSet, containsNoValueFromSet, containsNoneOfValue, containsStringAnyCase, convertEmailParticipantStringToParticipant, convertMaybeToArray, convertParticipantToEmailParticipantString, convertToArray, copyArray, copyField, copyLatLngBound, copyLatLngPoint, copyObject, copySetAndDo, countAllInNestedArray, countPOJOKeys, countPOJOKeysFunction, cronExpressionRepeatingEveryNMinutes, cssClassesSet, cutToPrecision, cutValueToInteger, cutValueToPrecision, cutValueToPrecisionFunction, dateFromLogicalDate, dateFromMinuteOfDay, dateToHoursAndMinutes, dateToMinuteOfDay, dayOfWeek, daysOfWeekArray, daysOfWeekFromEnabledDays, daysOfWeekNameFunction, daysOfWeekNameMap, decisionFunction, decodeHashedValues, decodeHashedValuesWithDecodeMap, decodeModelKeyTypePair, defaultFilterFromPOJOFunctionNoCopy, defaultForwardFunctionFactory, defaultLatLngPoint, defaultLatLngString, dencodeBitwiseSet, diffLatLngBoundPoints, diffLatLngPoints, dollarAmountString, e164PhoneNumberExtensionPair, e164PhoneNumberFromE164PhoneNumberExtensionPair, enabledDaysFromDaysOfWeek, encodeBitwiseSet, encodeModelKeyTypePair, errorMessageContainsString, errorMessageContainsStringFunction, escapeStringCharactersFunction, escapeStringForRegex, excludeValues, excludeValuesFromArray, excludeValuesFromSet, existsInIterable, expandArrayMapTuples, expandArrayValueTuples, expandFlattenTreeFunction, expandIndexSet, expandTreeFunction, expandTrees, extendLatLngBound, filterAndMapFunction, filterEmptyValues, filterFalsyAndEmptyValues, filterFromIterable, filterFromPOJO, filterFromPOJOFunction, filterKeyValueTupleFunction, filterKeyValueTuples, filterKeyValueTuplesFunction, filterKeyValueTuplesInputToFilter, filterMaybeValues, filterNullAndUndefinedValues, filterOnlyUndefinedValues, filterUndefinedValues, filterUniqueByIndex, filterUniqueCaseInsensitiveStrings, filterUniqueFunction, filterUniqueTransform, filterUniqueValues, filterValuesByDistance, filterValuesByDistanceNoOrder, filterValuesToSet, filterValuesUsingSet, filteredPage, findAllCharacterOccurences, findAllCharacterOccurencesFunction, findBest, findBestIndexMatch, findBestIndexMatchFunction, findBestIndexSetPair, findBestSplitStringTreeChildMatch, findBestSplitStringTreeChildMatchPath, findBestSplitStringTreeMatch, findBestSplitStringTreeMatchPath, findFirstCharacterOccurence, findInIterable, findIndexOfFirstDuplicateValue, findItemsByIndex, findNext, findPOJOKeys, findPOJOKeysFunction, findStringsRegexString, findToIndexSet, findValuesFrom, firstAndLastCharacterOccurrence, firstAndLastValue, firstValue, firstValueFromIterable, fitToIndexRangeFunction, fixExtraQueryParameters, fixMultiSlashesInSlashPath, flattenArray, flattenArrayOrValueArray, flattenArrayToSet, flattenArrayUnique, flattenArrayUniqueCaseInsensitiveStrings, flattenTree, flattenTreeToArray, flattenTreeToArrayFunction, flattenTrees, forEachInIterable, forEachKeyValue, forEachKeyValueOnPOJOFunction, forEachWithArray, forwardFunction, fractionalHoursToMinutes, generateIfDoesNotExist, getArrayNextIndex, getDayOffset, getDayTomorrow, getDayYesterday, getDaysOfWeekNames, getFunctionType, getNextDay, getNextPageNumber, getOverlappingRectangle, getPageNumber, getPreviousDay, getValueFromGetter, groupValues, handlerBindAccessor, handlerConfigurerFactory, handlerFactory, handlerMappedSetFunction, handlerMappedSetFunctionFactory, handlerSetFunction, hasDifferentStringsNoCase, hasDifferentValues, hasHttpPrefix, hasNonNullValue, hasPortNumber, hasSameTimezone, hasSameValues, hasValueFunction, hasValueOrNotEmpty, hasValueOrNotEmptyObject, hasWebsiteDomain, hasWebsiteTopLevelDomain, hashSetForIndexed, hourToFractionalHour, idBatchFactory, incrementingNumberFactory, indexDeltaGroup, indexDeltaGroupFunction, indexRange, indexRangeCheckFunction, indexRangeCheckReaderFunction, indexRangeForArray, indexRangeOverlapsIndexRange, indexRangeOverlapsIndexRangeFunction, indexRangeReaderPairFactory, indexRefMap, indexedValuesArrayAccessorFactory, insertIntoBooleanKeyArray, invertBooleanReturnFunction, invertDecision, invertFilter, isAllowed, isClassLikeType, isCompleteUnitedStatesAddress, isConsideredUtcTimezoneString, isDate, isDefaultLatLngPoint, isDefaultLatLngPointValue, isDefaultReadableError, isDefinedAndNotFalse, isDollarAmountString, isE164PhoneNumber, isE164PhoneNumberWithExtension, isEmptyIterable, isEqualContext, isEqualDate, isEqualToValueDecisionFunction, isEvenNumber, isFalseBooleanKeyArray, isFinalPage, isGetter, isISO8601DateString, isISO8601DayString, isISO8601DayStringStart, isInAllowedDaysOfWeekSet, isInNumberBoundFunction, isInSetDecisionFunction, isIndexNumberInIndexRange, isIndexNumberInIndexRangeFunction, isIndexRangeInIndexRange, isIndexRangeInIndexRangeFunction, isIterable, isKnownHttpWebsiteProtocol, isLatLngBound, isLatLngBoundWithinLatLngBound, isLatLngPoint, isLatLngPointWithinLatLngBound, isLatLngString, isLogicalDateStringCode, isMapIdentityFunction, isMaybeNot, isMaybeNotOrTrue, isMaybeSo, isMinuteOfDay, isModelKey, isMonthDaySlashDate, isNonClassFunction, isNotNullOrEmptyString, isNumberDivisibleBy, isObjectWithConstructor, isOddNumber, isPast, isPromise, isPromiseLike, isSameLatLngBound, isSameLatLngPoint, isSameNonNullValue, isSameVector, isSelectedDecisionFunctionFactory, isSelectedIndexDecisionFunction, isServerError, isSlashPathFile, isSlashPathFolder, isSlashPathTypedFile, isStandardInternetAccessibleWebsiteUrl, isStringOrTrue, isTrueBooleanKeyArray, isUTCDateString, isUniqueKeyedFunction, isUsStateCodeString, isValidLatLngPoint, isValidLatitude, isValidLongitude, isValidNumberBound, isValidPhoneExtensionNumber, isValidSlashPath, isWebsiteUrl, isWebsiteUrlWithPrefix, isWithinLatLngBoundFunction, isolateSlashPath, isolateSlashPathFunction, isolateWebsitePathFunction, itemCountForBatchIndex, iterableToArray, iterableToMap, iterableToSet, iterablesAreSetEquivalent, iterate, iterateFilteredPages, joinHostAndPort, joinStringsWithSpaces, keepCharactersAfterFirstCharacterOccurence, keepCharactersAfterFirstCharacterOccurenceFunction, keepFromSetCopy, keepValuesFromArray, keepValuesFromSet, keyValueMapFactory, labeledValueMap, lastValue, latLngBound, latLngBoundCenterPoint, latLngBoundEastBound, latLngBoundFromInput, latLngBoundFullyWrapsMap, latLngBoundFunction, latLngBoundNorthBound, latLngBoundNorthEastPoint, latLngBoundNorthWestPoint, latLngBoundOverlapsLatLngBound, latLngBoundSouthBound, latLngBoundSouthEastPoint, latLngBoundSouthWestPoint, latLngBoundStrictlyWrapsMap, latLngBoundTuple, latLngBoundTupleFunction, latLngBoundWestBound, latLngBoundWrapsMap, latLngDataPointFunction, latLngPoint, latLngPointFromString, latLngPointFunction, latLngPointPrecisionFunction, latLngString, latLngStringFunction, latLngTuple, latLngTupleFunction, limitArray, lonLatTuple, lowercaseFirstLetter, mailToUrlString, makeBestFit, makeCopyModelFieldFunction, makeDateMonthForMonthOfYear, makeGetter, makeHandler, makeHashDecodeMap, makeKeyPairs, makeModelConversionFieldValuesFunction, makeModelMap, makeModelMapFunctions, makeMultiModelKeyMap, makeValuesGroupMap, makeWithFactory, makeWithFactoryInput, mapArrayFunction, mapFunctionOutput, mapFunctionOutputPair, mapGetter, mapGetterFactory, mapIdentityFunction, mapIterable, mapKeysIntersectionObjectToArray, mapMaybeFunction, mapObjectMap, mapObjectMapFunction, mapObjectToTargetObject, mapPromiseOrValue, mapToObject, mapToTuples, mapValuesToSet, mappedUseAsyncFunction, mappedUseFunction, mapsHaveSameKeys, maybeMergeModelModifiers, maybeMergeModifiers, maybeModifierMapToFunction, maybeSet, mergeArrays, mergeArraysIntoArray, mergeFilterFunctions, mergeModifiers, mergeObjects, mergeObjectsFunction, mergeSlashPaths, messageFromError, minAndMaxFunction, minAndMaxIndex, minAndMaxIndexFunction, minAndMaxIndexItemsFunction, minAndMaxNumber, minutesToFractionalHours, minutesToHoursAndMinutes, modelFieldConversions, modelFieldMapFunction, modelFieldMapFunctions, modelTypeDataPairFactory, modifier, modifierMapToFunction, modifyModelMapFunction, modifyModelMapFunctions, monthDaySlashDateToDateString, monthOfYearFromDate, monthOfYearFromDateMonth, multiKeyValueMapFactory, multiValueMapBuilder, neMostLatLngPoint, nearestDivisibleValues, numberStringDencoder, numberStringDencoderDecodedNumberValueFunction, numberStringDencoderEncodedStringValueFunction, numberStringDencoderFunction, objectCopyFactory, objectDeltaArrayCompressor, objectFieldEqualityChecker, objectFlatMergeMatrix, objectHasKey, objectHasKeys, objectHasNoKeys, objectIsEmpty, objectKeyEqualityComparatorFunction, objectKeysEqualityComparatorFunction, objectMergeMatrix, objectToMap, objectToTuples, overlapsLatLngBoundFunction, overrideInObject, overrideInObjectFunctionFactory, padStartFunction, pairGroupValues, parseISO8601DayStringToUTCDate, partialServerError, passThrough, percentNumberFromDecimal, percentNumberToDecimal, performAsyncTask, performAsyncTasks, performBatchLoop, performMakeLoop, performTaskCountLoop, performTaskLoop, performTasksFromFactoryInParallelFunction, performTasksInParallel, performTasksInParallelFunction, pickOneRandomly, poll, primativeKeyDencoder, primativeKeyDencoderMap, primativeKeyStringDencoder, primativeValuesDelta, promiseReference, protectedFactory, pushArrayItemsIntoArray, pushElementOntoArray, pushItemOrArrayItemsIntoArray, randomArrayFactory, randomArrayIndex, randomBoolean, randomEmailFactory, randomFromArrayFactory, randomLatLngFactory, randomLatLngFromCenterFactory, randomNumber, randomNumberFactory, randomPhoneNumberFactory, randomPickFactory, range, rangedIndexedValuesArrayAccessorFactory, rangedIndexedValuesArrayAccessorInfoFactory, readBooleanKeySafetyWrap, readDomainFromEmailAddress, readDomainsFromEmailAddresses, readEmailDomainFromUrlOrEmailAddress, readIndexNumber, readKeysFrom, readKeysFromFilterUniqueFunctionAdditionalKeys, readKeysFromFilterUniqueFunctionAdditionalKeysInput, readKeysFunction, readKeysSetFrom, readKeysSetFunction, readKeysToMap, readModelKey, readModelKeyFromObject, readModelKeys, readModelKeysFromObjects, readMultipleKeysToMap, readPortNumber, readUniqueModelKey, readWebsiteProtocol, readableError, readableStreamToBase64, readableStreamToBuffer, readableStreamToStringFunction, rectangleOverlapsRectangle, reduceBooleansFn, reduceBooleansWithAnd, reduceBooleansWithAndFn, reduceBooleansWithOr, reduceBooleansWithOrFn, reduceNumbers, reduceNumbersFn, reduceNumbersWithAdd, reduceNumbersWithAddFn, reduceNumbersWithMax, reduceNumbersWithMaxFn, reduceNumbersWithMin, reduceNumbersWithMinFn, removeByKeyFromBooleanKeyArray, removeCharactersAfterFirstCharacterOccurence, removeCharactersAfterFirstCharacterOccurenceFunction, removeExtensionFromPhoneNumber, removeFromBooleanKeyArray, removeFromSet, removeFromSetCopy, removeHttpFromUrl, removeModelsWithKey, removeModelsWithSameKey, removeModifiers, removeTrailingFileTypeSeparators, removeTrailingSlashes, removeWebProtocolPrefix, repeatString, replaceCharacterAtIndexIf, replaceCharacterAtIndexWith, replaceInvalidFilePathTypeSeparatorsInSlashPath, replaceInvalidFilePathTypeSeparatorsInSlashPathFunction, replaceLastCharacterIf, replaceLastCharacterIfIsFunction, replaceMultipleFilePathsInSlashPath, replaceStringsFunction, requireModelKey, restoreOrder, restoreOrderWithValues, reverseCompareFn, roundNumberToStepFunction, roundNumberUpToStep, roundToPrecision, roundToPrecisionFunction, roundingFunction, runAsyncTaskForValue, runAsyncTasksForValues, safeCompareEquality, safeEqualityComparatorFunction, safeFindBestIndexMatch, searchStringFilterFunction, separateValues, separateValuesToSets, sequentialIncrementingNumberStringModelIdFactory, serverError, setContainsAllValues, setContainsAnyValue, setContainsNoneOfValue, setDeltaChangeKeys, setDeltaFunction, setHasValueFunction, setIncludes, setIncludesFunction, setKeysOnMap, setWebProtocolPrefix, setsAreEquivalent, simpleSortValuesFunctionWithSortRef, slashPathFactory, slashPathInvalidError, slashPathName, slashPathParts, slashPathStartTypeFactory, slashPathType, slashPathValidationFactory, sliceIndexRangeFunction, sortAscendingIndexNumberRefFunction, sortByIndexAscendingCompareFunction, sortByIndexRangeAscendingCompareFunction, sortByLabelFunction, sortByNumberFunction, sortByStringFunction, sortCompareNumberFunction, sortNumbersAscendingFunction, sortValues, sortValuesFunctionOrMapIdentityWithSortRef, sortValuesFunctionWithSortRef, spaceSeparatedCssClasses, splitCommaSeparatedString, splitCommaSeparatedStringToSet, splitJoinNameString, splitJoinRemainder, splitStringAtFirstCharacterOccurence, splitStringAtFirstCharacterOccurenceFunction, splitStringAtIndex, splitStringTreeFactory, startOfDayForSystemDateInUTC, startOfDayForUTCDateInUTC, stepsFromIndex, stepsFromIndexFunction, stringCharactersToIndexRecord, stringContains, stringFactoryFromFactory, stringToLowercaseFunction, stringToUppercaseFunction, stringTrimFunction, sumOfIntegersBetween, swMostLatLngPoint, symmetricDifferenceArray, symmetricDifferenceArrayBetweenSets, symmetricDifferenceWithModels, takeFront, takeLast, takeValuesFromIterable, telUrlString, telUrlStringForE164PhoneNumberPair, terminatingFactoryFromArray, throwKeyIsRequired, timePeriodCounter, timer, toAbsoluteSlashPathStartType, toCaseInsensitiveStringArray, toMinuteOfDay, toModelFieldConversions, toModelMapFunctions, toReadableError, toRelativeSlashPathStartType, toggleInSet, toggleInSetCopy, toggleTimerRunning, transformNumberFunction, transformNumberFunctionConfig, transformStringFunction, transformStringFunctionConfig, transformStrings, trimArray, tryWithPromiseFactoriesFunction, typedServiceRegistry, unique, uniqueCaseInsensitiveStrings, uniqueCaseInsensitiveStringsSet, uniqueKeys, uniqueModels, unitedStatesAddressString, urlWithoutParameters, useAsync, useCallback, useContextFunction, useIterableOrValue, useModelOrKey, usePromise, useValue, validLatLngPoint, validLatLngPointFunction, valueAtIndex, valuesAreBothNullishOrEquivalent, valuesFromPOJO, valuesFromPOJOFunction, vectorMinimumSizeResizeFunction, vectorsAreEqual, waitForMs, websiteDomainAndPathPair, websiteDomainAndPathPairFromWebsiteUrl, websitePathAndQueryPair, websitePathFromWebsiteDomainAndPath, websitePathFromWebsiteUrl, websiteUrlFromPaths, wrapIndexRangeFunction, wrapLatLngPoint, wrapLngValue, wrapMapFunctionOutput, wrapNumberFunction, wrapTuples, wrapUseAsyncFunction, wrapUseFunction };
|
|
17387
|
+
export { ALL_DOUBLE_SLASHES_REGEX, ALL_SLASHES_REGEX, ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX, ASSERTION_ERROR_CODE, ASSERTION_HANDLER, AUTH_ADMIN_ROLE, AUTH_ONBOARDED_ROLE, AUTH_ROLE_CLAIMS_DEFAULT_CLAIM_VALUE, AUTH_ROLE_CLAIMS_DEFAULT_EMPTY_VALUE, AUTH_TOS_SIGNED_ROLE, AUTH_USER_ROLE, AbstractUniqueModel, Assert, AssertMax, AssertMin, AssertionError, AssertionIssueHandler, BooleanStringKeyArrayUtility, BooleanStringKeyArrayUtilityInstance, CATCH_ALL_HANDLE_RESULT_KEY, CUT_VALUE_TO_ZERO_PRECISION, DATE_NOW_VALUE, DEFAULT_LAT_LNG_STRING_VALUE, DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG, DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG, DEFAULT_READABLE_ERROR_CODE, DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS, DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT, DEFAULT_UNKNOWN_MODEL_TYPE_STRING, DOLLAR_AMOUNT_PRECISION, DOLLAR_AMOUNT_STRING_REGEX, DataDoesNotExistError, DataIsExpiredError, Day, DestroyFunctionObject, E164PHONE_NUMBER_REGEX, E164PHONE_NUMBER_WITH_EXTENSION_REGEX, E164PHONE_NUMBER_WITH_OPTIONAL_EXTENSION_REGEX, FINAL_PAGE, FIRST_PAGE, FRACTIONAL_HOURS_PRECISION_FUNCTION, FullStorageObject, HAS_PORT_NUMBER_REGEX, HAS_WEBSITE_DOMAIN_NAME_REGEX, HOURS_IN_DAY, HTTP_OR_HTTPS_REGEX, HashSet, ISO8601_DAY_STRING_REGEX, ISO8601_DAY_STRING_START_REGEX, ISO_8601_DATE_STRING_REGEX, KeyValueTypleValueFilter, LAT_LNG_PATTERN, LAT_LNG_PATTERN_MAX_PRECISION, LAT_LONG_100KM_PRECISION, LAT_LONG_100M_PRECISION, LAT_LONG_10CM_PRECISION, LAT_LONG_10KM_PRECISION, LAT_LONG_10M_PRECISION, LAT_LONG_1CM_PRECISION, LAT_LONG_1KM_PRECISION, LAT_LONG_1MM_PRECISION, LAT_LONG_1M_PRECISION, LAT_LONG_GRAINS_OF_SAND_PRECISION, LEADING_SLASHES_REGEX, MAP_IDENTITY, MAX_BITWISE_SET_SIZE, MAX_LATITUDE_VALUE, MAX_LONGITUDE_VALUE, MINUTES_IN_DAY, MINUTES_IN_HOUR, MINUTE_OF_DAY_MAXMIMUM, MINUTE_OF_DAY_MINIUMUM, MIN_LATITUDE_VALUE, MIN_LONGITUDE_VALUE, MONTH_DAY_SLASH_DATE_STRING_REGEX, MS_IN_DAY, MS_IN_HOUR, MS_IN_MINUTE, MS_IN_SECOND, MemoryStorageInstance, ModelRelationUtility, NOOP_MODIFIER, NUMBER_STRING_DENCODER_64, NUMBER_STRING_DENCODER_64_DEFAULT_NEGATIVE_PREFIX, NUMBER_STRING_DENCODER_64_DIGITS, PHONE_EXTENSION_NUMBER_REGEX, PRIMATIVE_KEY_DENCODER_VALUE, PageCalculator, PropertyDescriptorUtility, REGEX_SPECIAL_CHARACTERS, REGEX_SPECIAL_CHARACTERS_SET, RelationChange, SECONDS_IN_MINUTE, SHARED_MEMORY_STORAGE, SLASH_PATH_FILE_TYPE_SEPARATOR, SLASH_PATH_SEPARATOR, SORT_VALUE_EQUAL, SORT_VALUE_GREATER_THAN, SORT_VALUE_LESS_THAN, SPLIT_STRING_TREE_NODE_ROOT_VALUE, ServerErrorResponse, SetDeltaChange, SimpleStorageObject, StorageObject, StorageObjectUtility, StoredDataError, SyncState, TOTAL_LATITUDE_RANGE, TOTAL_LONGITUDE_RANGE, TOTAL_SPAN_OF_LONGITUDE, TRAILING_FILE_TYPE_SEPARATORS_REGEX, TRAILING_SLASHES_REGEX, TimeAM, TimerCancelledError, TimerInstance, TypedServiceRegistryInstance, UNLOADED_PAGE, US_STATE_CODE_STRING_REGEX, UTC_DATE_STRING_REGEX, UTC_TIMEZONE_STRING, UTF_8_START_CHARACTER, UTF_PRIVATE_USAGE_AREA_START, UnauthorizedServerErrorResponse, WEBSITE_TLD_DETECTION_REGEX, WEB_PROTOCOL_PREFIX_REGEX, ZIP_CODE_STRING_REGEX, addHttpToUrl, addLatLngPoints, addModifiers, addPlusPrefixToNumber, addPrefix, addPrefixFunction, addSuffix, addSuffixFunction, addToSet, addToSetCopy, addToSplitStringTree, allFalsyOrEmptyKeys, allIndexesInIndexRange, allKeyValueTuples, allMaybeSoKeys, allNonUndefinedKeys, allObjectsAreEqual, allValuesAreMaybeNot, allValuesAreNotMaybe, allowValueOnceFilter, applyBestFit, applySplitStringTreeWithMultipleValues, applyToMultipleFields, approximateTimerEndDate, areEqualContext, areEqualPOJOValues, arrayContainsDuplicateValue, arrayContentsDiffer, arrayDecision, arrayDecisionFunction, arrayFactory, arrayInputFactory, arrayToLowercase, arrayToMap, arrayToObject, arrayToUppercase, asArray, asDecisionFunction, asGetter, asIndexRangeCheckFunctionConfig, asIterable, asMinuteOfDay, asNumber, asObjectCopyFactory, asPromise, asSet, assignValuesToPOJO, assignValuesToPOJOFunction, authClaims, authRoleClaimsService, authRolesSetHasRoles, baseWebsiteUrl, batch, batchCalc, bitwiseObjectDencoder, bitwiseObjectEncoder, bitwiseObjectdecoder, bitwiseSetDecoder, bitwiseSetDencoder, booleanFactory, booleanKeyArrayUtility, boundNumber, boundNumberFunction, boundToRectangle, build, cachedGetter, capLatValue, capitalizeFirstLetter, caseInsensitiveFilterByIndexOfDecisionFactory, caseInsensitiveString, catchAllHandlerKey, chainMapFunction, chainMapSameFunctions, coerceToEmailParticipants, combineMaps, compareEqualityWithValueFromItemsFunction, compareEqualityWithValueFromItemsFunctionFactory, compareFnOrder, compareWithMappedValuesFunction, computeNextFractionalHour, computeNextFreeIndexFunction, concatArrays, concatArraysUnique, containsAllStringsAnyCase, containsAllValues, containsAnyStringAnyCase, containsAnyValue, containsAnyValueFromSet, containsNoValueFromSet, containsNoneOfValue, containsStringAnyCase, convertEmailParticipantStringToParticipant, convertMaybeToArray, convertParticipantToEmailParticipantString, convertToArray, copyArray, copyField, copyLatLngBound, copyLatLngPoint, copyObject, copySetAndDo, countAllInNestedArray, countPOJOKeys, countPOJOKeysFunction, cronExpressionRepeatingEveryNMinutes, cssClassesSet, cutToPrecision, cutValueToInteger, cutValueToPrecision, cutValueToPrecisionFunction, dateFromLogicalDate, dateFromMinuteOfDay, dateToHoursAndMinutes, dateToMinuteOfDay, dayOfWeek, daysOfWeekArray, daysOfWeekFromEnabledDays, daysOfWeekNameFunction, daysOfWeekNameMap, decisionFunction, decodeHashedValues, decodeHashedValuesWithDecodeMap, decodeModelKeyTypePair, defaultFilterFromPOJOFunctionNoCopy, defaultForwardFunctionFactory, defaultLatLngPoint, defaultLatLngString, dencodeBitwiseSet, diffLatLngBoundPoints, diffLatLngPoints, dollarAmountString, e164PhoneNumberExtensionPair, e164PhoneNumberFromE164PhoneNumberExtensionPair, enabledDaysFromDaysOfWeek, encodeBitwiseSet, encodeModelKeyTypePair, errorMessageContainsString, errorMessageContainsStringFunction, escapeStringCharactersFunction, escapeStringForRegex, excludeValues, excludeValuesFromArray, excludeValuesFromSet, existsInIterable, expandArrayMapTuples, expandArrayValueTuples, expandFlattenTreeFunction, expandIndexSet, expandTreeFunction, expandTrees, exponentialPromiseRateLimiter, extendLatLngBound, filterAndMapFunction, filterEmptyValues, filterFalsyAndEmptyValues, filterFromIterable, filterFromPOJO, filterFromPOJOFunction, filterKeyValueTupleFunction, filterKeyValueTuples, filterKeyValueTuplesFunction, filterKeyValueTuplesInputToFilter, filterMaybeValues, filterNullAndUndefinedValues, filterOnlyUndefinedValues, filterUndefinedValues, filterUniqueByIndex, filterUniqueCaseInsensitiveStrings, filterUniqueFunction, filterUniqueTransform, filterUniqueValues, filterValuesByDistance, filterValuesByDistanceNoOrder, filterValuesToSet, filterValuesUsingSet, filteredPage, findAllCharacterOccurences, findAllCharacterOccurencesFunction, findBest, findBestIndexMatch, findBestIndexMatchFunction, findBestIndexSetPair, findBestSplitStringTreeChildMatch, findBestSplitStringTreeChildMatchPath, findBestSplitStringTreeMatch, findBestSplitStringTreeMatchPath, findFirstCharacterOccurence, findInIterable, findIndexOfFirstDuplicateValue, findItemsByIndex, findNext, findPOJOKeys, findPOJOKeysFunction, findStringsRegexString, findToIndexSet, findValuesFrom, firstAndLastCharacterOccurrence, firstAndLastValue, firstValue, firstValueFromIterable, fitToIndexRangeFunction, fixExtraQueryParameters, fixMultiSlashesInSlashPath, flattenArray, flattenArrayOrValueArray, flattenArrayToSet, flattenArrayUnique, flattenArrayUniqueCaseInsensitiveStrings, flattenTree, flattenTreeToArray, flattenTreeToArrayFunction, flattenTrees, forEachInIterable, forEachKeyValue, forEachKeyValueOnPOJOFunction, forEachWithArray, forwardFunction, fractionalHoursToMinutes, generateIfDoesNotExist, getArrayNextIndex, getBaseLog, getDayOffset, getDayTomorrow, getDayYesterday, getDaysOfWeekNames, getFunctionType, getNextDay, getNextPageNumber, getOverlappingRectangle, getPageNumber, getPreviousDay, getValueFromGetter, groupValues, handlerBindAccessor, handlerConfigurerFactory, handlerFactory, handlerMappedSetFunction, handlerMappedSetFunctionFactory, handlerSetFunction, hasDifferentStringsNoCase, hasDifferentValues, hasHttpPrefix, hasNonNullValue, hasPortNumber, hasSameTimezone, hasSameValues, hasValueFunction, hasValueOrNotEmpty, hasValueOrNotEmptyObject, hasWebsiteDomain, hasWebsiteTopLevelDomain, hashSetForIndexed, hourToFractionalHour, idBatchFactory, incrementingNumberFactory, indexDeltaGroup, indexDeltaGroupFunction, indexRange, indexRangeCheckFunction, indexRangeCheckReaderFunction, indexRangeForArray, indexRangeOverlapsIndexRange, indexRangeOverlapsIndexRangeFunction, indexRangeReaderPairFactory, indexRefMap, indexedValuesArrayAccessorFactory, insertIntoBooleanKeyArray, invertBooleanReturnFunction, invertDecision, invertFilter, isAllowed, isClassLikeType, isCompleteUnitedStatesAddress, isConsideredUtcTimezoneString, isDate, isDefaultLatLngPoint, isDefaultLatLngPointValue, isDefaultReadableError, isDefinedAndNotFalse, isDollarAmountString, isE164PhoneNumber, isE164PhoneNumberWithExtension, isEmptyIterable, isEqualContext, isEqualDate, isEqualToValueDecisionFunction, isEvenNumber, isFalseBooleanKeyArray, isFinalPage, isGetter, isISO8601DateString, isISO8601DayString, isISO8601DayStringStart, isInAllowedDaysOfWeekSet, isInNumberBoundFunction, isInSetDecisionFunction, isIndexNumberInIndexRange, isIndexNumberInIndexRangeFunction, isIndexRangeInIndexRange, isIndexRangeInIndexRangeFunction, isIterable, isKnownHttpWebsiteProtocol, isLatLngBound, isLatLngBoundWithinLatLngBound, isLatLngPoint, isLatLngPointWithinLatLngBound, isLatLngString, isLogicalDateStringCode, isMapIdentityFunction, isMaybeNot, isMaybeNotOrTrue, isMaybeSo, isMinuteOfDay, isModelKey, isMonthDaySlashDate, isNonClassFunction, isNotNullOrEmptyString, isNumberDivisibleBy, isObjectWithConstructor, isOddNumber, isPast, isPromise, isPromiseLike, isSameLatLngBound, isSameLatLngPoint, isSameNonNullValue, isSameVector, isSelectedDecisionFunctionFactory, isSelectedIndexDecisionFunction, isServerError, isSlashPathFile, isSlashPathFolder, isSlashPathTypedFile, isStandardInternetAccessibleWebsiteUrl, isStringOrTrue, isTrueBooleanKeyArray, isUTCDateString, isUniqueKeyedFunction, isUsStateCodeString, isValidLatLngPoint, isValidLatitude, isValidLongitude, isValidNumberBound, isValidPhoneExtensionNumber, isValidSlashPath, isWebsiteUrl, isWebsiteUrlWithPrefix, isWithinLatLngBoundFunction, isolateSlashPath, isolateSlashPathFunction, isolateWebsitePathFunction, itemCountForBatchIndex, iterableToArray, iterableToMap, iterableToSet, iterablesAreSetEquivalent, iterate, iterateFilteredPages, joinHostAndPort, joinStringsWithSpaces, keepCharactersAfterFirstCharacterOccurence, keepCharactersAfterFirstCharacterOccurenceFunction, keepFromSetCopy, keepValuesFromArray, keepValuesFromSet, keyValueMapFactory, labeledValueMap, lastValue, latLngBound, latLngBoundCenterPoint, latLngBoundEastBound, latLngBoundFromInput, latLngBoundFullyWrapsMap, latLngBoundFunction, latLngBoundNorthBound, latLngBoundNorthEastPoint, latLngBoundNorthWestPoint, latLngBoundOverlapsLatLngBound, latLngBoundSouthBound, latLngBoundSouthEastPoint, latLngBoundSouthWestPoint, latLngBoundStrictlyWrapsMap, latLngBoundTuple, latLngBoundTupleFunction, latLngBoundWestBound, latLngBoundWrapsMap, latLngDataPointFunction, latLngPoint, latLngPointFromString, latLngPointFunction, latLngPointPrecisionFunction, latLngString, latLngStringFunction, latLngTuple, latLngTupleFunction, limitArray, lonLatTuple, lowercaseFirstLetter, mailToUrlString, makeBestFit, makeCopyModelFieldFunction, makeDateMonthForMonthOfYear, makeGetter, makeHandler, makeHashDecodeMap, makeKeyPairs, makeModelConversionFieldValuesFunction, makeModelMap, makeModelMapFunctions, makeMultiModelKeyMap, makeValuesGroupMap, makeWithFactory, makeWithFactoryInput, mapArrayFunction, mapFunctionOutput, mapFunctionOutputPair, mapGetter, mapGetterFactory, mapIdentityFunction, mapIterable, mapKeysIntersectionObjectToArray, mapMaybeFunction, mapObjectMap, mapObjectMapFunction, mapObjectToTargetObject, mapPromiseOrValue, mapToObject, mapToTuples, mapValuesToSet, mappedUseAsyncFunction, mappedUseFunction, mapsHaveSameKeys, maybeMergeModelModifiers, maybeMergeModifiers, maybeModifierMapToFunction, maybeSet, mergeArrays, mergeArraysIntoArray, mergeFilterFunctions, mergeModifiers, mergeObjects, mergeObjectsFunction, mergeSlashPaths, messageFromError, minAndMaxFunction, minAndMaxIndex, minAndMaxIndexFunction, minAndMaxIndexItemsFunction, minAndMaxNumber, minutesToFractionalHours, minutesToHoursAndMinutes, modelFieldConversions, modelFieldMapFunction, modelFieldMapFunctions, modelTypeDataPairFactory, modifier, modifierMapToFunction, modifyModelMapFunction, modifyModelMapFunctions, monthDaySlashDateToDateString, monthOfYearFromDate, monthOfYearFromDateMonth, multiKeyValueMapFactory, multiValueMapBuilder, neMostLatLngPoint, nearestDivisibleValues, numberStringDencoder, numberStringDencoderDecodedNumberValueFunction, numberStringDencoderEncodedStringValueFunction, numberStringDencoderFunction, objectCopyFactory, objectDeltaArrayCompressor, objectFieldEqualityChecker, objectFlatMergeMatrix, objectHasKey, objectHasKeys, objectHasNoKeys, objectIsEmpty, objectKeyEqualityComparatorFunction, objectKeysEqualityComparatorFunction, objectMergeMatrix, objectToMap, objectToTuples, overlapsLatLngBoundFunction, overrideInObject, overrideInObjectFunctionFactory, padStartFunction, pairGroupValues, parseISO8601DayStringToUTCDate, partialServerError, passThrough, percentNumberFromDecimal, percentNumberToDecimal, performAsyncTask, performAsyncTasks, performBatchLoop, performMakeLoop, performTaskCountLoop, performTaskLoop, performTasksFromFactoryInParallelFunction, performTasksInParallel, performTasksInParallelFunction, pickOneRandomly, poll, primativeKeyDencoder, primativeKeyDencoderMap, primativeKeyStringDencoder, primativeValuesDelta, promiseReference, protectedFactory, pushArrayItemsIntoArray, pushElementOntoArray, pushItemOrArrayItemsIntoArray, randomArrayFactory, randomArrayIndex, randomBoolean, randomEmailFactory, randomFromArrayFactory, randomLatLngFactory, randomLatLngFromCenterFactory, randomNumber, randomNumberFactory, randomPhoneNumberFactory, randomPickFactory, range, rangedIndexedValuesArrayAccessorFactory, rangedIndexedValuesArrayAccessorInfoFactory, readBooleanKeySafetyWrap, readDomainFromEmailAddress, readDomainsFromEmailAddresses, readEmailDomainFromUrlOrEmailAddress, readIndexNumber, readKeysFrom, readKeysFromFilterUniqueFunctionAdditionalKeys, readKeysFromFilterUniqueFunctionAdditionalKeysInput, readKeysFunction, readKeysSetFrom, readKeysSetFunction, readKeysToMap, readModelKey, readModelKeyFromObject, readModelKeys, readModelKeysFromObjects, readMultipleKeysToMap, readPortNumber, readUniqueModelKey, readWebsiteProtocol, readableError, readableStreamToBase64, readableStreamToBuffer, readableStreamToStringFunction, rectangleOverlapsRectangle, reduceBooleansFn, reduceBooleansWithAnd, reduceBooleansWithAndFn, reduceBooleansWithOr, reduceBooleansWithOrFn, reduceNumbers, reduceNumbersFn, reduceNumbersWithAdd, reduceNumbersWithAddFn, reduceNumbersWithMax, reduceNumbersWithMaxFn, reduceNumbersWithMin, reduceNumbersWithMinFn, removeByKeyFromBooleanKeyArray, removeCharactersAfterFirstCharacterOccurence, removeCharactersAfterFirstCharacterOccurenceFunction, removeExtensionFromPhoneNumber, removeFromBooleanKeyArray, removeFromSet, removeFromSetCopy, removeHttpFromUrl, removeModelsWithKey, removeModelsWithSameKey, removeModifiers, removeTrailingFileTypeSeparators, removeTrailingSlashes, removeWebProtocolPrefix, repeatString, replaceCharacterAtIndexIf, replaceCharacterAtIndexWith, replaceInvalidFilePathTypeSeparatorsInSlashPath, replaceInvalidFilePathTypeSeparatorsInSlashPathFunction, replaceLastCharacterIf, replaceLastCharacterIfIsFunction, replaceMultipleFilePathsInSlashPath, replaceStringsFunction, requireModelKey, resetPeriodPromiseRateLimiter, restoreOrder, restoreOrderWithValues, reverseCompareFn, roundNumberToStepFunction, roundNumberUpToStep, roundToPrecision, roundToPrecisionFunction, roundingFunction, runAsyncTaskForValue, runAsyncTasksForValues, safeCompareEquality, safeEqualityComparatorFunction, safeFindBestIndexMatch, searchStringFilterFunction, separateValues, separateValuesToSets, sequentialIncrementingNumberStringModelIdFactory, serverError, setContainsAllValues, setContainsAnyValue, setContainsNoneOfValue, setDeltaChangeKeys, setDeltaFunction, setHasValueFunction, setIncludes, setIncludesFunction, setKeysOnMap, setWebProtocolPrefix, setsAreEquivalent, simpleSortValuesFunctionWithSortRef, slashPathFactory, slashPathInvalidError, slashPathName, slashPathParts, slashPathStartTypeFactory, slashPathType, slashPathValidationFactory, sliceIndexRangeFunction, sortAscendingIndexNumberRefFunction, sortByIndexAscendingCompareFunction, sortByIndexRangeAscendingCompareFunction, sortByLabelFunction, sortByNumberFunction, sortByStringFunction, sortCompareNumberFunction, sortNumbersAscendingFunction, sortValues, sortValuesFunctionOrMapIdentityWithSortRef, sortValuesFunctionWithSortRef, spaceSeparatedCssClasses, splitCommaSeparatedString, splitCommaSeparatedStringToSet, splitJoinNameString, splitJoinRemainder, splitStringAtFirstCharacterOccurence, splitStringAtFirstCharacterOccurenceFunction, splitStringAtIndex, splitStringTreeFactory, startOfDayForSystemDateInUTC, startOfDayForUTCDateInUTC, stepsFromIndex, stepsFromIndexFunction, stringCharactersToIndexRecord, stringContains, stringFactoryFromFactory, stringToLowercaseFunction, stringToUppercaseFunction, stringTrimFunction, sumOfIntegersBetween, swMostLatLngPoint, symmetricDifferenceArray, symmetricDifferenceArrayBetweenSets, symmetricDifferenceWithModels, takeFront, takeLast, takeValuesFromIterable, telUrlString, telUrlStringForE164PhoneNumberPair, terminatingFactoryFromArray, throwKeyIsRequired, timePeriodCounter, timer, toAbsoluteSlashPathStartType, toCaseInsensitiveStringArray, toMinuteOfDay, toModelFieldConversions, toModelMapFunctions, toReadableError, toRelativeSlashPathStartType, toggleInSet, toggleInSetCopy, toggleTimerRunning, transformNumberFunction, transformNumberFunctionConfig, transformStringFunction, transformStringFunctionConfig, transformStrings, trimArray, tryWithPromiseFactoriesFunction, typedServiceRegistry, unique, uniqueCaseInsensitiveStrings, uniqueCaseInsensitiveStringsSet, uniqueKeys, uniqueModels, unitedStatesAddressString, urlWithoutParameters, useAsync, useCallback, useContextFunction, useIterableOrValue, useModelOrKey, usePromise, useValue, validLatLngPoint, validLatLngPointFunction, valueAtIndex, valuesAreBothNullishOrEquivalent, valuesFromPOJO, valuesFromPOJOFunction, vectorMinimumSizeResizeFunction, vectorsAreEqual, waitForMs, websiteDomainAndPathPair, websiteDomainAndPathPairFromWebsiteUrl, websitePathAndQueryPair, websitePathFromWebsiteDomainAndPath, websitePathFromWebsiteUrl, websiteUrlFromPaths, wrapIndexRangeFunction, wrapLatLngPoint, wrapLngValue, wrapMapFunctionOutput, wrapNumberFunction, wrapTuples, wrapUseAsyncFunction, wrapUseFunction };
|
package/package.json
CHANGED
|
@@ -85,3 +85,15 @@ export declare const sortCompareNumberFunction: SortCompareFunction<number>;
|
|
|
85
85
|
* @returns
|
|
86
86
|
*/
|
|
87
87
|
export declare function minAndMaxNumber(values: Iterable<number>): MinAndMaxFunctionResult<number>;
|
|
88
|
+
/**
|
|
89
|
+
* Returns the lorgathirm of y with base x.
|
|
90
|
+
*
|
|
91
|
+
* Example:
|
|
92
|
+
* - (log2(16)): x = 2, y = 16 -> 4 (2^4 = 16)
|
|
93
|
+
* - (log10(100)): x = 10, y = 100 -> 2 (10^2 = 100)
|
|
94
|
+
*
|
|
95
|
+
* @param x
|
|
96
|
+
* @param y
|
|
97
|
+
* @returns
|
|
98
|
+
*/
|
|
99
|
+
export declare function getBaseLog(x: number, y: number): number;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { type Milliseconds } from '../date/date';
|
|
2
|
+
import { type Maybe } from '../value/maybe.type';
|
|
3
|
+
/**
|
|
4
|
+
* Interface for a rate limiter.
|
|
5
|
+
*/
|
|
6
|
+
export interface PromiseRateLimiter {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the expected wait time for the next wait.
|
|
9
|
+
*
|
|
10
|
+
* Can optionally provide an increase that updates the limiter to behave like the number of items is now being waited on.
|
|
11
|
+
*/
|
|
12
|
+
getNextWaitTime(increase?: number): Milliseconds;
|
|
13
|
+
/**
|
|
14
|
+
* Waits for the rate limited to allow the promise to continue.
|
|
15
|
+
*/
|
|
16
|
+
waitForRateLimit(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Interface for a PromiseRateLimiter that can be enabled or disabled.
|
|
20
|
+
*/
|
|
21
|
+
export interface EnableTogglePromiseRateLimiter extends PromiseRateLimiter {
|
|
22
|
+
/**
|
|
23
|
+
* Returns true if the rate limiter is enabled or not.
|
|
24
|
+
*/
|
|
25
|
+
getEnabled(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Enables or disables the rate limiter based on the inputs.
|
|
28
|
+
*
|
|
29
|
+
* @param enable
|
|
30
|
+
*/
|
|
31
|
+
setEnabled(enable: boolean): void;
|
|
32
|
+
}
|
|
33
|
+
export interface ExponentialPromiseRateLimiterConfig {
|
|
34
|
+
/**
|
|
35
|
+
* The base count to start limiting requests at. Minimum of 0 allowed.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to 0.
|
|
38
|
+
*/
|
|
39
|
+
readonly startLimitAt?: number;
|
|
40
|
+
/**
|
|
41
|
+
* How fast the cooldown occurs.
|
|
42
|
+
*
|
|
43
|
+
* Defaults to 1.
|
|
44
|
+
*/
|
|
45
|
+
readonly cooldownRate?: number;
|
|
46
|
+
/**
|
|
47
|
+
* The maximum amount of wait time to limit exponential requests to, if applicable.
|
|
48
|
+
*
|
|
49
|
+
* Defaults to 1 hour.
|
|
50
|
+
*/
|
|
51
|
+
readonly maxWaitTime?: Milliseconds;
|
|
52
|
+
/**
|
|
53
|
+
* The base exponent of the growth.
|
|
54
|
+
*
|
|
55
|
+
* Defaults to 2.
|
|
56
|
+
*/
|
|
57
|
+
readonly exponentRate?: number;
|
|
58
|
+
}
|
|
59
|
+
export type FullExponentialPromiseRateLimiterConfig = Required<ExponentialPromiseRateLimiterConfig>;
|
|
60
|
+
export interface ExponentialPromiseRateLimiter extends EnableTogglePromiseRateLimiter {
|
|
61
|
+
/**
|
|
62
|
+
* Returns the current config.
|
|
63
|
+
*/
|
|
64
|
+
getConfig(): FullExponentialPromiseRateLimiterConfig;
|
|
65
|
+
/**
|
|
66
|
+
* Updates the configuration.
|
|
67
|
+
*/
|
|
68
|
+
setConfig(config: Partial<ExponentialPromiseRateLimiterConfig>, andReset?: boolean): void;
|
|
69
|
+
/**
|
|
70
|
+
* Manually resets the limit
|
|
71
|
+
*/
|
|
72
|
+
reset(): void;
|
|
73
|
+
}
|
|
74
|
+
export declare function exponentialPromiseRateLimiter(initialConfig?: Maybe<ExponentialPromiseRateLimiterConfig>): ExponentialPromiseRateLimiter;
|
|
75
|
+
export interface ResetPeriodPromiseRateLimiterConfig extends Partial<ExponentialPromiseRateLimiterConfig> {
|
|
76
|
+
/**
|
|
77
|
+
* The number of times the rate limiter can be used before it needs to be reset.
|
|
78
|
+
*/
|
|
79
|
+
readonly limit: number;
|
|
80
|
+
/**
|
|
81
|
+
* Optional specific Date/Time at which to reset the remaining count back to the limit.
|
|
82
|
+
*/
|
|
83
|
+
readonly resetAt?: Maybe<Date>;
|
|
84
|
+
/**
|
|
85
|
+
* Amount of time in milliseconds to set the next resetAt time when reset is called.
|
|
86
|
+
*/
|
|
87
|
+
readonly resetPeriod: Milliseconds;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A rate limiter that resets every specific period of time and has a limited amount of items that can go out.
|
|
91
|
+
*/
|
|
92
|
+
export interface ResetPeriodPromiseRateLimiter extends EnableTogglePromiseRateLimiter {
|
|
93
|
+
/**
|
|
94
|
+
* Returns the current limit details with the amount remaining.
|
|
95
|
+
*/
|
|
96
|
+
getRemainingLimit(): number;
|
|
97
|
+
/**
|
|
98
|
+
* Sets the remaining limit number.
|
|
99
|
+
*
|
|
100
|
+
* @param limit
|
|
101
|
+
*/
|
|
102
|
+
setRemainingLimit(limit: number): void;
|
|
103
|
+
/**
|
|
104
|
+
* Returns the number of milliseconds until the next reset.
|
|
105
|
+
*/
|
|
106
|
+
getTimeUntilNextReset(): Milliseconds;
|
|
107
|
+
/**
|
|
108
|
+
* Returns the next reset at date/time.
|
|
109
|
+
*/
|
|
110
|
+
getResetAt(): Date;
|
|
111
|
+
/**
|
|
112
|
+
* Sets the next reset at Date.
|
|
113
|
+
*/
|
|
114
|
+
setNextResetAt(date: Date): void;
|
|
115
|
+
/**
|
|
116
|
+
* Sets the new config.
|
|
117
|
+
*
|
|
118
|
+
* @param limit
|
|
119
|
+
*/
|
|
120
|
+
setConfig(config: Partial<ResetPeriodPromiseRateLimiterConfig>, andReset?: boolean): void;
|
|
121
|
+
/**
|
|
122
|
+
* Manually resets the "remaining" amount on the limit back to the limit amount.
|
|
123
|
+
*/
|
|
124
|
+
reset(): void;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Creates a ResetPeriodPromiseRateLimiter.
|
|
128
|
+
*
|
|
129
|
+
* @param limit
|
|
130
|
+
*/
|
|
131
|
+
export declare function resetPeriodPromiseRateLimiter(initialConfig: ResetPeriodPromiseRateLimiterConfig): ResetPeriodPromiseRateLimiter;
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [11.0.14](https://github.com/dereekb/dbx-components/compare/v11.0.13-dev...v11.0.14) (2024-11-27)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [11.0.13](https://github.com/dereekb/dbx-components/compare/v11.0.12-dev...v11.0.13) (2024-11-27)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [11.0.12](https://github.com/dereekb/dbx-components/compare/v11.0.11-dev...v11.0.12) (2024-11-24)
|
|
6
14
|
|
|
7
15
|
|