Skip to main content
torch.js has not been released yet.
torch.js logotorch.js logotorch.js
PlaygroundContact
Login
Documentation
IntroductionType SafetyTensor ExpressionsTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformancePyTorch CompatibilityBenchmarksDType Coverage
torch.js· 2026
LegalTerms of UsePrivacy Policy
/
/
  1. docs
  2. Spark
  3. spark
  4. existsLocal

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 otherwise

Examples

// 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');
}

See Also

  • loadLocal - Load data
  • listLocal - List all keys
Previous
exists
Next
getBaseUrl