function stop(args, elements, promiseHandler, action) {
    var queueName = validateQueue(args[0], true),
        defaultQueue = defaults$1.queue,
        finishAll = args[queueName === undefined ? 0 : 1] === true;
    if (isVelocityResult(elements) && elements.velocity.animations) {
        var _iteratorNormalCompletion = true;
        var _didIteratorError = false;
        var _iteratorError = undefined;

        try {
            for (var _iterator = elements.velocity.animations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
                var animation = _step.value;

                checkAnimationShouldBeStopped(animation, queueName, defaultQueue);
            }
        } catch (err) {
            _didIteratorError = true;
            _iteratorError = err;
        } finally {
            try {
                if (!_iteratorNormalCompletion && _iterator.return) {
                    _iterator.return();
                }
            } finally {
                if (_didIteratorError) {
                    throw _iteratorError;
                }
            }
        }
    } else {
        while (State.firstNew) {
            validateTweens(State.firstNew);
        }
        for (var activeCall = State.first, nextCall; activeCall && (finishAll || activeCall !== State.firstNew); activeCall = nextCall || State.firstNew) {
            nextCall = activeCall._next;
            if (!elements || elements.includes(activeCall.element)) {
                checkAnimationShouldBeStopped(activeCall, queueName, defaultQueue);
            }
        }
    }
    if (promiseHandler) {
        if (isVelocityResult(elements) && elements.velocity.animations && elements.then) {
            elements.then(promiseHandler._resolver);
        } else {
            promiseHandler._resolver(elements);
        }
    }
}
When the stop action is triggered, the elements' currently active call is
immediately stopped. When an element is stopped, the next item in its
animation queue is immediately triggered. If passed via a chained call
then this will only target the animations in that call, and not the
elements linked to it.

A queue name may be passed in to specify that only animations on the
named queue are stopped. The default queue is named "". In addition the
value of `false` is allowed for the queue name.

An final argument may be passed in to clear an element's remaining queued
calls. This may only be the value `true`.

Note: The stop command runs prior to Velocity's Queueing phase since its
behavior is intended to take effect *immediately*, regardless of the
element's current queue state.