@sinclair/typebox
Version:
Json Schema Type Builder with Static Type Resolution for TypeScript
22 lines (21 loc) • 786 B
JavaScript
import { MappedResult } from '../mapped/index.mjs';
import { IndexPropertyKeys } from './indexed-property-keys.mjs';
import { Index } from './index.mjs';
// prettier-ignore
function FromProperties(type, properties, options) {
const result = {};
for (const K2 of Object.getOwnPropertyNames(properties)) {
const keys = IndexPropertyKeys(properties[K2]);
result[K2] = Index(type, keys, options);
}
return result;
}
// prettier-ignore
function FromMappedResult(type, mappedResult, options) {
return FromProperties(type, mappedResult.properties, options);
}
// prettier-ignore
export function IndexFromMappedResult(type, mappedResult, options) {
const properties = FromMappedResult(type, mappedResult, options);
return MappedResult(properties);
}