function finish(args, elements, promiseHandler) {
    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;

                checkAnimationShouldBeFinished(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)) {
                checkAnimationShouldBeFinished(activeCall, queueName, defaultQueue);
            }
        }
    }
    if (promiseHandler) {
        if (isVelocityResult(elements) && elements.velocity.animations && elements.then) {
            elements.then(promiseHandler._resolver);
        } else {
            promiseHandler._resolver(elements);
        }
    }
}
When the finish action is triggered, the elements' currently active call is
immediately finished. When an element is finished, 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 finished. 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`.