Socket
Socket
Sign inDemoInstall

number-allocator

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

number-allocator - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

4

CHANGELOG.md

@@ -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.

6

lib/number-allocator.js

@@ -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

{
"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",

@@ -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()
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc