import { __read, __spread } from "tslib";
var areArgumentsEqual = function (currentArguments, lastArguments) {
    if (currentArguments.length !== lastArguments.length) {
        return false;
    }
    for (var index = 0; index < currentArguments.length; index++) {
        var lastArg = lastArguments[index];
        var arg = currentArguments[index];
        if (arg !== lastArg) {
            return false;
        }
    }
    return true;
};
export var memoizeOne = function (cb, equals) {
    if (equals === void 0) { equals = areArgumentsEqual; }
    var lastArgs;
    var lastResult;
    return function () {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        if (lastResult === undefined ||
            lastArgs === undefined ||
            !equals(args, lastArgs)) {
            lastResult = cb.apply(void 0, __spread(args));
            lastArgs = args;
        }
        return lastResult;
    };
};
