I remember opening a bug for this ~2.5 years ago. The answer was that most of these assertions are so trivial to write that putting them in a module would actually make reading the code harder than simpler. I don't think the situation has changed since then.
Cheers, David On 15/05/14 08:04, ajvinc...@gmail.com wrote: > I've been thinking a bit about writing a JSM for validating arguments coming > into a function. > > The first part would be the set of assertion functions: > * a non-empty string > * a whole number > * a positive number > * a non-negative number > * a function > * instanceof > * typeof > * member of a set > * Custom validation function returning true or false > * etc. > > The second part would be how to respond to an assertion failure: > * Throw an Error > * Throw Components.Exception > * Report to JS console service > * Report to a provided Log.jsm logger > * Trigger a debugger keyword > * Custom failure function > * Ordered combinations of the above > > Above all else, the module should have a simple API. Something like this > could be useful throughout the Mozilla codebase, and for addons or custom > XULRunner applications. > > Suggestions? If there's an existing module out there, I'd like to hear of it > before reinventing the wheel. > _______________________________________________ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform > -- David Rajchenbach-Teller, PhD Performance Team, Mozilla
signature.asc
Description: OpenPGP digital signature
_______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform