@itwin/core-i18n 4.1.0-dev.56 → 4.1.0-dev.62
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/CHANGELOG.md +6 -1
- package/lib/cjs/ITwinLocalization.js.map +1 -1
- package/lib/cjs/core-i18n.js.map +1 -1
- package/lib/cjs/test/ITwinLocalization.test.js.map +1 -1
- package/lib/cjs/test/webpack/bundled-tests.instrumented.js +157 -149
- package/lib/cjs/test/webpack/bundled-tests.instrumented.js.map +1 -1
- package/lib/cjs/test/webpack/bundled-tests.js +15 -7
- package/lib/cjs/test/webpack/bundled-tests.js.map +1 -1
- package/lib/esm/ITwinLocalization.js.map +1 -1
- package/lib/esm/core-i18n.js.map +1 -1
- package/lib/esm/test/ITwinLocalization.test.js.map +1 -1
- package/package.json +6 -6
|
@@ -22038,28 +22038,36 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
22038
22038
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
22039
22039
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
22040
22040
|
*--------------------------------------------------------------------------------------------*/
|
|
22041
|
-
/** @
|
|
22041
|
+
/** @packageDocumentation
|
|
22042
|
+
* @module Utils
|
|
22043
|
+
*/
|
|
22042
22044
|
const defaultYieldManagerOptions = {
|
|
22043
22045
|
iterationsBeforeYield: 1000,
|
|
22044
22046
|
};
|
|
22045
|
-
/**
|
|
22046
|
-
*
|
|
22047
|
-
*
|
|
22048
|
-
*
|
|
22049
|
-
*
|
|
22050
|
-
*
|
|
22047
|
+
/** Provides a mechanism by which a loop can be made to periodically yield control back to the browser/node environment.
|
|
22048
|
+
* This can alleviate [performance and memory consumption issues](https://github.com/nodejs/node-addon-api/issues/1140).
|
|
22049
|
+
* It maintains a count of the number of iterations that have occurred since the last yield.
|
|
22050
|
+
* The constructor specifies how many iterations of the loop are permitted before yielding.
|
|
22051
|
+
* The loop should `await` [[allowYield]] on each iteration.
|
|
22052
|
+
* [[allowYield]] will yield (and reset the iteration counter) if the counter exceeds the specified maximum.
|
|
22053
|
+
* @public
|
|
22051
22054
|
*/
|
|
22052
22055
|
class YieldManager {
|
|
22056
|
+
/** Constructor.
|
|
22057
|
+
* @param options Options customizing the yield behavior. Omitted properties are assigned their default values.
|
|
22058
|
+
*/
|
|
22053
22059
|
constructor(options = {}) {
|
|
22054
22060
|
this._counter = 0;
|
|
22055
22061
|
this.options = { ...defaultYieldManagerOptions, ...options };
|
|
22056
22062
|
}
|
|
22063
|
+
/** Increment the iteration counter, yielding control and resetting the counter if [[options.iterationsBeforeYield]] is exceeded. */
|
|
22057
22064
|
async allowYield() {
|
|
22058
22065
|
this._counter = (this._counter + 1) % this.options.iterationsBeforeYield;
|
|
22059
22066
|
if (this._counter === 0) {
|
|
22060
22067
|
await this.actualYield();
|
|
22061
22068
|
}
|
|
22062
22069
|
}
|
|
22070
|
+
/** @internal */
|
|
22063
22071
|
async actualYield() {
|
|
22064
22072
|
await new Promise((r) => setTimeout(r, 0));
|
|
22065
22073
|
}
|