Skip to content

iterateCacheRefs

Official

Iterate links and embeds. If callback returns true, the iteration process will be interrupted.

Import:

import { iterateCacheRefs } from 'obsidian';

Example:

iterateCacheRefs(cache, (ref) => {
console.log(ref);
return true;
});
**Signature:**
```ts
function iterateCacheRefs(cache: CachedMetadata, cb: (ref: ReferenceCache) => boolean | void): boolean

Parameters:

ParameterTypeDescription
cacheCachedMetadataThe cache to iterate.
cb(ref: ReferenceCache) => boolean | voidThe callback to call for each link or embed.

Returns: booleantrue if callback ever returns true, false otherwise.

Example:

iterateCacheRefs(cache, (ref) => {
console.log(ref);
return true;
});