Rust backend: SQLite (WAL mode, 8 tables), vault encryption (Argon2id + AES-256-GCM), settings/connections/credentials services, 19 Tauri command wrappers. 46/46 tests passing. Vue 3 frontend: unlock/create vault flow, Pinia app store, Tailwind CSS v4 dark theme with Wraith branding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
711 B
JavaScript
38 lines
711 B
JavaScript
/*
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
Author Tobias Koppers @sokra
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* @template T
|
|
* @typedef {() => T} FunctionReturning
|
|
*/
|
|
|
|
/**
|
|
* @template T
|
|
* @param {FunctionReturning<T>} fn memorized function
|
|
* @returns {FunctionReturning<T>} new function
|
|
*/
|
|
const memoize = (fn) => {
|
|
let cache = false;
|
|
/** @type {T | undefined} */
|
|
let result;
|
|
return () => {
|
|
if (cache) {
|
|
return /** @type {T} */ (result);
|
|
}
|
|
|
|
result = fn();
|
|
cache = true;
|
|
// Allow to clean up memory for fn
|
|
// and all dependent resources
|
|
/** @type {FunctionReturning<T> | undefined} */
|
|
(fn) = undefined;
|
|
return /** @type {T} */ (result);
|
|
};
|
|
};
|
|
|
|
module.exports = memoize;
|