Vite + TypeScript PWA that mirrors the Android app's core features: - Pre-processed shelter data (build-time UTM33N→WGS84 conversion) - Leaflet map with shelter markers, user location, and offline tiles - Canvas compass arrow (ported from DirectionArrowView.kt) - IndexedDB shelter cache with 7-day staleness check - Service worker with CacheFirst tiles and precached app shell - i18n for en, nb, nn (ported from Android strings.xml) - iOS/Android compass handling with low-pass filter - Respects user map interaction (no auto-snap on pan/zoom) - Build revision cache-breaker for reliable SW updates Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
93 lines
No EOL
2.4 KiB
JavaScript
93 lines
No EOL
2.4 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = reflectAll;
|
|
|
|
var _reflect = require('./reflect.js');
|
|
|
|
var _reflect2 = _interopRequireDefault(_reflect);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* A helper function that wraps an array or an object of functions with `reflect`.
|
|
*
|
|
* @name reflectAll
|
|
* @static
|
|
* @memberOf module:Utils
|
|
* @method
|
|
* @see [async.reflect]{@link module:Utils.reflect}
|
|
* @category Util
|
|
* @param {Array|Object|Iterable} tasks - The collection of
|
|
* [async functions]{@link AsyncFunction} to wrap in `async.reflect`.
|
|
* @returns {Array} Returns an array of async functions, each wrapped in
|
|
* `async.reflect`
|
|
* @example
|
|
*
|
|
* let tasks = [
|
|
* function(callback) {
|
|
* setTimeout(function() {
|
|
* callback(null, 'one');
|
|
* }, 200);
|
|
* },
|
|
* function(callback) {
|
|
* // do some more stuff but error ...
|
|
* callback(new Error('bad stuff happened'));
|
|
* },
|
|
* function(callback) {
|
|
* setTimeout(function() {
|
|
* callback(null, 'two');
|
|
* }, 100);
|
|
* }
|
|
* ];
|
|
*
|
|
* async.parallel(async.reflectAll(tasks),
|
|
* // optional callback
|
|
* function(err, results) {
|
|
* // values
|
|
* // results[0].value = 'one'
|
|
* // results[1].error = Error('bad stuff happened')
|
|
* // results[2].value = 'two'
|
|
* });
|
|
*
|
|
* // an example using an object instead of an array
|
|
* let tasks = {
|
|
* one: function(callback) {
|
|
* setTimeout(function() {
|
|
* callback(null, 'one');
|
|
* }, 200);
|
|
* },
|
|
* two: function(callback) {
|
|
* callback('two');
|
|
* },
|
|
* three: function(callback) {
|
|
* setTimeout(function() {
|
|
* callback(null, 'three');
|
|
* }, 100);
|
|
* }
|
|
* };
|
|
*
|
|
* async.parallel(async.reflectAll(tasks),
|
|
* // optional callback
|
|
* function(err, results) {
|
|
* // values
|
|
* // results.one.value = 'one'
|
|
* // results.two.error = 'two'
|
|
* // results.three.value = 'three'
|
|
* });
|
|
*/
|
|
function reflectAll(tasks) {
|
|
var results;
|
|
if (Array.isArray(tasks)) {
|
|
results = tasks.map(_reflect2.default);
|
|
} else {
|
|
results = {};
|
|
Object.keys(tasks).forEach(key => {
|
|
results[key] = _reflect2.default.call(this, tasks[key]);
|
|
});
|
|
}
|
|
return results;
|
|
}
|
|
module.exports = exports.default; |