quickbit-universal
Advanced tools
Comparing version 2.0.5 to 2.1.0
@@ -128,20 +128,21 @@ const simdle = require('simdle-universal') | ||
const Index = exports.Index = class Index { | ||
static from (fieldOrChunks) { | ||
static from (fieldOrChunks, byteLength = -1) { | ||
if (Array.isArray(fieldOrChunks)) { | ||
return new SparseIndex(fieldOrChunks) | ||
return new SparseIndex(fieldOrChunks, byteLength) | ||
} else { | ||
return new DenseIndex(fieldOrChunks) | ||
return new DenseIndex(fieldOrChunks, byteLength) | ||
} | ||
} | ||
get byteLength () { | ||
return 0 | ||
constructor (byteLength) { | ||
this._byteLength = byteLength | ||
this.handle = new Uint32Array(INDEX_LEN / 4) | ||
} | ||
constructor () { | ||
this.handle = new Uint32Array(INDEX_LEN / 4) | ||
get byteLength () { | ||
return this._byteLength | ||
} | ||
skipFirst (value, position = 0) { | ||
const n = this.field.byteLength * 8 | ||
const n = this.byteLength * 8 | ||
@@ -179,4 +180,4 @@ if (position < 0) position += n | ||
skipLast (value, position = this.field.byteLength * 8 - 1) { | ||
const n = this.field.byteLength * 8 | ||
skipLast (value, position = this.byteLength * 8 - 1) { | ||
const n = this.byteLength * 8 | ||
@@ -216,4 +217,4 @@ if (position < 0) position += n | ||
class DenseIndex extends Index { | ||
constructor (field) { | ||
super() | ||
constructor (field, byteLength) { | ||
super(byteLength) | ||
this.field = field | ||
@@ -259,2 +260,3 @@ | ||
get byteLength () { | ||
if (this._byteLength !== -1) return this._byteLength | ||
return this.field.byteLength | ||
@@ -264,3 +266,3 @@ } | ||
update (bit) { | ||
const n = this.field.byteLength * 8 | ||
const n = this.byteLength * 8 | ||
@@ -321,4 +323,4 @@ if (bit < 0) bit += n | ||
class SparseIndex extends Index { | ||
constructor (chunks) { | ||
super() | ||
constructor (chunks, byteLength) { | ||
super(byteLength) | ||
this.chunks = chunks | ||
@@ -366,2 +368,3 @@ | ||
get byteLength () { | ||
if (this._byteLength !== -1) return this._byteLength | ||
const last = this.chunks[this.chunks.length - 1] | ||
@@ -372,8 +375,4 @@ return last ? last.offset + last.field.byteLength : 0 | ||
update (bit) { | ||
if (this.chunks.length === 0) return false | ||
const n = this.byteLength * 8 | ||
const last = this.chunks[this.chunks.length - 1] | ||
const n = (last.offset + last.field.byteLength) * 8 | ||
if (bit < 0) bit += n | ||
@@ -380,0 +379,0 @@ if (bit < 0 || bit >= n) return false |
{ | ||
"name": "quickbit-universal", | ||
"version": "2.0.5", | ||
"version": "2.1.0", | ||
"description": "Universal wrapper for libquickbit with a JavaScript fallback", | ||
@@ -31,3 +31,3 @@ "main": "index.js", | ||
"optionalDependencies": { | ||
"quickbit-native": "^2.0.3" | ||
"quickbit-native": "^2.1.0" | ||
}, | ||
@@ -34,0 +34,0 @@ "devDependencies": { |
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
13449
297