Comparing version 0.0.11 to 0.0.12
@@ -1,2 +0,2 @@ | ||
function Advance (array) { | ||
function Forward (array) { | ||
this._array = array | ||
@@ -6,7 +6,7 @@ this._index = 0 | ||
Advance.prototype.get = function () { | ||
Forward.prototype.get = function () { | ||
return this._array[this._index++] | ||
} | ||
Advance.prototype.next = function (callback) { | ||
Forward.prototype.next = function (callback) { | ||
if (this._index >= this._array.length) { | ||
@@ -19,8 +19,33 @@ callback(null, false) | ||
Advance.prototype.unlock = function (callback) { | ||
Forward.prototype.unlock = function (callback) { | ||
callback() | ||
} | ||
module.exports = function (array) { | ||
return new Advance(array) | ||
exports.forward = function (array) { | ||
return new Forward(array) | ||
} | ||
function Reverse (array) { | ||
this._array = array | ||
this._index = array.length - 1 | ||
} | ||
Reverse.prototype.get = function () { | ||
return this._array[this._index--] | ||
} | ||
Reverse.prototype.next = function (callback) { | ||
if (this._index < 0) { | ||
callback(null, false) | ||
} else { | ||
callback(null, true) | ||
} | ||
} | ||
Reverse.prototype.unlock = function (callback) { | ||
callback() | ||
} | ||
exports.reverse = function (array) { | ||
return new Reverse(array) | ||
} |
{ | ||
"name": "advance", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"author": "Alan Gutierrez <alan@prettyrobots.com>", | ||
@@ -30,3 +30,3 @@ "description": "In-memory forward iterator for use with the Strata b-tree MVCC tool collection.", | ||
{ | ||
"proof": "0.0.50", | ||
"proof": "0.0.51", | ||
"cadence": "0.0.52" | ||
@@ -33,0 +33,0 @@ }, |
@@ -5,3 +5,3 @@ require('proof')(3, require('cadence/redux')(prove)) | ||
var values = [ 'a', 'b', 'c' ] | ||
var iterator = require('../..')(values) | ||
var iterator = require('../..').forward(values) | ||
async(function () { | ||
@@ -8,0 +8,0 @@ iterator.next(async()) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7085
12
80