lib/dataset/query.js
function (limit, offset) {
            if (this.__opts.sql) {
                return this.fromSelf().limit(limit, offset);
            }
            if (Array.isArray(limit) && limit.length === 2) {
                offset = limit[0];
                limit = limit[1] - limit[0] + 1;
            }
            if (isString(limit) || isInstanceOf(limit, LiteralString)) {
                limit = parseInt("" + limit, 10);
            }
            if (isNumber(limit) && limit < 1) {
                throw new QueryError("Limit must be >= 1");
            }
            var opts = {limit: limit};
            if (offset) {
                if (isString(offset) || isInstanceOf(offset, LiteralString)) {
                    offset = parseInt("" + offset, 10);
                    isNaN(offset) && (offset = 0);
                }
                if (isNumber(offset) && offset < 0) {
                    throw new QueryError("Offset must be >= 0");
                }
                opts.offset = offset;
            }
            return this.mergeOptions(opts);
        }
function (limit, offset) {
            if (this.__opts.sql) {
                return this.fromSelf().limit(limit, offset);
            }
            if (Array.isArray(limit) && limit.length === 2) {
                offset = limit[0];
                limit = limit[1] - limit[0] + 1;
            }
            if (isString(limit) || isInstanceOf(limit, LiteralString)) {
                limit = parseInt("" + limit, 10);
            }
            if (isNumber(limit) && limit < 1) {
                throw new QueryError("Limit must be >= 1");
            }
            var opts = {limit: limit};
            if (offset) {
                if (isString(offset) || isInstanceOf(offset, LiteralString)) {
                    offset = parseInt("" + offset, 10);
                    isNaN(offset) && (offset = 0);
                }
                if (isNumber(offset) && offset < 0) {
                    throw new QueryError("Offset must be >= 0");
                }
                opts.offset = offset;
            }
            return this.mergeOptions(opts);
        }
function ( limit , offset ) { if ( this . __opts . sql ) { return this . fromSelf ( ) . limit ( limit , offset ) ; } if ( Array . isArray ( limit ) && limit . length === 2 ) { offset = limit [ 0 ] ; limit = limit [ 1 ] - limit [ 0 ] + 1 ; } if ( isString ( limit ) || isInstanceOf ( limit , LiteralString ) ) { limit = parseInt ( "" + limit , 10 ) ; } if ( isNumber ( limit ) && limit < 1 ) { throw new QueryError ( "Limit must be >= 1" ) ; } var opts = { limit : limit } ; if ( offset ) { if ( isString ( offset ) || isInstanceOf ( offset , LiteralString ) ) { offset = parseInt ( "" + offset , 10 ) ; isNaN ( offset ) && ( offset = 0 ) ; } if ( isNumber ( offset ) && offset < 0 ) { throw new QueryError ( "Offset must be >= 0" ) ; } opts . offset = offset ; } return this . mergeOptions ( opts ) ; }
If given an integer, the dataset will contain only the first l results.
If a second argument is given, it is used as an offset. To use
an offset without a limit, pass null as the first argument.

@example

DB.from("items").limit(10)
//=> SELECT * FROM items LIMIT 10
DB.from("items").limit(10, 20)
//=> SELECT * FROM items LIMIT 10 OFFSET 20
DB.from("items").limit([3, 7]).sql
//=> SELECT * FROM items LIMIT 5 OFFSET 3');
DB.from("items").limit(null, 20)
//=> SELECT * FROM items OFFSET 20

DB.from("items").limit('6', sql['a() - 1']).sql
=> 'SELECT * FROM items LIMIT 6 OFFSET a() - 1');

@param {Number|String|Number[]} limit the limit to apply
@param {Number|String|patio.sql.LiteralString} offset the offset to apply

@return {patio.Dataset}  a cloned dataset witht the LIMIT and OFFSET applied.
If given an integer the dataset will contain only the first l results . If a second argument is given it is used as an offset . To use an offset without a limit pass null as the first argument .