GT2/GT2-Android/node_modules/@expo/schemer/build/Util.js

29 lines
1.1 KiB
JavaScript
Raw Normal View History

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fieldPathToSchema = exports.schemaPointerToFieldPath = exports.fieldPathToSchemaPath = undefined;
var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var fieldPathToSchemaPath = exports.fieldPathToSchemaPath = function fieldPathToSchemaPath(fieldPath) {
var newPath = _lodash2.default.zip(_lodash2.default.fill(fieldPath.split('.'), 'properties'), fieldPath.split('.'));
return _lodash2.default.flatten(newPath).join('.');
};
// Assumption: used only for jsonPointer returned from traverse
var schemaPointerToFieldPath = exports.schemaPointerToFieldPath = function schemaPointerToFieldPath(jsonPointer) {
return jsonPointer.split('/').slice(2).filter(function (e) {
return e !== 'properties';
}).join('.');
};
var fieldPathToSchema = exports.fieldPathToSchema = function fieldPathToSchema(schema, fieldPath) {
return _lodash2.default.get(schema, fieldPathToSchemaPath(fieldPath));
};