hooks.js
function nextPreHook() {
                    /**
                     * read the arguments from previous "hook" response
                     */
                    const args = Array.prototype.slice.apply(arguments);

                    /**
                     * Check if the arguments contains an "__override" property
                     * that would override the arguments sent originally to the
                     * target method
                     */
                    if (is.object(args[0]) && {}.hasOwnProperty.call(args[0], '__override')) {
                        passedArgs = arrify(args[0].__override);
                    }

                    /**
                     * Reference to current pre hook
                     */
                    let currentHook;

                    if (currentPre + 1 < totalPres) {
                        currentPre += 1;
                        currentHook = pres[currentPre];
                        const hookMethod = currentHook.displayName || currentHook.name;
                        /**
                         * If there is a __scopeHook function on the object
                         * we call it to get the scope wanted for the hook
                         */
                        scope = getScope(self, name, passedArgs, hookMethod, 'pre');

                        /**
                         * Execute the hook and recursively call the next one
                         */
                        return currentHook.apply(scope, passedArgs).then(nextPreHook, handleError);
                    }

                    /**
                     * We are done with "pre" hooks
                     */
                    return done.apply(scope, passedArgs);
                }
function nextPreHook() {
                    /**
                     * read the arguments from previous "hook" response
                     */
                    const args = Array.prototype.slice.apply(arguments);

                    /**
                     * Check if the arguments contains an "__override" property
                     * that would override the arguments sent originally to the
                     * target method
                     */
                    if (is.object(args[0]) && {}.hasOwnProperty.call(args[0], '__override')) {
                        passedArgs = arrify(args[0].__override);
                    }

                    /**
                     * Reference to current pre hook
                     */
                    let currentHook;

                    if (currentPre + 1 < totalPres) {
                        currentPre += 1;
                        currentHook = pres[currentPre];
                        const hookMethod = currentHook.displayName || currentHook.name;
                        /**
                         * If there is a __scopeHook function on the object
                         * we call it to get the scope wanted for the hook
                         */
                        scope = getScope(self, name, passedArgs, hookMethod, 'pre');

                        /**
                         * Execute the hook and recursively call the next one
                         */
                        return currentHook.apply(scope, passedArgs).then(nextPreHook, handleError);
                    }

                    /**
                     * We are done with "pre" hooks
                     */
                    return done.apply(scope, passedArgs);
                }
function nextPreHook ( ) { /**
                     * read the arguments from previous "hook" response
                     */ const args = Array . prototype . slice . apply ( arguments ) ; /**
                     * Check if the arguments contains an "__override" property
                     * that would override the arguments sent originally to the
                     * target method
                     */ if ( is . object ( args [ 0 ] ) && { } . hasOwnProperty . call ( args [ 0 ] , '__override' ) ) { passedArgs = arrify ( args [ 0 ] . __override ) ; } /**
                     * Reference to current pre hook
                     */ let currentHook ; if ( currentPre + 1 < totalPres ) { currentPre += 1 ; currentHook = pres [ currentPre ] ; const hookMethod = currentHook . displayName || currentHook . name ; /**
                         * If there is a __scopeHook function on the object
                         * we call it to get the scope wanted for the hook
                         */ scope = getScope ( self , name , passedArgs , hookMethod , 'pre' ) ; /**
                         * Execute the hook and recursively call the next one
                         */ return currentHook . apply ( scope , passedArgs ) . then ( nextPreHook , handleError ) ; } /**
                     * We are done with "pre" hooks
                     */ return done . apply ( scope , passedArgs ) ; }
"pre" hook handler
pre hook handler