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

chs

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chs - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

57

lib/chs.js

@@ -16,22 +16,8 @@ /**

if( cylinder != null && !Number.isFinite( cylinder ) )
throw new TypeError( 'Cylinder must be a number' )
if( head != null && !Number.isFinite( head ) )
throw new TypeError( 'Head must be a number' )
if( sector != null && !Number.isFinite( sector ) )
throw new TypeError( 'Sector must be a number' )
/** @type {Number} Cylinder */
this.cylinder = cylinder != null ?
( cylinder | 0 ) : 1023
this.cylinder = cylinder & 0x03FF
/** @type {Number} Head */
this.head = head != null ?
( head | 0 ) : 254
this.head = head & 0xFF
/** @type {Number} Sector */
this.sector = sector != null ?
( sector | 0 ) : 63
this.sector = sector & 0x3F

@@ -142,13 +128,16 @@ }

this.head = buffer[0]
var value = buffer.readUIntLE( 0, 3 )
// Sector in bits 5–0;
// bits 7–6 are high bits of cylinder
// 00111111b
this.sector = buffer[1] & 0x3F
// The head is in the low 8 bits;
// 11111111 00000000 00000000
this.head = ( value & 0xFF0000 ) >>> 16
// Bits 7-6 from sector & bits 7–0 of cylinder
// 11000000b
this.cylinder = ( ( buffer[1] & 0xC0 ) << 2 ) | buffer[2]
// The cylinder in bits 8-16 + 16-18;
// 00000000 11111111 11000000
this.cylinder = ( value & 0x00FFC0 ) >>> 6
// The sector in bits 18-24;
// 00000000 00000000 00111111
this.sector = ( value & 0x00003F )
return this

@@ -164,8 +153,18 @@

var cylinder = this.cylinder & 0xFF
var head = this.head
var sector = (( this.sector >> 2 ) & 0xC0) ^ this.sector
var buffer = Buffer.alloc(3)
var value = 0
return new Buffer([ head, sector, cylinder ])
// 11111111 00000000 00000000
value = ( this.head & 0xFF ) << 16
// 00000000 11111111 11000000
value = value | (( this.cylinder << 6 ) & 0xFFC0 )
// 00000000 00000000 00111111
value = value | ( this.sector & 0x3F )
buffer.writeUIntLE( value, 0, 3 )
return buffer
},

@@ -172,0 +171,0 @@

{
"name": "chs",
"version": "1.0.0",
"version": "1.0.1",
"description": "Cylinder-Head-Sector Address (CHS)",

@@ -23,3 +23,3 @@ "author": "Jonas Hermsmeier <jhermsmeier@gmail.com> (https://jhermsmeier.de)",

"devDependencies": {
"mocha": "~3.1.0"
"mocha": "^3.4.2"
},

@@ -26,0 +26,0 @@ "homepage": "https://github.com/jhermsmeier/node-chs",

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