number-allocator
Advanced tools
@@ -19,3 +19,3 @@ name: number-allocator CI | ||
| matrix: | ||
| node-version: [10.x, 11.x, 12.x, 13.x, 14.x, 15.x] | ||
| node-version: [14.x, 15.x, 16.x, 18.x, 19.x] | ||
| fail-fast: false | ||
@@ -22,0 +22,0 @@ |
+4
-0
@@ -0,1 +1,5 @@ | ||
| ## 1.0.13 | ||
| - **Important** Fixed invalid free operator. | ||
| - Updated js-sdsl. | ||
| ## 1.0.12 | ||
@@ -2,0 +6,0 @@ - Updated js-sdsl. updateKeyByIterator() is used. |
@@ -179,5 +179,4 @@ // Copyright Takatoshi Kondo 2021 | ||
| // Concat to right | ||
| const low = it.pointer.high - 1 | ||
| const high = it.pointer.high | ||
| this.ss.updateKeyByIterator(it, new Interval(low, high)) | ||
| this.ss.updateKeyByIterator(it, new Interval(num, high)) | ||
| } else { | ||
@@ -198,4 +197,3 @@ // Insert new interval | ||
| this.ss.eraseElementByIterator(it) | ||
| const high = it.pointer.high | ||
| this.ss.updateKeyByIterator(it, new Interval(lLow, high)) | ||
| this.ss.updateKeyByIterator(it, new Interval(lLow, rHigh)) | ||
| } else { | ||
@@ -202,0 +200,0 @@ // Concat to left |
+3
-3
| { | ||
| "name": "number-allocator", | ||
| "version": "1.0.12", | ||
| "version": "1.0.13", | ||
| "description": "A library for the unique number allocator", | ||
@@ -41,3 +41,3 @@ "main": "index.js", | ||
| "debug": "^4.3.1", | ||
| "js-sdsl": "4.1.4" | ||
| "js-sdsl": "4.3.0" | ||
| }, | ||
@@ -56,3 +56,3 @@ "devDependencies": { | ||
| "karma-mocha": "^2.0.1", | ||
| "mocha": "^8.2.1", | ||
| "mocha": "^10.2.0", | ||
| "nyc": "^15.1.0", | ||
@@ -59,0 +59,0 @@ "snazzy": "^9.0.0", |
+47
-0
@@ -290,2 +290,49 @@ // Copyright Takatoshi Kondo 2021 | ||
| }) | ||
| it('should concat to right on free', function (done) { | ||
| const a = NumberAllocator(0, 3) | ||
| assert.equal(a.alloc(), 0) | ||
| assert.equal(a.alloc(), 1) | ||
| a.free(1) | ||
| assert.equal(a.alloc(), 1) | ||
| done() | ||
| }) | ||
| it('should concat to left on free', function (done) { | ||
| const a = NumberAllocator(0, 3) | ||
| assert.equal(a.alloc(), 0) | ||
| assert.equal(a.alloc(), 1) | ||
| assert.equal(a.alloc(), 2) | ||
| a.free(0) | ||
| a.free(1) | ||
| assert.equal(a.alloc(), 0) | ||
| assert.equal(a.alloc(), 1) | ||
| done() | ||
| }) | ||
| it('should concat to left and right on free', function (done) { | ||
| const a = NumberAllocator(0, 3) | ||
| assert.equal(a.alloc(), 0) | ||
| assert.equal(a.alloc(), 1) | ||
| assert.equal(a.alloc(), 2) | ||
| a.free(0) | ||
| a.free(2) | ||
| a.free(1) | ||
| assert.equal(a.alloc(), 0) | ||
| assert.equal(a.alloc(), 1) | ||
| assert.equal(a.alloc(), 2) | ||
| done() | ||
| }) | ||
| it('should insert new interval on free', function (done) { | ||
| const a = NumberAllocator(0, 4) | ||
| assert.equal(a.alloc(), 0) | ||
| assert.equal(a.alloc(), 1) | ||
| assert.equal(a.alloc(), 2) | ||
| assert.equal(a.alloc(), 3) | ||
| assert.equal(a.alloc(), 4) | ||
| a.free(0) | ||
| a.free(4) | ||
| a.free(2) | ||
| assert.equal(a.alloc(), 0) | ||
| assert.equal(a.alloc(), 2) | ||
| assert.equal(a.alloc(), 4) | ||
| done() | ||
| }) | ||
| }) |
29672
4.39%655
7.38%+ Added
- Removed
Updated