@liberation-data/drivine
Version:
Best and fastest graph database client for TypeScript / Node.js. Provides a level of abstraction for building highly scalable applications, without compromising architectural integrity
31 lines • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ObjectUtils = void 0;
const class_transformer_1 = require("class-transformer");
const neo4j_driver_1 = require("neo4j-driver");
class ObjectUtils {
}
exports.ObjectUtils = ObjectUtils;
ObjectUtils.primitiveProps = (object, options = { classToPlain: true, neo4jDateToDateTime: true }) => {
const props = {};
if (object) {
const source = options.classToPlain ? (0, class_transformer_1.instanceToPlain)(object) : object;
const strings = Object.keys(source);
strings.forEach((key) => {
const candidate = source[key];
if (candidate != undefined &&
candidate.constructor === Array &&
candidate.filter((it) => typeof it === 'object').length === 0) {
props[key] = candidate;
}
else if (candidate != undefined && candidate instanceof Date && options.neo4jDateToDateTime) {
props[key] = neo4j_driver_1.default.types.DateTime.fromStandardDate(candidate);
}
else if (candidate != undefined && typeof candidate !== 'object') {
props[key] = candidate;
}
});
}
return props;
};
//# sourceMappingURL=ObjectUtils.js.map