Skip to content

Commit

Permalink
refactor: refactor import statements and move convertMBToBytes and ca…
Browse files Browse the repository at this point in the history
…lculateMemorySize functions to separate files
  • Loading branch information
theodrosyimer committed Feb 27, 2024
1 parent 1f8add5 commit 06bc9fe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/binez.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Command } from 'commander'

import { handleBits, handleBytes } from './range.js'
import { formatNumber, convertMBToBytes, calculateMemorySize } from './utils.js'
import { convertMBToBytes } from './convert.js'
import { calculateMemorySize } from './mem.js'
import { formatNumber } from './utils.js'

export const binezCli = new Command()

Expand Down
6 changes: 6 additions & 0 deletions src/convert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @param mb number of megabytes to convert to bytes
*/
export function convertMBToBytes(mb: number) {
return mb * 1024 * 1024
}
7 changes: 7 additions & 0 deletions src/mem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @param size size of data storage in `kilobytes`, `32` means `32kb`
* @param bits size in `bits` of the numeric value type
*/
export function calculateMemorySize(bits: number, size: number) {
return (size * 1024) / (bits / 8)
}
15 changes: 0 additions & 15 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/**
* @param mb number of megabytes to convert to bytes
*/
export function convertMBToBytes(mb: number) {
return mb * 1024 * 1024
}

/**
* @param size size of data storage in `kilobytes`, `32` means `32kb`
* @param bits size in `bits` of the numeric value type
*/
export function calculateMemorySize(bits: number, size: number) {
return (size * 1024) / (bits / 8)
}

/**
* @param value value to convert
* @param locale locale to use for formatting
Expand Down

0 comments on commit 06bc9fe

Please sign in to comment.