avoid json errors in firefox
This commit is contained in:
parent
af52ac30ba
commit
0a349e1707
3 changed files with 17 additions and 7 deletions
|
|
@ -52,6 +52,15 @@ export async function initCode() {
|
|||
}
|
||||
}
|
||||
|
||||
export const parseJSON = (json) => {
|
||||
json = json != null && json.length ? json : '{}';
|
||||
try {
|
||||
return JSON.parse(json);
|
||||
} catch {
|
||||
return '{}';
|
||||
}
|
||||
};
|
||||
|
||||
export function getRandomTune() {
|
||||
const allTunes = Object.entries(stockPatterns);
|
||||
const randomItem = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue