How to implement 'assert' function?


Problem: How would you write an assert function that checks if an object o verify a property p else throw an error with message m after all reactive computations completed?

My solution:

var assert =
        function (message, checkProperty, getValue) {
            Tracker.afterFlush(function () {
                try {
                    check(getValue(), Match.Where(checkProperty));
                catch (e) {
                    Match.test(e, Match.Error) && (e.message = message);
                    throw e;

checkProperty : Object -> Boolean
getValue : ΓΈ -> Object
getValue has to be a function to fetch the value in memory at the last possible moment, i.e when the checkProperty function is called with the corresponding object as an argument.

Do you see any weak point with this implementation?