Skip to content

Commit 79f280b

Browse files
committed
Update
1 parent ae8f597 commit 79f280b

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

strings/update.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ function replaceAll(toBeReplaced) {
6666

6767
export const replaceSpacesWithHyphens = replaceAll(/\s+/)("-");
6868
export const replaceSpacesWithUnderscores = replaceAll(/\s+/)("_");
69+
export const replaceHyphensWithSpaces = replaceAll(/-/)(" ");
70+
export const replaceUnderscoresWithSpaces = replaceAll(/_+/)(" ");
71+
export const replaceHyphensWithUnderscores = replaceAll(/-+/)("_");
72+
export const replaceUnderscoresWithHyphens = replaceAll(/_+/)("-");
6973

7074
function pad(character) {
7175
return (minimumLength) => (input) => {

units.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Number of bytes in a Kilobyte.
3+
* @const
4+
* @type {number}
5+
*/
6+
export const BYTES_PER_KB = 1024;
7+
8+
/**
9+
* Convert bytes to megabytes.
10+
* @param {number} bytes - The number of bytes.
11+
* @return {number} The equivalent number of megabytes.
12+
*/
13+
export function bytesToMb(bytes) {
14+
return bytes / BYTES_PER_KB / BYTES_PER_KB;
15+
}
16+
17+
/**
18+
* Convert bytes to gigabytes.
19+
* @param {number} bytes - The number of bytes.
20+
* @return {number} The equivalent number of gigabytes.
21+
*/
22+
export function bytesToGb(bytes) {
23+
return bytes / BYTES_PER_KB / BYTES_PER_KB / BYTES_PER_KB;
24+
}
25+
26+
/**
27+
* Convert megabytes to bytes.
28+
* @param {number} mb - The number of megabytes.
29+
* @return {number} The equivalent number of bytes.
30+
*/
31+
export function mbToBytes(mb) {
32+
return mb * BYTES_PER_KB * BYTES_PER_KB;
33+
}
34+
35+
/**
36+
* Convert megabytes to gigabytes.
37+
* @param {number} mb - The number of megabytes.
38+
* @return {number} The equivalent number of gigabytes.
39+
*/
40+
export function mbToGb(mb) {
41+
return mb / BYTES_PER_KB;
42+
}
43+
44+
/**
45+
* Convert gigabytes to bytes.
46+
* @param {number} gb - The number of gigabytes.
47+
* @return {number} The equivalent number of bytes.
48+
*/
49+
export function gbToBytes(gb) {
50+
return gb * BYTES_PER_KB * BYTES_PER_KB * BYTES_PER_KB;
51+
}
52+
53+
/**
54+
* Convert gigabytes to megabytes.
55+
* @param {number} gb - The number of gigabytes.
56+
* @return {number} The equivalent number of megabytes.
57+
*/
58+
export function gbToMb(gb) {
59+
return gb * BYTES_PER_KB;
60+
}

0 commit comments

Comments
 (0)