Skip to content

Commit

Permalink
Switch to typescript 3.8.3. No semantic change.
Browse files Browse the repository at this point in the history
  • Loading branch information
qwertie committed Nov 2, 2020
1 parent 480fd5b commit 0f8dcc4
Show file tree
Hide file tree
Showing 8 changed files with 3,718 additions and 3,686 deletions.
12 changes: 6 additions & 6 deletions b+tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ export default class BTree<K = any, V = any> implements ISortedMapF<K, V>, ISort
*/
constructor(entries?: [K, V][], compare?: (a: K, b: K) => number, maxNodeSize?: number);
/** Gets the number of key-value pairs in the tree. */
readonly size: number;
get size(): number;
/** Gets the number of key-value pairs in the tree. */
readonly length: number;
get length(): number;
/** Returns true iff the tree contains no key-value pairs. */
readonly isEmpty: boolean;
get isEmpty(): boolean;
/** Releases the tree so that its size is 0. */
clear(): void;
forEach(callback: (v: V, k: K, tree: BTree<K, V>) => void, thisArg?: any): number;
Expand Down Expand Up @@ -228,7 +228,7 @@ export default class BTree<K = any, V = any> implements ISortedMapF<K, V>, ISort
* @param firstKey: Minimum key whose associated value is included in the output. */
values(firstKey?: K): IterableIterator<V>;
/** Returns the maximum number of children/values before nodes will split. */
readonly maxNodeSize: number;
get maxNodeSize(): number;
/** Gets the lowest key in the tree. Complexity: O(log size) */
minKey(): K | undefined;
/** Gets the highest key in the tree. Complexity: O(1) */
Expand Down Expand Up @@ -342,7 +342,7 @@ export default class BTree<K = any, V = any> implements ISortedMapF<K, V>, ISort
deleteKeys(keys: K[]): number;
/** Gets the height of the tree: the number of internal nodes between the
* BTree object and its leaf nodes (zero if there are no internal nodes). */
readonly height: number;
get height(): number;
/** Makes the object read-only to ensure it is not accidentally modified.
* Freezing does not have to be permanent; unfreeze() reverses the effect.
* This is accomplished by replacing mutator functions with a function
Expand All @@ -353,7 +353,7 @@ export default class BTree<K = any, V = any> implements ISortedMapF<K, V>, ISort
/** Ensures mutations are allowed, reversing the effect of freeze(). */
unfreeze(): void;
/** Returns true if the tree appears to be frozen. */
readonly isFrozen: boolean;
get isFrozen(): boolean;
/** Scans the tree for signs of serious bugs (e.g. this.size doesn't match
* number of elements, internal nodes not caching max element properly...)
* Computational complexity: O(number of nodes), i.e. O(size). This method
Expand Down
24 changes: 14 additions & 10 deletions b+tree.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
Expand All @@ -19,6 +22,7 @@ var __extends = (this && this.__extends) || (function () {
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmptyBTree = exports.defaultComparator = void 0;
// Informative microbenchmarks & stuff:
// http://www.jayconrod.com/posts/52/a-tour-of-v8-object-representation (very educational)
// https://blog.mozilla.org/luke/2012/10/02/optimizing-javascript-variable-access/ (local vars are faster than properties)
Expand Down Expand Up @@ -141,19 +145,19 @@ var __extends = (this && this.__extends) || (function () {
// ES6 Map<K,V> methods ///////////////////////////////////////////////////
/** Gets the number of key-value pairs in the tree. */
get: function () { return this._size; },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(BTree.prototype, "length", {
/** Gets the number of key-value pairs in the tree. */
get: function () { return this._size; },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(BTree.prototype, "isEmpty", {
/** Returns true iff the tree contains no key-value pairs. */
get: function () { return this._size === 0; },
enumerable: true,
enumerable: false,
configurable: true
});
/** Releases the tree so that its size is 0. */
Expand Down Expand Up @@ -494,7 +498,7 @@ var __extends = (this && this.__extends) || (function () {
get: function () {
return this._maxNodeSize;
},
enumerable: true,
enumerable: false,
configurable: true
});
/** Gets the lowest key in the tree. Complexity: O(log size) */
Expand Down Expand Up @@ -718,7 +722,7 @@ var __extends = (this && this.__extends) || (function () {
node = node.children;
return h;
},
enumerable: true,
enumerable: false,
configurable: true
});
/** Makes the object read-only to ensure it is not accidentally modified.
Expand Down Expand Up @@ -746,7 +750,7 @@ var __extends = (this && this.__extends) || (function () {
get: function () {
return this.hasOwnProperty('editRange');
},
enumerable: true,
enumerable: false,
configurable: true
});
/** Scans the tree for signs of serious bugs (e.g. this.size doesn't match
Expand Down Expand Up @@ -783,7 +787,7 @@ var __extends = (this && this.__extends) || (function () {
}
Object.defineProperty(BNode.prototype, "isLeaf", {
get: function () { return this.children === undefined; },
enumerable: true,
enumerable: false,
configurable: true
});
// Shared methods /////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion b+tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ if (Symbol && Symbol.iterator) // iterator is equivalent to entries()
(BTree as any).prototype.setRange = BTree.prototype.setPairs;
(BTree as any).prototype.add = BTree.prototype.set;

function iterator<T>(next: () => {done:boolean,value?:T} = (() => ({ done:true, value:undefined }))): IterableIterator<T> {
function iterator<T>(next: () => IteratorResult<T> = (() => ({ done:true, value:undefined }))): IterableIterator<T> {
var result: any = { next };
if (Symbol && Symbol.iterator)
result[Symbol.iterator] = function() { return this; };
Expand Down
Loading

0 comments on commit 0f8dcc4

Please sign in to comment.