@dereekb/util 11.0.11 → 11.0.13

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.
@@ -4922,7 +4922,7 @@ function fetchTimeout(inputFetch) {
4922
4922
  * @returns
4923
4923
  */
4924
4924
 
4925
- function _await$2(value, then, direct) {
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
- * Creates a function that wraps fetch and uses a FetchRequestFactory to generate a Request before invoking Fetch.
4935
- *
4936
- * @param config
4934
+ * Default FetchHabdler
4935
+ * @param request
4936
+ * @param makeFetch
4937
4937
  * @returns
4938
4938
  */
4939
4939
 
4940
- function _async$2(f) {
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$2(function (input, init) {
5026
- return _await$2(makeFetchRequest(input, init), function (request) {
5027
- let response = makeFetch(request);
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$2(function (input) {
5052
+ const asFetchRequest = _async$3(function (input) {
5037
5053
  const _isPromiseLike = util.isPromiseLike(input);
5038
- return _await$2(input, function (awaitedInput) {
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 = (input, init) => new Request(input, init),
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$2(function (input) {
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$2(makeRequest(input), function (_makeRequest) {
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$2(makeRequest(url.href, baseRequest), function (_makeRequest2) {
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$2(requestInit, function (_requestInit) {
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$2(function (input, init) {
5128
- return _catch(function () {
5129
- return _await$2(buildRequestWithFixedUrl(input), function (fixedRequest) {
5130
- return _await$2(buildRequestInit(fixedRequest, init), function (_buildRequestInit) {
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$2(makeRequest(fixedRequest, init), function (request) {
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
- const nodeFetchService = fetchService({
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;
@@ -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 = makeFetch(request);
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 = (input, init) => new Request(input, init),
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
- const nodeFetchService = fetchService({
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
- export { FETCH_PAGE_FACTORY_DEFAULT_MAX_PAGE, FetchPageLimitReachedError, FetchPageNoNextPageError, FetchRequestFactoryError, FetchResponseError, FetchTimeoutError, JsonResponseParseError, configureFetch, fetchJsonBodyString, fetchJsonFunction, fetchJsonRequestInit, fetchJsonRequestInitFunction, fetchOk, fetchPageFactory, fetchRequestFactory, fetchService, fetchTimeout, fetchURL, fetchURLQueryKeyValueStringTuples, fetchURLSearchParamsObjectToURLSearchParams, headersToHeadersTuple, isFetchRequest, isURL, isURLSearchParams, iterateFetchPages, iterateFetchPagesByEachItem, iterateFetchPagesByItems, makeUrlSearchParams, mergeRequestHeaders, mergeRequestInits, nodeFetchService, queryParamsToSearchParams, requireOkResponse, returnNullHandleFetchJsonParseErrorFunction, throwJsonResponseParseErrorFunction };
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 };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util/fetch",
3
- "version": "11.0.11",
3
+ "version": "11.0.13",
4
4
  ".": {
5
5
  "types": "./src/index.d.ts",
6
6
  "node": {
@@ -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>;
@@ -1,5 +1,6 @@
1
1
  export * from './error';
2
2
  export * from './fetch';
3
+ export * from './fetch.limit';
3
4
  export * from './fetch.type';
4
5
  export * from './fetch.page';
5
6
  export * from './fetch.page.iterate';
@@ -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,195 @@ function performTasksFromFactoryInParallelFunction(config) {
13747
13761
  };
13748
13762
  }
13749
13763
 
13764
+ function exponentialPromiseRateLimiter(initialConfig) {
13765
+ const DEFAULT_COOLDOWN_RATE = 1;
13766
+ const DEFAULT_EXPONENT_RATE = 2;
13767
+ const DEFAULT_MAX_WAIT_TIME = MS_IN_HOUR;
13768
+ let config = {
13769
+ cooldownRate: DEFAULT_COOLDOWN_RATE,
13770
+ exponentRate: DEFAULT_EXPONENT_RATE,
13771
+ maxWaitTime: DEFAULT_MAX_WAIT_TIME
13772
+ };
13773
+ let currentCount = 0;
13774
+ let countForMaxWaitTime = Number.MAX_SAFE_INTEGER;
13775
+ let timeOfLastExecution = new Date();
13776
+ let enabled = true;
13777
+ setConfig(initialConfig != null ? initialConfig : config);
13778
+ function getConfig() {
13779
+ return Object.assign({}, config);
13780
+ }
13781
+ function getEnabled() {
13782
+ return enabled;
13783
+ }
13784
+ function setEnabled(nextEnabled) {
13785
+ enabled = nextEnabled;
13786
+ }
13787
+ function setConfig(newConfig, andReset = false) {
13788
+ var _newConfig$cooldownRa, _newConfig$maxWaitTim, _newConfig$exponentRa;
13789
+ const cooldownRate = (_newConfig$cooldownRa = newConfig.cooldownRate) != null ? _newConfig$cooldownRa : DEFAULT_COOLDOWN_RATE;
13790
+ const maxWaitTime = (_newConfig$maxWaitTim = newConfig.maxWaitTime) != null ? _newConfig$maxWaitTim : DEFAULT_MAX_WAIT_TIME;
13791
+ const exponentRate = (_newConfig$exponentRa = newConfig.exponentRate) != null ? _newConfig$exponentRa : DEFAULT_EXPONENT_RATE;
13792
+ config = {
13793
+ cooldownRate,
13794
+ maxWaitTime,
13795
+ exponentRate
13796
+ };
13797
+ // calculate max count for max wait time to use for determining rounding of nextWaitTime
13798
+ countForMaxWaitTime = getBaseLog(exponentRate, maxWaitTime / MS_IN_SECOND + 1);
13799
+ if (andReset) {
13800
+ reset();
13801
+ }
13802
+ }
13803
+ function reset() {
13804
+ currentCount = 0;
13805
+ timeOfLastExecution = new Date();
13806
+ }
13807
+ function _nextWaitTime(increasedExecutions) {
13808
+ if (!enabled) {
13809
+ return 0;
13810
+ }
13811
+ const {
13812
+ cooldownRate
13813
+ } = config;
13814
+ const msSinceLastExecution = Date.now() - timeOfLastExecution.getTime();
13815
+ const cooldown = msSinceLastExecution * cooldownRate / MS_IN_SECOND; // the cooldown amount
13816
+ const count = Math.max(currentCount - cooldown, 0);
13817
+ if (increasedExecutions) {
13818
+ currentCount = count + increasedExecutions;
13819
+ timeOfLastExecution = new Date();
13820
+ }
13821
+ if (count >= countForMaxWaitTime) {
13822
+ return config.maxWaitTime;
13823
+ } else {
13824
+ return count === 0 ? 0 : Math.pow(config.exponentRate, Math.max(count - 1, 0)) * MS_IN_SECOND;
13825
+ }
13826
+ }
13827
+ function getNextWaitTime(increase) {
13828
+ return _nextWaitTime(increase != null ? increase : 0);
13829
+ }
13830
+ function waitForRateLimit() {
13831
+ const waitTime = _nextWaitTime(1);
13832
+ return waitForMs(waitTime);
13833
+ }
13834
+ return {
13835
+ waitForRateLimit,
13836
+ getNextWaitTime,
13837
+ getConfig,
13838
+ setConfig,
13839
+ getEnabled,
13840
+ setEnabled,
13841
+ reset
13842
+ };
13843
+ }
13844
+ /**
13845
+ * Creates a ResetPeriodPromiseRateLimiter.
13846
+ *
13847
+ * @param limit
13848
+ */
13849
+ function resetPeriodPromiseRateLimiter(initialConfig) {
13850
+ const DEFAULT_EXPONENT_RATE = 1.5;
13851
+ const exponentialLimiter = exponentialPromiseRateLimiter(Object.assign({
13852
+ exponentRate: DEFAULT_EXPONENT_RATE,
13853
+ maxWaitTime: MS_IN_SECOND * 8
13854
+ }, initialConfig));
13855
+ let resetPeriod = MS_IN_MINUTE;
13856
+ let nextResetAt = new Date();
13857
+ let limit = 0;
13858
+ let remaining = 0;
13859
+ let enabled = true;
13860
+ setConfig(initialConfig, true);
13861
+ function _checkRemainingReset() {
13862
+ if (nextResetAt && isPast(nextResetAt)) {
13863
+ reset();
13864
+ }
13865
+ }
13866
+ function getEnabled() {
13867
+ return enabled;
13868
+ }
13869
+ function setEnabled(nextEnabled) {
13870
+ enabled = nextEnabled;
13871
+ }
13872
+ function reset() {
13873
+ remaining = limit;
13874
+ nextResetAt = new Date(Date.now() + resetPeriod);
13875
+ // do not reset the exponential limiter
13876
+ }
13877
+
13878
+ function getResetAt() {
13879
+ return nextResetAt;
13880
+ }
13881
+ function getTimeUntilNextReset() {
13882
+ return Math.max(0, nextResetAt.getTime() - Date.now());
13883
+ }
13884
+ function setNextResetAt(date) {
13885
+ nextResetAt = date;
13886
+ }
13887
+ function getRemainingLimit() {
13888
+ _checkRemainingReset();
13889
+ return remaining;
13890
+ }
13891
+ function setRemainingLimit(nextRemaining) {
13892
+ remaining = nextRemaining;
13893
+ }
13894
+ function setConfig(config, andReset = false) {
13895
+ var _config$limit, _config$resetPeriod, _config$cooldownRate, _config$exponentRate, _config$maxWaitTime, _config$resetAt;
13896
+ limit = (_config$limit = config.limit) != null ? _config$limit : limit;
13897
+ resetPeriod = (_config$resetPeriod = config.resetPeriod) != null ? _config$resetPeriod : resetPeriod;
13898
+ const exponentialLimiterConfig = {
13899
+ cooldownRate: (_config$cooldownRate = config.cooldownRate) != null ? _config$cooldownRate : Math.max(0.1, resetPeriod / MS_IN_SECOND),
13900
+ exponentRate: (_config$exponentRate = config.exponentRate) != null ? _config$exponentRate : DEFAULT_EXPONENT_RATE,
13901
+ maxWaitTime: (_config$maxWaitTime = config.maxWaitTime) != null ? _config$maxWaitTime : MS_IN_SECOND * 8
13902
+ };
13903
+ exponentialLimiter.setConfig(exponentialLimiterConfig, andReset);
13904
+ if (andReset) {
13905
+ reset();
13906
+ }
13907
+ nextResetAt = (_config$resetAt = config.resetAt) != null ? _config$resetAt : nextResetAt;
13908
+ }
13909
+ function _nextWaitTime(increasedExecutions) {
13910
+ if (!enabled) {
13911
+ return 0;
13912
+ }
13913
+ function computeNextWaitTime() {
13914
+ remaining -= increasedExecutions;
13915
+ return exponentialLimiter.getNextWaitTime(increasedExecutions);
13916
+ }
13917
+ let waitTime = 0;
13918
+ if (remaining > 0) {
13919
+ waitTime = computeNextWaitTime();
13920
+ } else {
13921
+ // if none remaining, try and reset
13922
+ _checkRemainingReset();
13923
+ if (remaining > 0) {
13924
+ waitTime = computeNextWaitTime();
13925
+ } else {
13926
+ waitTime = getTimeUntilNextReset();
13927
+ }
13928
+ }
13929
+ return waitTime;
13930
+ }
13931
+ function getNextWaitTime(increase) {
13932
+ return _nextWaitTime(increase != null ? increase : 0);
13933
+ }
13934
+ function waitForRateLimit() {
13935
+ const waitTime = _nextWaitTime(1);
13936
+ return waitForMs(waitTime);
13937
+ }
13938
+ return {
13939
+ getRemainingLimit,
13940
+ setRemainingLimit,
13941
+ getTimeUntilNextReset,
13942
+ getResetAt,
13943
+ setNextResetAt,
13944
+ setConfig,
13945
+ reset,
13946
+ getNextWaitTime,
13947
+ waitForRateLimit,
13948
+ getEnabled,
13949
+ setEnabled
13950
+ };
13951
+ }
13952
+
13750
13953
  function _await$1(value, then, direct) {
13751
13954
  if (direct) {
13752
13955
  return then ? then(value) : value;
@@ -16168,6 +16371,7 @@ exports.expandFlattenTreeFunction = expandFlattenTreeFunction;
16168
16371
  exports.expandIndexSet = expandIndexSet;
16169
16372
  exports.expandTreeFunction = expandTreeFunction;
16170
16373
  exports.expandTrees = expandTrees;
16374
+ exports.exponentialPromiseRateLimiter = exponentialPromiseRateLimiter;
16171
16375
  exports.extendLatLngBound = extendLatLngBound;
16172
16376
  exports.filterAndMapFunction = filterAndMapFunction;
16173
16377
  exports.filterEmptyValues = filterEmptyValues;
@@ -16237,6 +16441,7 @@ exports.forwardFunction = forwardFunction;
16237
16441
  exports.fractionalHoursToMinutes = fractionalHoursToMinutes;
16238
16442
  exports.generateIfDoesNotExist = generateIfDoesNotExist;
16239
16443
  exports.getArrayNextIndex = getArrayNextIndex;
16444
+ exports.getBaseLog = getBaseLog;
16240
16445
  exports.getDayOffset = getDayOffset;
16241
16446
  exports.getDayTomorrow = getDayTomorrow;
16242
16447
  exports.getDayYesterday = getDayYesterday;
@@ -16605,6 +16810,7 @@ exports.replaceLastCharacterIfIsFunction = replaceLastCharacterIfIsFunction;
16605
16810
  exports.replaceMultipleFilePathsInSlashPath = replaceMultipleFilePathsInSlashPath;
16606
16811
  exports.replaceStringsFunction = replaceStringsFunction;
16607
16812
  exports.requireModelKey = requireModelKey;
16813
+ exports.resetPeriodPromiseRateLimiter = resetPeriodPromiseRateLimiter;
16608
16814
  exports.restoreOrder = restoreOrder;
16609
16815
  exports.restoreOrderWithValues = restoreOrderWithValues;
16610
16816
  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,213 @@ 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_COOLDOWN_RATE = 1;
15302
+ const DEFAULT_EXPONENT_RATE = 2;
15303
+ const DEFAULT_MAX_WAIT_TIME = MS_IN_HOUR;
15304
+ let config = {
15305
+ cooldownRate: DEFAULT_COOLDOWN_RATE,
15306
+ exponentRate: DEFAULT_EXPONENT_RATE,
15307
+ maxWaitTime: DEFAULT_MAX_WAIT_TIME
15308
+ };
15309
+ let currentCount = 0;
15310
+ let countForMaxWaitTime = Number.MAX_SAFE_INTEGER;
15311
+ let timeOfLastExecution = new Date();
15312
+ let enabled = true;
15313
+ setConfig(initialConfig != null ? initialConfig : config);
15314
+ function getConfig() {
15315
+ return Object.assign({}, config);
15316
+ }
15317
+ function getEnabled() {
15318
+ return enabled;
15319
+ }
15320
+ function setEnabled(nextEnabled) {
15321
+ enabled = nextEnabled;
15322
+ }
15323
+ function setConfig(newConfig, andReset = false) {
15324
+ var _newConfig$cooldownRa, _newConfig$maxWaitTim, _newConfig$exponentRa;
15325
+ const cooldownRate = (_newConfig$cooldownRa = newConfig.cooldownRate) != null ? _newConfig$cooldownRa : DEFAULT_COOLDOWN_RATE;
15326
+ const maxWaitTime = (_newConfig$maxWaitTim = newConfig.maxWaitTime) != null ? _newConfig$maxWaitTim : DEFAULT_MAX_WAIT_TIME;
15327
+ const exponentRate = (_newConfig$exponentRa = newConfig.exponentRate) != null ? _newConfig$exponentRa : DEFAULT_EXPONENT_RATE;
15328
+ config = {
15329
+ cooldownRate,
15330
+ maxWaitTime,
15331
+ exponentRate
15332
+ };
15333
+
15334
+ // calculate max count for max wait time to use for determining rounding of nextWaitTime
15335
+ countForMaxWaitTime = getBaseLog(exponentRate, maxWaitTime / MS_IN_SECOND + 1);
15336
+ if (andReset) {
15337
+ reset();
15338
+ }
15339
+ }
15340
+ function reset() {
15341
+ currentCount = 0;
15342
+ timeOfLastExecution = new Date();
15343
+ }
15344
+ function _nextWaitTime(increasedExecutions) {
15345
+ if (!enabled) {
15346
+ return 0;
15347
+ }
15348
+ const {
15349
+ cooldownRate
15350
+ } = config;
15351
+ const msSinceLastExecution = Date.now() - timeOfLastExecution.getTime();
15352
+ const cooldown = msSinceLastExecution * cooldownRate / MS_IN_SECOND; // the cooldown amount
15353
+ const count = Math.max(currentCount - cooldown, 0);
15354
+ if (increasedExecutions) {
15355
+ currentCount = count + increasedExecutions;
15356
+ timeOfLastExecution = new Date();
15357
+ }
15358
+ if (count >= countForMaxWaitTime) {
15359
+ return config.maxWaitTime;
15360
+ } else {
15361
+ return count === 0 ? 0 : Math.pow(config.exponentRate, Math.max(count - 1, 0)) * MS_IN_SECOND;
15362
+ }
15363
+ }
15364
+ function getNextWaitTime(increase) {
15365
+ return _nextWaitTime(increase != null ? increase : 0);
15366
+ }
15367
+ function waitForRateLimit() {
15368
+ const waitTime = _nextWaitTime(1);
15369
+ return waitForMs(waitTime);
15370
+ }
15371
+ return {
15372
+ waitForRateLimit,
15373
+ getNextWaitTime,
15374
+ getConfig,
15375
+ setConfig,
15376
+ getEnabled,
15377
+ setEnabled,
15378
+ reset
15379
+ };
15380
+ }
15381
+
15382
+ // MARK: Count Down limiter
15383
+
15384
+ /**
15385
+ * A rate limiter that resets every specific period of time and has a limited amount of items that can go out.
15386
+ */
15387
+
15388
+ /**
15389
+ * Creates a ResetPeriodPromiseRateLimiter.
15390
+ *
15391
+ * @param limit
15392
+ */
15393
+ function resetPeriodPromiseRateLimiter(initialConfig) {
15394
+ const DEFAULT_EXPONENT_RATE = 1.5;
15395
+ const exponentialLimiter = exponentialPromiseRateLimiter(Object.assign({
15396
+ exponentRate: DEFAULT_EXPONENT_RATE,
15397
+ maxWaitTime: MS_IN_SECOND * 8
15398
+ }, initialConfig));
15399
+ let resetPeriod = MS_IN_MINUTE;
15400
+ let nextResetAt = new Date();
15401
+ let limit = 0;
15402
+ let remaining = 0;
15403
+ let enabled = true;
15404
+ setConfig(initialConfig, true);
15405
+ function _checkRemainingReset() {
15406
+ if (nextResetAt && isPast(nextResetAt)) {
15407
+ reset();
15408
+ }
15409
+ }
15410
+ function getEnabled() {
15411
+ return enabled;
15412
+ }
15413
+ function setEnabled(nextEnabled) {
15414
+ enabled = nextEnabled;
15415
+ }
15416
+ function reset() {
15417
+ remaining = limit;
15418
+ nextResetAt = new Date(Date.now() + resetPeriod);
15419
+ // do not reset the exponential limiter
15420
+ }
15421
+
15422
+ function getResetAt() {
15423
+ return nextResetAt;
15424
+ }
15425
+ function getTimeUntilNextReset() {
15426
+ return Math.max(0, nextResetAt.getTime() - Date.now());
15427
+ }
15428
+ function setNextResetAt(date) {
15429
+ nextResetAt = date;
15430
+ }
15431
+ function getRemainingLimit() {
15432
+ _checkRemainingReset();
15433
+ return remaining;
15434
+ }
15435
+ function setRemainingLimit(nextRemaining) {
15436
+ remaining = nextRemaining;
15437
+ }
15438
+ function setConfig(config, andReset = false) {
15439
+ var _config$limit, _config$resetPeriod, _config$cooldownRate, _config$exponentRate, _config$maxWaitTime, _config$resetAt;
15440
+ limit = (_config$limit = config.limit) != null ? _config$limit : limit;
15441
+ resetPeriod = (_config$resetPeriod = config.resetPeriod) != null ? _config$resetPeriod : resetPeriod;
15442
+ const exponentialLimiterConfig = {
15443
+ cooldownRate: (_config$cooldownRate = config.cooldownRate) != null ? _config$cooldownRate : Math.max(0.1, resetPeriod / MS_IN_SECOND),
15444
+ exponentRate: (_config$exponentRate = config.exponentRate) != null ? _config$exponentRate : DEFAULT_EXPONENT_RATE,
15445
+ maxWaitTime: (_config$maxWaitTime = config.maxWaitTime) != null ? _config$maxWaitTime : MS_IN_SECOND * 8
15446
+ };
15447
+ exponentialLimiter.setConfig(exponentialLimiterConfig, andReset);
15448
+ if (andReset) {
15449
+ reset();
15450
+ }
15451
+ nextResetAt = (_config$resetAt = config.resetAt) != null ? _config$resetAt : nextResetAt;
15452
+ }
15453
+ function _nextWaitTime(increasedExecutions) {
15454
+ if (!enabled) {
15455
+ return 0;
15456
+ }
15457
+ function computeNextWaitTime() {
15458
+ remaining -= increasedExecutions;
15459
+ return exponentialLimiter.getNextWaitTime(increasedExecutions);
15460
+ }
15461
+ let waitTime = 0;
15462
+ if (remaining > 0) {
15463
+ waitTime = computeNextWaitTime();
15464
+ } else {
15465
+ // if none remaining, try and reset
15466
+ _checkRemainingReset();
15467
+ if (remaining > 0) {
15468
+ waitTime = computeNextWaitTime();
15469
+ } else {
15470
+ waitTime = getTimeUntilNextReset();
15471
+ }
15472
+ }
15473
+ return waitTime;
15474
+ }
15475
+ function getNextWaitTime(increase) {
15476
+ return _nextWaitTime(increase != null ? increase : 0);
15477
+ }
15478
+ function waitForRateLimit() {
15479
+ const waitTime = _nextWaitTime(1);
15480
+ return waitForMs(waitTime);
15481
+ }
15482
+ return {
15483
+ getRemainingLimit,
15484
+ setRemainingLimit,
15485
+ getTimeUntilNextReset,
15486
+ getResetAt,
15487
+ setNextResetAt,
15488
+ setConfig,
15489
+ reset,
15490
+ getNextWaitTime,
15491
+ waitForRateLimit,
15492
+ getEnabled,
15493
+ setEnabled
15494
+ };
15495
+ }
15496
+
15275
15497
  /**
15276
15498
  * Function that uses an array of Factories to produce Promises, one after the other, to attempt to return the value.
15277
15499
  *
@@ -17157,4 +17379,4 @@ async function iterateFilteredPages(inputPage, loadFn, iterFn) {
17157
17379
  return count;
17158
17380
  }
17159
17381
 
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 };
17382
+ 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util",
3
- "version": "11.0.11",
3
+ "version": "11.0.13",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./src/index.d.ts",
@@ -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;
@@ -3,6 +3,7 @@ export * from './is';
3
3
  export * from './poll';
4
4
  export * from './map';
5
5
  export * from './promise';
6
+ export * from './promise.limit';
6
7
  export * from './promise.loop';
7
8
  export * from './promise.ref';
8
9
  export * from './promise.factory';
@@ -0,0 +1,125 @@
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
+ * How fast the cooldown occurs.
36
+ *
37
+ * Defaults to 1.
38
+ */
39
+ readonly cooldownRate?: number;
40
+ /**
41
+ * The maximum amount of wait time to limit exponential requests to, if applicable.
42
+ *
43
+ * Defaults to 1 hour.
44
+ */
45
+ readonly maxWaitTime?: Milliseconds;
46
+ /**
47
+ * The base exponent of the growth.
48
+ *
49
+ * Defaults to 2.
50
+ */
51
+ readonly exponentRate?: number;
52
+ }
53
+ export type FullExponentialPromiseRateLimiterConfig = Required<ExponentialPromiseRateLimiterConfig>;
54
+ export interface ExponentialPromiseRateLimiter extends EnableTogglePromiseRateLimiter {
55
+ /**
56
+ * Returns the current config.
57
+ */
58
+ getConfig(): FullExponentialPromiseRateLimiterConfig;
59
+ /**
60
+ * Updates the configuration.
61
+ */
62
+ setConfig(config: Partial<ExponentialPromiseRateLimiterConfig>, andReset?: boolean): void;
63
+ /**
64
+ * Manually resets the limit
65
+ */
66
+ reset(): void;
67
+ }
68
+ export declare function exponentialPromiseRateLimiter(initialConfig?: Maybe<ExponentialPromiseRateLimiterConfig>): ExponentialPromiseRateLimiter;
69
+ export interface ResetPeriodPromiseRateLimiterConfig extends Partial<ExponentialPromiseRateLimiterConfig> {
70
+ /**
71
+ * The number of times the rate limiter can be used before it needs to be reset.
72
+ */
73
+ readonly limit: number;
74
+ /**
75
+ * Optional specific Date/Time at which to reset the remaining count back to the limit.
76
+ */
77
+ readonly resetAt?: Maybe<Date>;
78
+ /**
79
+ * Amount of time in milliseconds to set the next resetAt time when reset is called.
80
+ */
81
+ readonly resetPeriod: Milliseconds;
82
+ }
83
+ /**
84
+ * A rate limiter that resets every specific period of time and has a limited amount of items that can go out.
85
+ */
86
+ export interface ResetPeriodPromiseRateLimiter extends EnableTogglePromiseRateLimiter {
87
+ /**
88
+ * Returns the current limit details with the amount remaining.
89
+ */
90
+ getRemainingLimit(): number;
91
+ /**
92
+ * Sets the remaining limit number.
93
+ *
94
+ * @param limit
95
+ */
96
+ setRemainingLimit(limit: number): void;
97
+ /**
98
+ * Returns the number of milliseconds until the next reset.
99
+ */
100
+ getTimeUntilNextReset(): Milliseconds;
101
+ /**
102
+ * Returns the next reset at date/time.
103
+ */
104
+ getResetAt(): Date;
105
+ /**
106
+ * Sets the next reset at Date.
107
+ */
108
+ setNextResetAt(date: Date): void;
109
+ /**
110
+ * Sets the new config.
111
+ *
112
+ * @param limit
113
+ */
114
+ setConfig(config: Partial<ResetPeriodPromiseRateLimiterConfig>, andReset?: boolean): void;
115
+ /**
116
+ * Manually resets the "remaining" amount on the limit back to the limit amount.
117
+ */
118
+ reset(): void;
119
+ }
120
+ /**
121
+ * Creates a ResetPeriodPromiseRateLimiter.
122
+ *
123
+ * @param limit
124
+ */
125
+ export declare function resetPeriodPromiseRateLimiter(initialConfig: ResetPeriodPromiseRateLimiterConfig): ResetPeriodPromiseRateLimiter;
package/test/CHANGELOG.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
- ## [11.0.11](https://github.com/dereekb/dbx-components/compare/v11.0.10-dev...v11.0.11) (2024-11-24)
5
+ ## [11.0.13](https://github.com/dereekb/dbx-components/compare/v11.0.12-dev...v11.0.13) (2024-11-27)
6
+
7
+
8
+
9
+ ## [11.0.12](https://github.com/dereekb/dbx-components/compare/v11.0.11-dev...v11.0.12) (2024-11-24)
6
10
 
7
11
 
8
12
 
package/test/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util/test",
3
- "version": "11.0.11",
3
+ "version": "11.0.13",
4
4
  "type": "commonjs",
5
5
  "peerDependencies": {
6
6
  "@dereekb/util": "*"