function isCallbackOfArrayMethod(node) {
    let currentNode = node;

    while (currentNode) {
        const parent = currentNode.parent;

        switch (parent.type) {

            /*
             * Looks up the destination. e.g.,
             * foo.every(nativeFoo || function foo() { ... });
             */
            case "LogicalExpression":
            case "ConditionalExpression":
                currentNode = parent;
                break;

            /*
             * If the upper function is IIFE, checks the destination of the return value.
             * e.g.
             *   foo.every((function() {
             *     // setup...
             *     return function callback() { ... };
             *   })());
             */
            case "ReturnStatement": {
                const func = astUtils.getUpperFunction(parent);

                if (func === null || !astUtils.isCallee(func)) {
                    return false;
                }
                currentNode = func.parent;
                break;
            }

            /*
             * e.g.
             *   Array.from([], function() {});
             *   list.every(function() {});
             */
            case "CallExpression":
                if (astUtils.isArrayFromMethod(parent.callee)) {
                    return (
                        parent.arguments.length >= 2 &&
                        parent.arguments[1] === currentNode
                    );
                }
                if (isTargetMethod(parent.callee)) {
                    return (
                        parent.arguments.length >= 1 &&
                        parent.arguments[0] === currentNode
                    );
                }
                return false;

            // Otherwise this node is not target.
            default:
                return false;
        }
    }

    /* istanbul ignore next: unreachable */
    return false;
}
function isCallbackOfArrayMethod(node) {
    let currentNode = node;

    while (currentNode) {
        const parent = currentNode.parent;

        switch (parent.type) {

            /*
             * Looks up the destination. e.g.,
             * foo.every(nativeFoo || function foo() { ... });
             */
            case "LogicalExpression":
            case "ConditionalExpression":
                currentNode = parent;
                break;

            /*
             * If the upper function is IIFE, checks the destination of the return value.
             * e.g.
             *   foo.every((function() {
             *     // setup...
             *     return function callback() { ... };
             *   })());
             */
            case "ReturnStatement": {
                const func = astUtils.getUpperFunction(parent);

                if (func === null || !astUtils.isCallee(func)) {
                    return false;
                }
                currentNode = func.parent;
                break;
            }

            /*
             * e.g.
             *   Array.from([], function() {});
             *   list.every(function() {});
             */
            case "CallExpression":
                if (astUtils.isArrayFromMethod(parent.callee)) {
                    return (
                        parent.arguments.length >= 2 &&
                        parent.arguments[1] === currentNode
                    );
                }
                if (isTargetMethod(parent.callee)) {
                    return (
                        parent.arguments.length >= 1 &&
                        parent.arguments[0] === currentNode
                    );
                }
                return false;

            // Otherwise this node is not target.
            default:
                return false;
        }
    }

    /* istanbul ignore next: unreachable */
    return false;
}
function isCallbackOfArrayMethod ( node ) { let currentNode = node ; while ( currentNode ) { const parent = currentNode . parent ; switch ( parent . type ) { /*
             * Looks up the destination. e.g.,
             * foo.every(nativeFoo || function foo() { ... });
             */ case "LogicalExpression" : case "ConditionalExpression" : currentNode = parent ; break ; /*
             * If the upper function is IIFE, checks the destination of the return value.
             * e.g.
             *   foo.every((function() {
             *     // setup...
             *     return function callback() { ... };
             *   })());
             */ case "ReturnStatement" : { const func = astUtils . getUpperFunction ( parent ) ; if ( func === null || ! astUtils . isCallee ( func ) ) { return false ; } currentNode = func . parent ; break ; } /*
             * e.g.
             *   Array.from([], function() {});
             *   list.every(function() {});
             */ case "CallExpression" : if ( astUtils . isArrayFromMethod ( parent . callee ) ) { return ( parent . arguments . length >= 2 && parent . arguments [ 1 ] === currentNode ) ; } if ( isTargetMethod ( parent . callee ) ) { return ( parent . arguments . length >= 1 && parent . arguments [ 0 ] === currentNode ) ; } return false ; // Otherwise this node is not target. default : return false ; } } /* istanbul ignore next: unreachable */ return false ; }
Checks whether or not a given node is a function expression which is the
callback of an array method.

@param {ASTNode} node - A node to check. This is one of
FunctionExpression or ArrowFunctionExpression.
@returns {boolean} `true` if the node is the callback of an array method.
Checks whether or not a given node is a function expression which is the callback of an array method .
Checks if the node is a callback of an array method