Registry / storage / tile-cache

tile-cache

JSON →
library3.0.0jsnpmunverified

Client-side slippy tile cache for map tiles, fonts, JSON styles, and sprites. Version 3.0.0 is the current stable release with an irregular release cadence. Provides simple store-based API (put, get, check, remove, drop) using IndexedDB or LevelDB. Lightweight alternative to tilelive-cache or Leaflet tile layers, focused on offline caching. Supports Blob/ArrayBuffer storage with key format [x, y, zoom].

npm install tile-cache
INSTALL
IMPORT
SIG · TILE-CACHE
T
tile-cache
storagejavascriptv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tileCache
✓ import tileCache from 'tile-cache'
✗ const { tileCache } = require('tile-cache')
Default import in ESM; CommonJS uses require('tile-cache').
tileCache
✓ const tileCache = require('tile-cache')
CJS require returns the module directly.
types
✓ import type { TileCache } from 'tile-cache'
TypeScript users can import types if available; not documented.

Demonstrates all basic operations on the tile store: put, get, check, remove, and drop.

const tileCache = require('tile-cache'); async function example() { const key = [0, 3, 5]; // [x, y, zoom] const tile = new ArrayBuffer(16); // example tile data await tileCache.put('tile', key, tile); console.log('Tile saved'); const retrieved = await tileCache.get('tile', key); console.log('Tile retrieved:', retrieved); const inCache = await tileCache.check('tile', key); console.log('In cache:', inCache); await tileCache.remove('tile', key); console.log('Tile removed'); await tileCache.drop('tile'); console.log('Store dropped'); } example().catch(console.error);
Debug
Known issues
breakingVersion 3.0.0 changed the API from callbacks to promises. Old style callbacks are no longer supported.
fix
Use async/await or .then() for all operations.
affects: >=3.0.0 <4.0.0
gotchaKeys must be arrays of three numbers [x, y, zoom]; other formats may silently fail.
fix
Always provide an array of three integers.
affects: >=3.0.0
gotchaStores are persistent across page loads via IndexedDB; data is not automatically cleared.
fix
Call tileCache.drop('store') to clear a store when needed.
affects: >=3.0.0
deprecatedThe 'json' store type may be deprecated in future versions; prefer storing JSON via other means.
fix
Use localStorage or dedicated JSON caching library for styles.
affects: >=3.0.0
Errors
Common errors & fixes
Error: store name must be one of: tile, font, json, image
Provided an invalid or misspelled store name.
fix
Use one of the allowed stores: 'tile', 'font', 'json', 'image'.
TypeError: key must be an array of 3 numbers
Key provided as a string or array of wrong dimensions.
fix
Pass key as an array like [0, 3, 5].
tileCache.put is not a function
Importing via destructuring when default import is needed.
fix
Use `import tileCache from 'tile-cache'` or `const tileCache = require('tile-cache')`.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
tile-cache — npm install tile-cache · libregistry