Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match$ method; true if entA subset of entB #50

Open
rjrodger opened this issue Mar 18, 2018 · 0 comments
Open

match$ method; true if entA subset of entB #50

rjrodger opened this issue Mar 18, 2018 · 0 comments
Assignees

Comments

@rjrodger
Copy link
Contributor

draft impl:

function match$(sub_ent, super_ent, why) {
  var why = { match: false }
  if( (null != super_ent.id || null != super_ent.id$) && null == sub_ent.id ) {
    why.no_id = true
    return why
  }
  
  if( (null == super_ent.id && null == super_ent.id$) && null != sub_ent.id )  {
    why.has_id = true
    return why
  }
  
  if( !sub_ent.is$(super_ent.canon$()) ) {
    why.canon = true
    return why
  }

  // FIX: this will need to be deepEqual
  why.match = true
  Object.keys(sub_ent.data$()).forEach(function(sub_field) {
    if( 'id' != sub_field && sub_ent[sub_field] !== super_ent[sub_field] ) {
      why.match = false
      why.field = sub_field
      why.values = [sub_ent[sub_field], super_ent[sub_field]]
    }
  })

  return why
}

@rjrodger rjrodger self-assigned this Mar 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant