UNPKG

@hashgraph/solo

Version:

An opinionated CLI tool to deploy and manage private Hedera Networks.

71 lines 2.54 kB
// SPDX-License-Identifier: Apache-2.0 import { UnsupportedOperationError } from '../errors/unsupported-operation-error.js'; export class ReflectAssist { constructor() { throw new UnsupportedOperationError('utility classes and cannot be instantiated'); } /** * TypeScript custom type guard that checks if the provided object implements Refreshable. * * @param v - The object to check. * @returns true if the object implements Refreshable, false otherwise. * @private */ static isRefreshable(v) { return typeof v === 'object' && !!v && 'refresh' in v; } /** * TypeScript custom type guard that checks if the provided object implements Persistable. * * @param v - The object to check. * @returns true if the object implements Persistable, false otherwise. * @private */ static isPersistable(v) { return typeof v === 'object' && !!v && 'persist' in v; } /** * TypeScript custom type guard that checks if the provided object implements ObjectStorageBackend. * * @param v - The object to check. * @returns true if the object implements ObjectStorageBackend, false otherwise. * @private */ static isObjectStorageBackend(v) { return typeof v === 'object' && !!v && 'readObject' in v; } static coerce(v) { try { return JSON.parse(v); } catch { return v; } } /** * Creates a clone of the firstObject of type T and merges the properties of the secondObject into it. If either * object is falsy, then the other object is returned. * @returns The merged object of type T. * @param firstObject * @param secondObject */ static merge(firstObject, secondObject) { if (!firstObject) { return secondObject; } if (!secondObject) { return firstObject; } const mergedObject = structuredClone(firstObject); for (const key in secondObject) { if (secondObject.hasOwnProperty(key) && secondObject[key] !== null && secondObject[key] !== undefined) { mergedObject[key] = typeof secondObject[key] === 'object' && !Array.isArray(secondObject[key]) ? ReflectAssist.merge(mergedObject[key], secondObject[key]) : secondObject[key]; } } return mergedObject; } } //# sourceMappingURL=reflect-assist.js.map