@itwin/core-backend
Version:
iTwin.js backend components
86 lines • 3.57 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Workspace
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SettingsPriority = exports.Setting = void 0;
const Symbols_1 = require("../internal/Symbols");
/** @beta */
var Setting;
(function (Setting) {
/** Create a deep copy of a [[Setting]]. */
function clone(setting) {
if (!setting || typeof setting !== "object")
return setting;
const result = Array.isArray(setting) ? [] : {};
Object.keys(setting).forEach((key) => result[key] = clone(setting[key]));
return result;
}
Setting.clone = clone;
/** Returns true if `a` and `b` are considered equivalent [[Setting]] values.
* Settings of primitive types like `number` and `string` are compared using `===`.
* Settings of type "object" are compared by comparing each property using `areEqual`; the objects are considered
* equal if they have the exact same set of property names with equivalent values.
* Settings of type "array" are compared by comparing each element of the arrays use `areEqual`; the arrays are considered
* equal if they have the same number of elements with equivalent values in the same exact order.
*/
function areEqual(a, b) {
if (a === b) {
return true;
}
// For primitive types, === suffices.
if (typeof a !== "object" || typeof b !== "object") {
return false;
}
if (Array.isArray(a) || Array.isArray(b)) {
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (!areEqual(a[i], b[i])) {
return false;
}
}
return true;
}
const aKeys = Object.keys(a);
const bKeys = Object.keys(b);
if (aKeys.length !== bKeys.length) {
return false;
}
aKeys.sort();
bKeys.sort();
for (let i = 0; i < aKeys.length; i++) {
const key = aKeys[i];
if (key !== bKeys[i]) {
return false;
}
if (!areEqual(a[key], b[key])) {
return false;
}
}
return true;
}
Setting.areEqual = areEqual;
})(Setting || (exports.Setting = Setting = {}));
/** @beta */
var SettingsPriority;
(function (SettingsPriority) {
/** Settings that originate from default setting files loaded automatically at the start of a session. */
SettingsPriority.defaults = 100;
/** Settings supplied by an application at runtime. */
SettingsPriority.application = 200;
/** Settings that apply to all iTwins for an organization. */
SettingsPriority.organization = 300;
/** Settings that apply to all iModels in an iTwin. */
SettingsPriority.iTwin = 400;
/** Settings that apply to all branches of an iModel. */
SettingsPriority.branch = 500;
/** Settings that apply to a specific iModel. */
SettingsPriority.iModel = 600;
})(SettingsPriority || (exports.SettingsPriority = SettingsPriority = {}));
//# sourceMappingURL=Settings.js.map