Skip to content

Commit

Permalink
refactor(buffer): Move P2 to Utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWendelborn committed Sep 15, 2018
1 parent 665c417 commit 0c5b040
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions source/buffer/read-int.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { Bits } from '../types'
import { p2 } from '../utilities'
import not from '../bits/not'
import read from './read'

// 32-bit powers of two wouldn't be possible with <<
const p2: Array<number> = []
for (let i: number = 0; i < 32; i++) p2[i] = Math.pow(2, i)

/**
* Converts a section of a buffer to a signed integer.
*
Expand Down
5 changes: 1 addition & 4 deletions source/buffer/read-u-int.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Bits } from '../types'
import { p2 } from '../utilities'
import read from './read'

// 32-bit powers of two wouldn't be possible with <<
const p2: Array<number> = []
for (let i: number = 0; i < 32; i++) p2[i] = Math.pow(2, i)

/**
* Converts a section of a buffer to an unsigned integer.
*
Expand Down
3 changes: 3 additions & 0 deletions source/utilities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// 32-bit powers of two wouldn't be possible with <<
export const p2: Array<number> = []
for (let i: number = 0; i < 32; i++) p2[i] = Math.pow(2, i)

0 comments on commit 0c5b040

Please sign in to comment.