csp.js icon indicating copy to clipboard operation
csp.js copied to clipboard

would you be open to some code updates?

Open mreinstein opened this issue 5 years ago • 6 comments

@njoubert some things I'd like to do:

  • update to es modules
  • update to es6 (let, const, etc.)
  • simplify the API

Would you be open to some pull request(s) for this stuff? Happy to work on it.

mreinstein avatar Jan 28 '20 17:01 mreinstein

Sure, that would be great!

njoubert avatar Feb 18 '20 23:02 njoubert

@njoubert here's what I've come up with so far:

https://gist.github.com/mreinstein/fe6c19caace8921666ab4d24bf7ed0a0

changes:

  • converted to pure es modules
  • made the interface pure functions
  • removed the abstraction layer stuff for adding more solver types (there's only ever been 1 in this repo so far)
  • converted to es6 (let, const, ... object spread syntax)

Let me know if this is something you like, happy to send this in a proper PR

mreinstein avatar Feb 19 '20 01:02 mreinstein

another thing I've considered doing (but haven't yet) is using objects for semi-named parameters. For example this:

addConstraint({
  problem: p,
  variables: [ 'a', 'b' ],
  fn: (a, b) => a*2 === b
})

is probably more readable than:

addConstraint(
  p,
  [ 'a', 'b' ],
  (a, b) => a*2 === b
)

If this is something you like, happy to add this change as well.

mreinstein avatar Feb 19 '20 01:02 mreinstein

@njoubert any thoughts on these changes? Happy to turn this into a PR if you generally agree with the concept.

mreinstein avatar Mar 01 '20 17:03 mreinstein

@mreinstein Your changes look good for me. I think a PR makes it easier to discuss changes

thetric avatar May 31 '20 18:05 thetric

I'm happy to send a PR, was just hoping to hear from the project maintainer if this is something that would even be considered

mreinstein avatar May 31 '20 18:05 mreinstein