How to use the @sinonjs/commons.typeOf function in @sinonjs/commons

To help you get started, we’ve selected a few @sinonjs/commons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sinonjs / formatio / lib / formatio.js View on Github external
}

    // eslint supports bigint as of version 6.0.0
    // https://github.com/eslint/eslint/commit/e4ab0531c4e44c23494c6a802aa2329d15ac90e5
    // eslint-disable-next-line
    if (typeOf(object) === "bigint") {
        return object.toString();
    }

    var internalProcessed = processed || [];

    if (isCircular(object, internalProcessed)) {
        return "[Circular]";
    }

    if (typeOf(object) === "array") {
        return ascii.array.call(f, object, internalProcessed);
    }

    if (!object) {
        return String(1 / object === -Infinity ? "-0" : object);
    }
    if (samsam.isElement(object)) {
        return ascii.element(object);
    }

    if (
        typeof object.toString === "function" &&
        object.toString !== Object.prototype.toString
    ) {
        return object.toString();
    }
github publiclab / Leaflet.DistortableImage / node_modules / @sinonjs / samsam / lib / matcher.js View on Github external
every(actual, function(element, index) {
                var expected = expectation[index];
                return typeOf(expected) === "array" &&
                    typeOf(element) === "array"
                    ? match.array.deepEquals(expected).test(element)
                    : deepEqual(expected, element);
            })
        );
github publiclab / Leaflet.DistortableImage / node_modules / @sinonjs / samsam / lib / matcher.js View on Github external
return arrayEvery(Object.keys(expectation), function(key) {
        var exp = expectation[key];
        var act = actual[key];

        if (isMatcher(exp)) {
            if (!exp.test(act)) {
                return false;
            }
        } else if (typeOf(exp) === "object") {
            if (!matchObject(act, exp)) {
                return false;
            }
        } else if (!deepEqual(act, exp)) {
            return false;
        }

        return true;
    });
}
github publiclab / Leaflet.DistortableImage / node_modules / @sinonjs / samsam / lib / matcher.js View on Github external
function isIterable(value) {
    return !!value && typeOf(value.forEach) === "function";
}
github publiclab / Leaflet.DistortableImage / node_modules / @sinonjs / samsam / lib / matcher.js View on Github external
function match(expectation, message) {
    var m = Object.create(matcher);
    var type = typeOf(expectation);

    if (message !== undefined && typeof message !== "string") {
        throw new TypeError("Message should be a string");
    }

    if (arguments.length > 2) {
        throw new TypeError(
            "Expected 1 or 2 arguments, received " + arguments.length
        );
    }

    if (type in TYPE_MAP) {
        TYPE_MAP[type](m, expectation, message);
    } else {
        m.test = function(actual) {
            return deepEqual(actual, expectation);
github publiclab / Leaflet.DistortableImage / node_modules / @sinonjs / samsam / lib / matcher.js View on Github external
match.in = function(arrayOfExpectations) {
    if (typeOf(arrayOfExpectations) !== "array") {
        throw new TypeError("array expected");
    }

    return match(function(actual) {
        return some(arrayOfExpectations, function(expectation) {
            return expectation === actual;
        });
    }, "in(" + valueToString(arrayOfExpectations) + ")");
};
github publiclab / Leaflet.DistortableImage / node_modules / @sinonjs / samsam / lib / matcher.js View on Github external
function assertType(value, type, name) {
    var actual = typeOf(value);
    if (actual !== type) {
        throw new TypeError(
            "Expected type of " +
                name +
                " to be " +
                type +
                ", but was " +
                actual
        );
    }
}