lib/schema/cast.js
function cast ({ id, attributes, relationships, defaultAttrs, defaultRels }) {
  return (data, { onlyMappedValues }) => {
    if (!data) {
      return undefined
    }

    const attrs = castAttributes(data.attributes, attributes, (onlyMappedValues) ? {} : { ...defaultAttrs })
    if (!onlyMappedValues) {
      setDates(attrs)
    }
    const rels = castRelationships(data.relationships, relationships, (onlyMappedValues) ? {} : { ...defaultRels })
    const castId = data.id || attrs.id || uuid()
    delete attrs.id

    const casted = {
      id: castId,
      type: id,
      attributes: attrs,
      relationships: rels
    }

    if (data.isNew) {
      casted.isNew = true
    }
    if (data.isDeleted) {
      casted.isDeleted = true
    }

    return casted
  }
}
function cast ({ id, attributes, relationships, defaultAttrs, defaultRels }) {
  return (data, { onlyMappedValues }) => {
    if (!data) {
      return undefined
    }

    const attrs = castAttributes(data.attributes, attributes, (onlyMappedValues) ? {} : { ...defaultAttrs })
    if (!onlyMappedValues) {
      setDates(attrs)
    }
    const rels = castRelationships(data.relationships, relationships, (onlyMappedValues) ? {} : { ...defaultRels })
    const castId = data.id || attrs.id || uuid()
    delete attrs.id

    const casted = {
      id: castId,
      type: id,
      attributes: attrs,
      relationships: rels
    }

    if (data.isNew) {
      casted.isNew = true
    }
    if (data.isDeleted) {
      casted.isDeleted = true
    }

    return casted
  }
}
Cast item