UNPKG

@itwin/presentation-common

Version:

Common pieces for iModel.js presentation packages

85 lines 3 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Content */ Object.defineProperty(exports, "__esModule", { value: true }); exports.DisplayValue = exports.Value = void 0; /** @public */ // eslint-disable-next-line @typescript-eslint/no-redeclare var Value; (function (Value) { /** Is the value a primitive */ function isPrimitive(value) { return isPrimitiveValue(value); } Value.isPrimitive = isPrimitive; /** Is the value an array */ function isArray(value) { return isArrayValue(value); } Value.isArray = isArray; /** Is the value a map / struct */ function isMap(value) { return isMapValue(value); } Value.isMap = isMap; /** Is the value a nested content value */ function isNestedContent(value) { return isNestedContentValue(value); } Value.isNestedContent = isNestedContent; /** Is the value a navigation value */ function isNavigationValue(value) { return (value !== undefined && value.id !== undefined && value.className !== undefined && value.label !== undefined); } Value.isNavigationValue = isNavigationValue; })(Value || (exports.Value = Value = {})); /** @public */ // eslint-disable-next-line @typescript-eslint/no-redeclare var DisplayValue; (function (DisplayValue) { /** Is the value a primitive */ function isPrimitive(value) { return isPrimitiveValue(value); } DisplayValue.isPrimitive = isPrimitive; /** Is the value an array */ function isArray(value) { return isArrayValue(value); } DisplayValue.isArray = isArray; /** Is the value a map / struct */ function isMap(value) { return isMapValue(value); } DisplayValue.isMap = isMap; })(DisplayValue || (exports.DisplayValue = DisplayValue = {})); function isNestedContentValue(v) { return (v !== undefined && Array.isArray(v) && (v.length === 0 || (!!v[0] && v[0].primaryKeys !== undefined && v[0].values !== undefined && v[0].displayValues !== undefined && v[0].mergedFieldNames !== undefined))); } function isArrayValue(v) { // note: we don't guarantee by 100% that v is ValuesArray | DisplayValuesArray, but merely make compiler happy. // we have other means to determine the type of value. return v !== undefined && Array.isArray(v); } function isMapValue(v) { return v !== undefined && typeof v === "object" && !Array.isArray(v); } function isPrimitiveValue(v) { return !isArrayValue(v) && !isMapValue(v); } //# sourceMappingURL=Value.js.map