lib/WixClient.js
function WixPagingData(initialResult, wixApiCallback, dataHandler) {
    this.currentData = initialResult;
    if(dataHandler !== undefined && dataHandler !== null) {
        this.resultData = _.map(initialResult.results, function(elem) {
            return dataHandler(elem);
        });
    } else {
        this.resultData = initialResult.results;
    }

    this.wixApiCallback = wixApiCallback;

    function canYieldData(data, mode) {
        if(data !== null) {
            var field = data.nextCursor;
            if(mode === 'previous') {
                field = data.previousCursor;
            }
            return field !== null && field !== 0;
        }
        return false;
    }

    /**
     * Determines if this cursor can yield additional data
     * @returns {boolean}
     */
    this.hasNext = function() {
        return canYieldData(this.currentData, 'next');
    };
    /**
     * Determines if this cursor can yield previous data
     * @returns {boolean}
     */
    this.hasPrevious = function() {
        return canYieldData(this.currentData, 'previous');
    };
    /**
     * Returns the next page of data for this paging collection
     * @returns {Promise.<WixPagingData, error>}
     */
    this.next = function() {
        return this.wixApiCallback(this.currentData.nextCursor);
    };
    /**
     * Returns the previous page of data for this paging collection
     * @returns {Promise.<WixPagingData, error>}
     */
    this.previous = function() {
        return this.wixApiCallback(this.currentData.previousCursor);
    };
    /**
     * Returns an array of items represented in this page of data
     * @returns {array}
     */
    this.results = function() {
        return this.resultData;
    };
}
function WixPagingData(initialResult, wixApiCallback, dataHandler) {
    this.currentData = initialResult;
    if(dataHandler !== undefined && dataHandler !== null) {
        this.resultData = _.map(initialResult.results, function(elem) {
            return dataHandler(elem);
        });
    } else {
        this.resultData = initialResult.results;
    }

    this.wixApiCallback = wixApiCallback;

    function canYieldData(data, mode) {
        if(data !== null) {
            var field = data.nextCursor;
            if(mode === 'previous') {
                field = data.previousCursor;
            }
            return field !== null && field !== 0;
        }
        return false;
    }

    /**
     * Determines if this cursor can yield additional data
     * @returns {boolean}
     */
    this.hasNext = function() {
        return canYieldData(this.currentData, 'next');
    };
    /**
     * Determines if this cursor can yield previous data
     * @returns {boolean}
     */
    this.hasPrevious = function() {
        return canYieldData(this.currentData, 'previous');
    };
    /**
     * Returns the next page of data for this paging collection
     * @returns {Promise.<WixPagingData, error>}
     */
    this.next = function() {
        return this.wixApiCallback(this.currentData.nextCursor);
    };
    /**
     * Returns the previous page of data for this paging collection
     * @returns {Promise.<WixPagingData, error>}
     */
    this.previous = function() {
        return this.wixApiCallback(this.currentData.previousCursor);
    };
    /**
     * Returns an array of items represented in this page of data
     * @returns {array}
     */
    this.results = function() {
        return this.resultData;
    };
}
function WixPagingData ( initialResult , wixApiCallback , dataHandler ) { this . currentData = initialResult ; if ( dataHandler !== undefined && dataHandler !== null ) { this . resultData = _ . map ( initialResult . results , function ( elem ) { return dataHandler ( elem ) ; } ) ; } else { this . resultData = initialResult . results ; } this . wixApiCallback = wixApiCallback ; function canYieldData ( data , mode ) { if ( data !== null ) { var field = data . nextCursor ; if ( mode === 'previous' ) { field = data . previousCursor ; } return field !== null && field !== 0 ; } return false ; } /**
     * Determines if this cursor can yield additional data
     * @returns {boolean}
     */ this . hasNext = function ( ) { return canYieldData ( this . currentData , 'next' ) ; } ; /**
     * Determines if this cursor can yield previous data
     * @returns {boolean}
     */ this . hasPrevious = function ( ) { return canYieldData ( this . currentData , 'previous' ) ; } ; /**
     * Returns the next page of data for this paging collection
     * @returns {Promise.<WixPagingData, error>}
     */ this . next = function ( ) { return this . wixApiCallback ( this . currentData . nextCursor ) ; } ; /**
     * Returns the previous page of data for this paging collection
     * @returns {Promise.<WixPagingData, error>}
     */ this . previous = function ( ) { return this . wixApiCallback ( this . currentData . previousCursor ) ; } ; /**
     * Returns an array of items represented in this page of data
     * @returns {array}
     */ this . results = function ( ) { return this . resultData ; } ; }
A WixPagingData object is used to navigate cursored data sets returned by Wix APIs
@constructor
@class
@alias WixPagingData
A WixPagingData object is used to navigate cursored data sets returned by Wix APIs