mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
Don't use a util function for a thing that exists 1x in the code
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { utilFetchJson } from '../util/util';
|
||||
import parseVersion from 'vparse';
|
||||
// Double check this resolves to iD's `package.json`
|
||||
import packageJSON from '../../package.json';
|
||||
@@ -60,7 +59,15 @@ export function coreFileFetcher() {
|
||||
|
||||
let prom = _inflight[url];
|
||||
if (!prom) {
|
||||
_inflight[url] = prom = utilFetchJson(url)
|
||||
_inflight[url] = prom = fetch(url)
|
||||
.then(response => {
|
||||
// fetch in PhantomJS tests may return ok=false and status=0 even if it's okay
|
||||
if ((!response.ok && response.status !== 0) || !response.json) {
|
||||
throw new Error(response.status + ' ' + response.statusText);
|
||||
}
|
||||
if (response.status === 204 || response.status === 205) return; // No Content, Reset Content
|
||||
return response.json();
|
||||
})
|
||||
.then(result => {
|
||||
delete _inflight[url];
|
||||
if (!result) {
|
||||
|
||||
@@ -27,7 +27,6 @@ export { utilEntityOrMemberSelector } from './util';
|
||||
export { utilEntityOrDeepMemberSelector } from './util';
|
||||
export { utilEntitySelector } from './util';
|
||||
export { utilFastMouse } from './util';
|
||||
export { utilFetchJson } from './util';
|
||||
export { utilFunctor } from './util';
|
||||
export { utilGetAllNodes } from './util';
|
||||
export { utilGetSetValue } from './get_set_value';
|
||||
|
||||
@@ -580,14 +580,3 @@ export function utilUnicodeCharsCount(str) {
|
||||
export function utilUnicodeCharsTruncated(str, limit) {
|
||||
return Array.from(str).slice(0, limit).join('');
|
||||
}
|
||||
|
||||
// Variation of d3.json (https://github.com/d3/d3-fetch/blob/master/src/json.js)
|
||||
export function utilFetchJson(resourse, init) {
|
||||
return fetch(resourse, init)
|
||||
.then((response) => {
|
||||
// fetch in PhantomJS tests may return ok=false and status=0 even if it's okay
|
||||
if ((!response.ok && response.status !== 0) || !response.json) throw new Error(response.status + ' ' + response.statusText);
|
||||
if (response.status === 204 || response.status === 205) return;
|
||||
return response.json();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user