UNPKG

@gmod/nclist

Version:

Read features from JBrowse 1 format nested containment list JSON

23 lines 713 B
//@ts-nocheck import resolve from '@jridgewell/resolve-uri'; export async function readJSON(url, readFile, options = {}) { const { defaultContent = {} } = options; try { const str = await readFile(url, { encoding: 'utf8' }); const decoder = new TextDecoder('utf8'); return JSON.parse(decoder.decode(str)); } catch (error) { if (error.code === 'ENOENT' || error.status === 404 || error.message.includes('404') || error.message.includes('ENOENT')) { return defaultContent; } throw error; } } export function newURL(arg, base = '.') { return resolve(arg, base); } //# sourceMappingURL=util.js.map