<commit_before>var CHS = require( 'chs' )
var isBuffer = Buffer.isBuffer

/**
 * MBR Partition
 * @param {Buffer} buffer (optional)
 * @param {Number} start (optional)
 * @param {Number} end (optional)
 * @return {Partition}
 */
function Partition( buffer, start, end ) {
  
  if( !(this instanceof Partition) )
    return new Partition( buffer, start, end )
  
  if( buffer != null && !isBuffer( buffer ) )
    throw new TypeError( 'Argument must be a Buffer' )
  
  this.status = 0x00
  this.type = 0x00
  this.sectors = 0x00
  this.firstLBA = 0x00
  this.firstCHS = new CHS()
  this.lastCHS = new CHS()
  
  if( buffer != null ) {
    this.buffer = buffer.slice( start, end )
  }
  
}

// Partition Attribute Bitmap
// NOTE: Only for internal type property mapping;
// not present anywhere in partition structure on disk
Partition.FREE        = 1 << 0
Partition.HIDDEN      = 1 << 1
Partition.SECURED     = 1 << 2
Partition.FILE_SYSTEM = 1 << 3
Partition.CONTAINER   = 1 << 4
Partition.SERVICE     = 1 << 5
Partition.IMAGE       = 1 << 6
Partition.BLOCKER     = 1 << 7
Partition.POLICY      = 1 << 8

/**
 * Parse a MBR Partition structure
 * @param {Buffer} buffer (optional)
 * @param {Number} start (optional)
 * @param {Number} end (optional)
 * @return {Partition}
 */
Partition.parse = function( buffer, start, end ) {
  return new Partition( buffer, start, end )
}

/**
 * Partition prototype
 * @type {Object}
 */
Partition.prototype = {
  
  constructor: Partition,
  
  get statusText() {
    switch( this.status ) {
      case 0x80: return 'active'; break
      case 0x00: return 'inactive'; break
      default:   return 'invalid'; break
    }
  },
  
  get extended() {
    throw new Error( 'Not implemented' )
  },
  
  get lastLBA() {
    return this.firstLBA + this.sectors
  },
  
  byteOffset: function( blockSize ) {
    blockSize = blockSize || 512
    return this.firstLBA * blockSize
  },
  
  byteSize: function( blockSize ) {
    return this.sectors * blockSize
  },<commit_msg>Updated lib/partition: Added getters for status types<commit_after>var CHS = require( 'chs' )
var isBuffer = Buffer.isBuffer

/**
 * MBR Partition
 * @param {Buffer} buffer (optional)
 * @param {Number} start (optional)
 * @param {Number} end (optional)
 * @return {Partition}
 */
function Partition( buffer, start, end ) {
  
  if( !(this instanceof Partition) )
    return new Partition( buffer, start, end )
  
  if( buffer != null && !isBuffer( buffer ) )
    throw new TypeError( 'Argument must be a Buffer' )
  
  this.status = 0x00
  this.type = 0x00
  this.sectors = 0x00
  this.firstLBA = 0x00
  this.firstCHS = new CHS()
  this.lastCHS = new CHS()
  
  if( buffer != null ) {
    this.buffer = buffer.slice( start, end )
  }
  
}

// Partition Attribute Bitmap
// NOTE: Only for internal type property mapping;
// not present anywhere in partition structure on disk
Partition.FREE        = 1 << 0
Partition.HIDDEN      = 1 << 1
Partition.SECURED     = 1 << 2
Partition.FILE_SYSTEM = 1 << 3
Partition.CONTAINER   = 1 << 4
Partition.SERVICE     = 1 << 5
Partition.IMAGE       = 1 << 6
Partition.BLOCKER     = 1 << 7
Partition.POLICY      = 1 << 8

/**
 * Parse a MBR Partition structure
 * @param {Buffer} buffer (optional)
 * @param {Number} start (optional)
 * @param {Number} end (optional)
 * @return {Partition}
 */
Partition.parse = function( buffer, start, end ) {
  return new Partition( buffer, start, end )
}

/**
 * Partition prototype
 * @type {Object}
 */
Partition.prototype = {
  
  constructor: Partition,
  
  get statusText() {
    switch( this.status ) {
      case 0x80: return 'active'; break
      case 0x00: return 'inactive'; break
      default:   return 'invalid'; break
    }
  },
  
  get active() {
    return this.status === 0x80
  },
  
  get inactive() {
    return this.status === 0x00
  },
  
  get invalid() {
    return !this.active && !this.inactive
  },
  
  get extended() {
    throw new Error( 'Not implemented' )
  },
  
  get lastLBA() {
    return this.firstLBA + this.sectors
  },
  
  byteOffset: function( blockSize ) {
    blockSize = blockSize || 512
    return this.firstLBA * blockSize
  },
  
  byteSize: function( blockSize ) {
    return this.sectors * blockSize
  },
{'fraction_non_alphanumeric': 0.12588568729333963, 'fraction_numerical': 0.01983939537080775, 'mean_word_length': 2.818755635707845, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5475890', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1376, 'n_words': 419}