@intelligo.ai/object-to-schema
Advanced tools
Comparing version 1.5.4 to 1.5.5
@@ -9,2 +9,3 @@ "use strict"; | ||
var transform_1 = require("./utils/transform"); | ||
var _ = require("lodash"); | ||
function mapObjectToSchema(obj, schema) { | ||
@@ -16,3 +17,3 @@ if (schema === void 0) { schema = {}; } | ||
return Object | ||
.keys(obj) | ||
.keys(pruneEmpty(obj)) | ||
.reduce(function (schema, key) { return resolveOperation(schema, obj, key); }, schema); | ||
@@ -37,2 +38,16 @@ } | ||
} | ||
function pruneEmpty(obj) { | ||
return function prune(current) { | ||
_.forOwn(current, function (value, key) { | ||
if (_.isUndefined(value) || _.isNull(value) || _.isNaN(value) || | ||
(_.isString(value) && _.isEmpty(value)) || | ||
(_.isObject(value) && _.isEmpty(prune(value)))) { | ||
delete current[key]; | ||
} | ||
}); | ||
if (_.isArray(current)) | ||
_.pull(current, undefined); | ||
return current; | ||
}(_.cloneDeep(obj)); | ||
} | ||
function handleEmptyValue(schema, key) { | ||
@@ -39,0 +54,0 @@ var value = schema[key]; |
{ | ||
"name": "@intelligo.ai/object-to-schema", | ||
"version": "1.5.4", | ||
"version": "1.5.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
331022
6444