Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { data } = await httpRequest({
getState,
method: 'GET',
url: '//api.openstreetmap.org/api/0.6/changesets',
expectedStatus: [200, 404],
params: {
bbox,
time: fromTime + (toTime0 ? `,${toTime0}` : ''),
// eslint-disable-next-line
display_name: state.changesets.authorName,
},
cancelActions: [changesetsSetAuthorName, selectFeature, clearMap],
});
const xml = new DOMParser().parseFromString(
assertType(data),
'text/xml',
);
const rawChangesets = xml.getElementsByTagName('changeset');
const arrayOfrawChangesets = Array.from(rawChangesets);
const changesetsFromThisRequest = arrayOfrawChangesets
.map(rawChangeset => {
const minLat = parseFloat(rawChangeset.getAttribute('min_lat') ?? '');
const maxLat = parseFloat(rawChangeset.getAttribute('max_lat') ?? '');
const minLon = parseFloat(rawChangeset.getAttribute('min_lon') ?? '');
const maxLon = parseFloat(rawChangeset.getAttribute('max_lon') ?? '');
const descriptionTag = Array.from(
rawChangeset.getElementsByTagName('tag'),
).find(tag => tag.getAttribute('k') === 'comment');
function loadAppState(): void {
let appState: AppState | undefined;
const as = storage.getItem('appState');
if (as) {
try {
appState = assertType(JSON.parse(as));
} catch (e) {
storage.removeItem('appState');
throw e;
}
}
if (appState) {
store.dispatch(setAppState(appState));
}
store.dispatch(
l10nSetChosenLanguage(
appState?.language?.replace(/-.*/, '') ?? null, // fixing wrong saved language because of bug in older version
),
);
}
transform: ({ action }) => {
if (!action.payload.trackGpx) {
return action;
}
// TODO add error handling for failed string-to-gpx and gpx-to-geojson parsing
const gpxAsXml = new DOMParser().parseFromString(
action.payload.trackGpx,
'text/xml',
);
const trackGeojson = assertType(toGeoJSON.gpx(gpxAsXml));
const startPoints: TrackPoint[] = []; // TODO
const finishPoints: TrackPoint[] = []; // TODO
for (const feature of trackGeojson.features) {
if (feature.geometry.type === 'LineString') {
const lengthInKm = turfLength(feature);
const coords = feature.geometry.coordinates;
const startLonlat = coords[0];
let startTime: Date | undefined;
let finishTime: Date | undefined;
const times = assertType(
feature.properties && feature.properties.coordTimes,
);
if (times) {
startTime = new Date(times[0]);
item: V;
}
interface Baz {
buz: W;
}
interface Foo extends Bar<u>, Baz {
type: 'cool';
secondItem: T;
thirdItem: Bar>;
}
console.log(is, string>>({}));
console.log(is, string>>({ item: 'string', buz: 1, type: 'cool', secondItem: { item: 2 }, thirdItem: { item: { item: true } } }));
console.log(is(true));
console.log(is(false));
</u>
}
interface Baz {
buz: W;
}
interface Foo extends Bar<u>, Baz {
type: 'cool';
secondItem: T;
thirdItem: Bar>;
}
console.log(is, string>>({}));
console.log(is, string>>({ item: 'string', buz: 1, type: 'cool', secondItem: { item: 2 }, thirdItem: { item: { item: true } } }));
console.log(is(true));
console.log(is(false));
</u>
interface Bar /*extends Pick*/ {
item: V;
}
interface Baz {
buz: W;
}
interface Foo extends Bar<u>, Baz {
type: 'cool';
secondItem: T;
thirdItem: Bar>;
}
console.log(is, string>>({}));
console.log(is, string>>({ item: 'string', buz: 1, type: 'cool', secondItem: { item: 2 }, thirdItem: { item: { item: true } } }));
console.log(is(true));
console.log(is(false));
</u>
handle: async ({ getState, dispatch }) => {
const { data } = await httpRequest({
getState,
method: 'GET',
url: '/gallery/picture-users',
expectedStatus: 200,
});
dispatch(gallerySetUsers(assertType(data)));
},
};
if (response.status !== 'connected') {
dispatch(toastsAddError('logIn.logInError2'));
return;
}
}
const { data } = await httpRequest({
getState,
method: 'POST',
url: `/auth/login-fb`,
cancelActions: [],
expectedStatus: 200,
data: { accessToken: response.authResponse.accessToken },
});
const user = assertType(data);
dispatch(
toastsAdd({
collapseKey: 'login',
messageKey: 'logIn.success',
style: 'info',
timeout: 5000,
}),
);
dispatch(authSetUser(user));
},
};
function toLatLon(
coord1deg: number,
coord1min: number,
coord1sec: number,
card1: string,
coord2deg: number,
coord2min: number,
coord2sec: number,
card2: string,
): LatLon {
const latLon = {
...toLatLon1(coord1deg, coord1min, coord1sec, card1),
...toLatLon1(coord2deg, coord2min, coord2sec, card2),
};
return assertType(latLon);
}
export function parseCoordinates(coord: string): LatLon {
const mXml = P_XML.exec(coord);
if (mXml) {
return assertType({
...toLatLon1(parseFloat(mXml[1].replace(',', '.')), 0.0, 0.0, 'N'),
...toLatLon1(parseFloat(mXml[2].replace(',', '.')), 0.0, 0.0, 'E'),
});
}
const sb: string[] = [];
const list: Array = [];
const P = new RegExp(patterns, 'ig');
for (let i = 0; i < 100; i += 1) {
const m = P.exec(coord);
if (!m) {
break;
}