Write a function that takes an rtype interface description as a string and returns an object that can be used for runtime type checking.
interface TypeChecker {
checkInputs: Predicate,
checkOutput: Predicate,
checkError: Predicate
}
parseSignature(signature: String) => TypeChecker
The target function will get wrapped by a utility such as rfx. When the wrapper function gets called, it will pass inputs to checkInputs(). If it returns true, only then does the original function get called. When the function returns, its output will be similarly checked by checkOutput() before it gets returned to the original caller. If the function throws, the error will also be checked, by checkError().
Useful background:
If you're curious about types, see the introduction to types from the Stanford Compiler course.
Contributing
Start with unit tests, please. See Why I Use Tape Instead of Mocha & So Should You & Five Questions Every Unit Test Must Answer for guidance on how to write a good unit test suite.
Related issues:
Write a function that takes an rtype interface description as a string and returns an object that can be used for runtime type checking.
The target function will get wrapped by a utility such as rfx. When the wrapper function gets called, it will pass inputs to
checkInputs(). If it returns true, only then does the original function get called. When the function returns, its output will be similarly checked bycheckOutput()before it gets returned to the original caller. If the function throws, the error will also be checked, bycheckError().Useful background:
If you're curious about types, see the introduction to types from the Stanford Compiler course.
Contributing
Start with unit tests, please. See Why I Use Tape Instead of Mocha & So Should You & Five Questions Every Unit Test Must Answer for guidance on how to write a good unit test suite.
Related issues:
interfaces.rtypefile #61