UNPKG

@rxap/json-schema-to-typescript

Version:

Generate TypeScript interfaces from JSON Schema definitions. It allows you to programmatically create and manipulate TypeScript interface definitions based on JSON schema inputs. The package provides utilities to convert JSON schema to TypeScript interfac

22 lines 754 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFromObject = getFromObject; const has_index_signature_1 = require("./has-index-signature"); function getFromObject(obj, path, defaultValue) { const fragments = path.split('.').filter(Boolean); if (fragments.length === 0) { return obj; } if (!obj) { return defaultValue; } if (typeof obj !== 'object') { return defaultValue; } const fragment = fragments.shift(); if ((0, has_index_signature_1.hasIndexSignature)(obj) && obj[fragment] !== undefined) { return getFromObject(obj[fragment], fragments.join('.'), defaultValue); } return defaultValue; } //# sourceMappingURL=get-from-object.js.map