Skip to content

Commit 0c5b040

Browse files
refactor(buffer): Move P2 to Utilities
1 parent 665c417 commit 0c5b040

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

source/buffer/read-int.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import { Bits } from '../types'
2+
import { p2 } from '../utilities'
23
import not from '../bits/not'
34
import read from './read'
45

5-
// 32-bit powers of two wouldn't be possible with <<
6-
const p2: Array<number> = []
7-
for (let i: number = 0; i < 32; i++) p2[i] = Math.pow(2, i)
8-
96
/**
107
* Converts a section of a buffer to a signed integer.
118
*

source/buffer/read-u-int.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { Bits } from '../types'
2+
import { p2 } from '../utilities'
23
import read from './read'
34

4-
// 32-bit powers of two wouldn't be possible with <<
5-
const p2: Array<number> = []
6-
for (let i: number = 0; i < 32; i++) p2[i] = Math.pow(2, i)
7-
85
/**
96
* Converts a section of a buffer to an unsigned integer.
107
*

source/utilities.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// 32-bit powers of two wouldn't be possible with <<
2+
export const p2: Array<number> = []
3+
for (let i: number = 0; i < 32; i++) p2[i] = Math.pow(2, i)

0 commit comments

Comments
 (0)