UNPKG

1.06 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6const fill_1 = __importDefault(require("lodash/fill"));
7const flatten_1 = __importDefault(require("lodash/flatten"));
8const get_1 = __importDefault(require("lodash/get"));
9const zip_1 = __importDefault(require("lodash/zip"));
10exports.fieldPathToSchemaPath = (fieldPath) => {
11 let newPath = zip_1.default(fill_1.default(fieldPath.split('.'), 'properties'), fieldPath.split('.'));
12 return flatten_1.default(newPath).join('.');
13};
14// Assumption: used only for jsonPointer returned from traverse
15exports.schemaPointerToFieldPath = (jsonPointer) => {
16 return jsonPointer
17 .split('/')
18 .slice(2)
19 .filter(e => e !== 'properties')
20 .join('.');
21};
22exports.fieldPathToSchema = (schema, fieldPath) => {
23 return get_1.default(schema, exports.fieldPathToSchemaPath(fieldPath));
24};
25//# sourceMappingURL=Util.js.map
\No newline at end of file