jsonQ.js
function(option) {
            var current = this.jsonQ_current,
                newObj = this.cloneObj(jsonQ()),
                newCurrent = newObj.jsonQ_current = [],
                pathObj = this.jsonQ_path,

                //key element (an array of paths with following key)
                key = option.key,
                //dont work with original object clone it and if undefined than make as empty array
                elm = jsonQ.clone(pathObj[key]) || [],
                //qualifier
                qualifier = option.qualifier,
                qType = objType(qualifier),
                //travese method
                method = option.method,
                find = method == "find" ? true : false;

            for (var i = 0, ln = current.length; i < ln; i++) {
                var pathC = current[i].path,
                    pathCTemp = [],
                    found = false;


                if (!find) {
                    //if it is top level continue the loop. This case comes when we do sibling method called on initial object
                    if (pathC.length === 0) {
                        continue;
                    }

                    pathCTemp = pathC.concat([]);
                    pathCTemp.pop();
                }

                //make a loop on element to match the current path and element path
                for (var j = 0; j < elm.length; j++) {
                    var pathE = elm[j].path,
                        condition;
                    if (find) {
                        condition = matchPath(pathC, pathE);
                    } else {
                        var pathETemp = pathE.concat([]);
                        //to pop last element
                        pathETemp.pop();
                        condition = pathCTemp.join() == pathETemp.join();
                    }

                    if (condition) {
                        //code to check qualifier need to be written this on is only when quantifier when it is function in other case it will be applied on last

                        var qTest = tFunc.qTest.call(this, qType, qualifier, pathE, newCurrent);

                        if (qTest) {
                            //to remove element which is already added
                            elm.splice(j, 1);
                            j--;
                        }

                        //make found flag true
                        found = true;
                    }
                    //break if path doesent match in next sequence and for one element is already there.
                    else if (found) {
                        break;
                    }
                }
            }

            //to apply qualifier if it is string . its mainly for array kind of qualifier
            if (qType == "string") {
                newObj = this.filter.call(newObj, qualifier);
            }

            //set other defination variables
            newObj.length = newObj.jsonQ_current.length;

            //to add selector
            newObj.selector.push({
                method: method,
                key: key,
                qualifier: qualifier
            });


            return newObj;
        }
function(option) {
            var current = this.jsonQ_current,
                newObj = this.cloneObj(jsonQ()),
                newCurrent = newObj.jsonQ_current = [],
                pathObj = this.jsonQ_path,

                //key element (an array of paths with following key)
                key = option.key,
                //dont work with original object clone it and if undefined than make as empty array
                elm = jsonQ.clone(pathObj[key]) || [],
                //qualifier
                qualifier = option.qualifier,
                qType = objType(qualifier),
                //travese method
                method = option.method,
                find = method == "find" ? true : false;

            for (var i = 0, ln = current.length; i < ln; i++) {
                var pathC = current[i].path,
                    pathCTemp = [],
                    found = false;


                if (!find) {
                    //if it is top level continue the loop. This case comes when we do sibling method called on initial object
                    if (pathC.length === 0) {
                        continue;
                    }

                    pathCTemp = pathC.concat([]);
                    pathCTemp.pop();
                }

                //make a loop on element to match the current path and element path
                for (var j = 0; j < elm.length; j++) {
                    var pathE = elm[j].path,
                        condition;
                    if (find) {
                        condition = matchPath(pathC, pathE);
                    } else {
                        var pathETemp = pathE.concat([]);
                        //to pop last element
                        pathETemp.pop();
                        condition = pathCTemp.join() == pathETemp.join();
                    }

                    if (condition) {
                        //code to check qualifier need to be written this on is only when quantifier when it is function in other case it will be applied on last

                        var qTest = tFunc.qTest.call(this, qType, qualifier, pathE, newCurrent);

                        if (qTest) {
                            //to remove element which is already added
                            elm.splice(j, 1);
                            j--;
                        }

                        //make found flag true
                        found = true;
                    }
                    //break if path doesent match in next sequence and for one element is already there.
                    else if (found) {
                        break;
                    }
                }
            }

            //to apply qualifier if it is string . its mainly for array kind of qualifier
            if (qType == "string") {
                newObj = this.filter.call(newObj, qualifier);
            }

            //set other defination variables
            newObj.length = newObj.jsonQ_current.length;

            //to add selector
            newObj.selector.push({
                method: method,
                key: key,
                qualifier: qualifier
            });


            return newObj;
        }
function ( option ) { var current = this . jsonQ_current , newObj = this . cloneObj ( jsonQ ( ) ) , newCurrent = newObj . jsonQ_current = [ ] , pathObj = this . jsonQ_path , //key element (an array of paths with following key) key = option . key , //dont work with original object clone it and if undefined than make as empty array elm = jsonQ . clone ( pathObj [ key ] ) || [ ] , //qualifier qualifier = option . qualifier , qType = objType ( qualifier ) , //travese method method = option . method , find = method == "find" ? true : false ; for ( var i = 0 , ln = current . length ; i < ln ; i ++ ) { var pathC = current [ i ] . path , pathCTemp = [ ] , found = false ; if ( ! find ) { //if it is top level continue the loop. This case comes when we do sibling method called on initial object if ( pathC . length === 0 ) { continue ; } pathCTemp = pathC . concat ( [ ] ) ; pathCTemp . pop ( ) ; } //make a loop on element to match the current path and element path for ( var j = 0 ; j < elm . length ; j ++ ) { var pathE = elm [ j ] . path , condition ; if ( find ) { condition = matchPath ( pathC , pathE ) ; } else { var pathETemp = pathE . concat ( [ ] ) ; //to pop last element pathETemp . pop ( ) ; condition = pathCTemp . join ( ) == pathETemp . join ( ) ; } if ( condition ) { //code to check qualifier need to be written this on is only when quantifier when it is function in other case it will be applied on last var qTest = tFunc . qTest . call ( this , qType , qualifier , pathE , newCurrent ) ; if ( qTest ) { //to remove element which is already added elm . splice ( j , 1 ) ; j -- ; } //make found flag true found = true ; } //break if path doesent match in next sequence and for one element is already there. else if ( found ) { break ; } } } //to apply qualifier if it is string . its mainly for array kind of qualifier if ( qType == "string" ) { newObj = this . filter . call ( newObj , qualifier ) ; } //set other defination variables newObj . length = newObj . jsonQ_current . length ; //to add selector newObj . selector . push ( { method : method , key : key , qualifier : qualifier } ) ; return newObj ; }
traverse which have qualifiers mainly on bottom and sibling method
traverse which have qualifiers mainly on bottom and sibling method