PageSourceSearch

https://hydrantmap.org/assets/requests.js

js hydrantmap.org collected 2026-10-04 17:16:41 UTC 965 bytes, 22 lines download raw bytes

1(function () {
2  'use strict';
3  const writes = new Map();
4  const requestKey = () => crypto.randomUUID?.() || [...crypto.getRandomValues(new Uint8Array(16))].map(value => value.toString(16).padStart(2, '0')).join('');
5  async function request(path, options = {}) {
6    const isWrite = options.method === 'POST' && path.startsWith('/api/osm/') && !path.endsWith('/can-move');
7    const signature = path + '\n' + String(options.body || '');
8    if (isWrite) {
9      if (!writes.has(signature)) writes.set(signature, requestKey());
10      options = { ...options, headers: { ...options.headers, 'X-Idempotency-Key': writes.get(signature) } };
11    }
12    try {
13      const response = await fetch(path, options);
14      return response;
15    } catch (error) {
16      error.network = true;
17      error.code = isWrite ? 'osm_write_unconfirmed' : 'network_error';
18      throw error;
19    }
20  }
21  window.HMRequests = Object.freeze({ request, reset: () => writes.clear() });
22})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.