Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

binary-bitfield

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binary-bitfield - npm Package Compare versions

Comparing version 2.0.10 to 2.56.8

34

binary-bitfield.js

@@ -59,3 +59,3 @@ "use strict";

this.bitfield = this.setPieces(this.pieces);
this.downloaded = this.totalBitfield = (downloaded)
this.downloaded = (downloaded)
? this.d2binary(downloaded)

@@ -95,3 +95,3 @@ : this.setZeros(this.pieces);

}
let addZero = 8 - (result.length % 8);
let addZero = (result.length % 8) ? (8 - (result.length % 8)) : 0;
while (addZero) {

@@ -153,18 +153,18 @@ result += '0';

}
for (let i = 0; i < bits.length; i++) {
if (self.downloaded[i] === '0' && bits[i] === '1')
result += '1';
else
result += '0';
if (bits[i] === '1') {
let num = Number(self.totalBitfield[i]);
num++;
add2total += num;
process.nextTick(() => {
for (let i = 0; i < bits.length; i++) {
if (self.downloaded[i] === '0' && bits[i] === '1')
result += '1';
else
result += '0';
if (bits[i] === '1') {
let num = Number(self.downloaded[i]);
num++;
add2total += num;
}
else
add2total += self.downloaded[i];
}
else
add2total += self.totalBitfield[i];
}
self.totalBitfield = add2total;
process.nextTick(() => {
cb(self.binary2hex(result), self.totalBitfield);
self.downloaded = add2total;
cb(self.binary2hex(result), self.downloaded);
});

@@ -171,0 +171,0 @@ }

@@ -51,3 +51,2 @@ import { Buffer } from 'buffer';

bitfield: string
totalBitfield: string
downloaded: string

@@ -71,3 +70,3 @@ percent: number

this.bitfield = this.setPieces(this.pieces);
this.downloaded = this.totalBitfield = (downloaded)
this.downloaded = (downloaded)
? this.d2binary(downloaded)

@@ -110,3 +109,3 @@ : this.setZeros(this.pieces);

}
let addZero = 8 - (result.length % 8);
let addZero = (result.length % 8) ? (8 - (result.length % 8)) : 0;
while (addZero) {

@@ -175,18 +174,18 @@ result += '0';

}
for (let i = 0; i < bits.length; i++) {
if (self.downloaded[i] === '0' && bits[i] === '1')
result += '1';
else
result += '0';
if (bits[i] === '1') {
let num = Number(self.totalBitfield[i]);
num++;
add2total += num;
process.nextTick(() => {
for (let i = 0; i < bits.length; i++) {
if (self.downloaded[i] === '0' && bits[i] === '1')
result += '1';
else
result += '0';
if (bits[i] === '1') {
let num = Number(self.downloaded[i]);
num++;
add2total += num;
}
else
add2total += self.downloaded[i];
}
else
add2total += self.totalBitfield[i];
}
self.totalBitfield = add2total;
process.nextTick(() => {
cb(self.binary2hex(result), self.totalBitfield);
self.downloaded = add2total;
cb(self.binary2hex(result), self.downloaded);
});

@@ -193,0 +192,0 @@ }

{
"name": "binary-bitfield",
"version": "2.0.10",
"version": "2.56.8",
"description": "Binary bitfield system to easily keep track of torrent pieces",

@@ -5,0 +5,0 @@ "main": "binary-bitfield.js",

"use strict";
const binary_bitfield_1 = require("./binary-bitfield");
let bitfield = new binary_bitfield_1.default('c0', '40');
let y = Buffer.from('40', 'hex');
let bitfield = new binary_bitfield_1.default('c0');
let y = Buffer.from('80', 'hex');
bitfield.findNewPieces(y, (result, total) => {
console.log('b2: ', bitfield);
console.log('r2: ', result);
console.log('t2: ', total);
});
console.log(bitfield.set(0));
console.log(bitfield);
console.log(bitfield.get(1));
console.log('b1: ', bitfield);

@@ -26,11 +26,14 @@ import binaryBitfield from './binary-bitfield';

let bitfield = new binaryBitfield('c0', '40');
let bitfield = new binaryBitfield('c0');
let y = Buffer.from('40', 'hex');
let y = Buffer.from('80', 'hex');
bitfield.findNewPieces(y, (result, total) => {
console.log('b2: ' ,bitfield);
console.log('r2: ' ,result);
console.log('t2: ' ,total);
});
//console.log(bitfield.set(0));
console.log(bitfield.set(0));
console.log(bitfield);
console.log(bitfield.get(1));
console.log('b1: ' ,bitfield);
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