spark.existsLocal
function existsLocal(key: string): Promise<boolean>Check if a key exists in local browser storage (IndexedDB).
Efficiently checks for existence without loading the data. Useful before loading large amounts of data.
Parameters
keystring- Key to check
Returns
Promise<boolean>– Promise resolving to true if key exists, false otherwiseExamples
// Check before loading
if (await spark.existsLocal('best-model')) {
const weights = await spark.loadLocal('best-model');
model.load_state_dict(torch.deserialize(weights));
} else {
console.log('No checkpoint found, starting fresh');
}