Comparing version 1.0.1 to 1.0.2
@@ -44,5 +44,3 @@ var ltgt = require('ltgt') | ||
Keydir.prototype.range = function (options) { | ||
options = options || {} | ||
Keydir.prototype._rangeIndexes = function (options) { | ||
var lowerBound = ltgt.lowerBound(options) | ||
@@ -55,3 +53,2 @@ , fromIdx = lowerBound ? | ||
this._sortedIndexOf(upperBound) + 1 : this._keys.length | ||
, keys | ||
@@ -75,5 +72,11 @@ if (ltgt.lowerBoundExclusive(options) && this._keys[fromIdx] === lowerBound) | ||
} | ||
return { from: fromIdx, to: toIdx } | ||
} | ||
keys = this._keys.slice(fromIdx, toIdx) | ||
Keydir.prototype.range = function (options) { | ||
options = options || {} | ||
var indexes = this._rangeIndexes(options) | ||
, keys = this._keys.slice(indexes.from, indexes.to) | ||
if (options.reverse) | ||
@@ -80,0 +83,0 @@ keys = keys.reverse() |
{ | ||
"name": "keydir", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A sorted list of keys with support for level-* ranges", | ||
@@ -5,0 +5,0 @@ "main": "keydir.js", |
@@ -9,2 +9,6 @@ # keydir[![build status](https://secure.travis-ci.org/kesla/keydir.svg)](http://travis-ci.org/kesla/keydir) | ||
## Kudos | ||
The starting point for this module was extracted from the memdown-module (https://npmjs.org/package/memdown). | ||
## Installation | ||
@@ -11,0 +15,0 @@ |
@@ -89,2 +89,7 @@ var test = require('tape') | ||
t.deepEqual( | ||
dir.range({ limit: -1 }) | ||
, [ 'foo1', 'foo2', 'foo3', 'foo4', 'foo5' ] | ||
) | ||
t.deepEqual( | ||
dir.range({ reverse: true }) | ||
@@ -91,0 +96,0 @@ , [ 'foo5', 'foo4', 'foo3', 'foo2', 'foo1' ] |
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
7909
188
42