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

Defaults Object #18

Open
buschtoens opened this issue Nov 25, 2012 · 0 comments
Open

Defaults Object #18

buschtoens opened this issue Nov 25, 2012 · 0 comments

Comments

@buschtoens
Copy link
Owner

The defaults array is great. It's very useful, but in practice we often have to deal with defaults objects.

var defs = { host: "localhost", port: 80, https: false };

If we want to use these objects we currently have to parse them into an array, so sanitize can handle them. But what about this?

var defs = { host: "localhost", port: 80, https: false };
function client(host, port, https) {
  var options = sanitize(arguments, client, defs);
  console.log(options);
}
client("google.com", true); // -> { host: "google.com", port: 80, https: true }

This won't harm anybody, as it doesn't conflict with the array syntax. I'll implement that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant