16 lines
322 B
TypeScript
16 lines
322 B
TypeScript
import { readFileSync } from 'fs';
|
|
import axios from 'axios';
|
|
|
|
export const readOrFetch = async (path: string) => {
|
|
if (path.indexOf('http') === 0) {
|
|
return (
|
|
await axios({
|
|
url: path,
|
|
method: 'GET',
|
|
responseType: 'arraybuffer',
|
|
})
|
|
).data;
|
|
}
|
|
|
|
return readFileSync(path);
|
|
};
|