Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Pollak committed Sep 18, 2019
1 parent c8b5871 commit cb93eff
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/core/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,22 @@ export function serializeWithSchema(schema, obj) {
export function serializeStarProps(schema, propDef, obj, target) {
checkStarSchemaInvariant(propDef)
for (var key in obj) if (obj.hasOwnProperty(key)) if (!(key in schema.props)) {
let onlyPrimitives = propDef === true
let pattern = !onlyPrimitives && propDef.pattern
let matchesPattern = pattern && pattern.test(key)
if (onlyPrimitives || matchesPattern) {
var value = obj[key]
if (onlyPrimitives) {
if (isPrimitive(value)) {
target[key] = value
}
} else {
var jsonValue = serializeWithSchema(propDef, value)
if (jsonValue === SKIP) {
return
}
// todo: propDef.jsonname could be a transform function on key
target[key] = jsonValue
}
if ((propDef === true) || (propDef.pattern && propDef.pattern.test(key))) {
var value = obj[key]
if (propDef === true) {
if (isPrimitive(value)) {
target[key] = value
}
} else {
var jsonValue = serializeWithSchema(propDef, value)
if (jsonValue === SKIP) {
return
}
// todo: propDef.jsonname could be a transform function on key
target[key] = jsonValue
}
}
}
}

/**
Expand Down

0 comments on commit cb93eff

Please sign in to comment.