Comparing version 1.6.0 to 1.7.0
12
index.js
@@ -141,9 +141,17 @@ exports.fullRoots = function (index, result) { | ||
Iterator.prototype.isLeft = function () { | ||
return !(this.offset & 1) | ||
return (this.offset & 1) === 0 | ||
} | ||
Iterator.prototype.isRight = function () { | ||
return !this.isLeft() | ||
return (this.offset & 1) === 1 | ||
} | ||
Iterator.prototype.contains = function (index) { | ||
return index > this.index | ||
? index < (this.index + this.factor / 2) | ||
: index < this.index | ||
? index > (this.index - this.factor / 2) | ||
: true | ||
} | ||
Iterator.prototype.prev = function () { | ||
@@ -150,0 +158,0 @@ if (!this.offset) return this.index |
{ | ||
"name": "flat-tree", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "A series of functions to map a binary tree to a list", | ||
@@ -8,4 +8,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"standard": "^8.6.0", | ||
"tape": "^4.0.0" | ||
"standard": "^14.3.4", | ||
"tape": "^5.0.1" | ||
}, | ||
@@ -12,0 +12,0 @@ "scripts": { |
@@ -96,3 +96,3 @@ # flat-tree | ||
#### `index = iterator.prev() | ||
#### `index = iterator.prev()` | ||
@@ -137,4 +137,21 @@ Move the iterator the prev item in the tree. | ||
## See also | ||
- [mafintosh/print-flat-tree][print]: A cli that can pretty print flat-trees. | ||
- [bcomnes/flattree][ftg]: A port of the node module to Go. | ||
- [arablocks/flat-tree.c](c): A port of the module to C | ||
- [datkt/flat-tree][kt]: A port of the module to Kotlin | ||
- [datrs/flat-tree][rs]: A port to Rust. | ||
- [bcomnes/flattree][ftg]: A port to Go. | ||
- [noffle/cl-flat-tree][clft]: A port to Common Lisp. | ||
## License | ||
MIT | ||
[print]: https://github.com/mafintosh/print-flat-tree | ||
[rs]: https://github.com/datrs/flat-tree | ||
[ftg]: https://github.com/bcomnes/flattree | ||
[c]: https://github.com/arablocks/flat-tree.c | ||
[kt]: https://github.com/datkt/flat-tree | ||
[clft]: https://github.com/noffle/cl-flat-tree |
15
test.js
@@ -27,2 +27,3 @@ var tape = require('tape') | ||
t.same(feed.children(3), [1, 5]) | ||
t.same(feed.children(9), [8, 10]) | ||
t.end() | ||
@@ -147,1 +148,15 @@ }) | ||
}) | ||
tape('iterator, non-leaf start', function (t) { | ||
var iterator = feed.iterator(1) | ||
t.same(iterator.index, 1) | ||
t.same(iterator.parent(), 3) | ||
t.same(iterator.parent(), 7) | ||
t.same(iterator.rightChild(), 11) | ||
t.same(iterator.leftChild(), 9) | ||
t.same(iterator.next(), 13) | ||
t.same(iterator.leftSpan(), 12) | ||
t.end() | ||
}) |
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
14494
309
156
6