import Random from '../../../util/Random' ; import BitSet from '../../../util/BitSet' ; import { corrupt } from '../../../common/reedsolomon/ReedSolomonCorrupt' ; author Sean Owen
  export default abstract class AbstractErrorCorrectionSpec { static corrupt ( received , howMany , random ) { corrupt ( received , howMany , random , 929 ) ; } static erase ( received , howMany , random ) { const erased = new Map < number , boolean > ( ) ; const erasures = new Int32Array ( howMany ) ; let erasureOffset = 0 ; for ( let j = 0 ; j < howMany ; j ++ ) { const location = random . next ( received . length ) ; if ( erased . get ( location ) ) { j -- ; } else { erased . set ( location , true ) ; received [ location ] = 0 ; erasures [ erasureOffset ++ ] = location ; } } return erasures ; } static getRandom ( ) { return new Random ( '0xDEADBEEF' ) ; } }