-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bd63db
commit b13ac5f
Showing
7 changed files
with
130 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
|
||
export function prepareData(data: { [key: string]: string }) { | ||
return Object.keys(data) | ||
.map( | ||
(key) => | ||
encodeURIComponent(key) + "=" + encodeURIComponent(data[key]) | ||
) | ||
.join("&"); | ||
return Object.keys(data) | ||
.map((key) => encodeURIComponent(key) + "=" + encodeURIComponent(data[key])) | ||
.join("&"); | ||
} | ||
|
||
export function millisToMinutesAndSeconds(millis: number) { | ||
const minutes: number = Math.floor(millis / 60000); | ||
const seconds: number = parseInt(((millis % 60000) / 1000).toFixed(0)); | ||
if (minutes === 0) { | ||
return (seconds < 10 ? "0" : "") + seconds + "s"; | ||
} | ||
return minutes + "m:" + (seconds < 10 ? "0" : "") + seconds + "s"; | ||
const minutes: number = Math.floor(millis / 60000); | ||
const seconds: number = parseInt(((millis % 60000) / 1000).toFixed(0)); | ||
if (minutes === 0) { | ||
return (seconds < 10 ? "0" : "") + seconds + "s"; | ||
} | ||
return minutes + "m:" + (seconds < 10 ? "0" : "") + seconds + "s"; | ||
} | ||
|
||
export function millisToSeconds(millis: number) { | ||
return (millis / 1000).toFixed(0); | ||
return (millis / 1000).toFixed(0); | ||
} | ||
|
||
// Best effort / guessing to try to catch and indicate invalid / not found path | ||
export function isPath(str: string) { | ||
const pathRegex = /^[a-zA-Z0-9_\\/.]+$/; | ||
return Boolean(str.match(pathRegex)); | ||
} |