---
title: "default | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Class default<KeyType, ValueType>

#### Type Parameters

-   KeyType
-   ValueType

#### Hierarchy

-   Map<[KeyType](#keytype), [ValueType](#valuetype)\>
    -   default

#### Implements

-   [Iterable](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Iterable/)<\[[KeyType](#keytype), [ValueType](#valuetype)\]\>

##### Index

### Constructors[](#constructors)

[constructor](#constructor)

### Properties[](#properties)

[\[toStringTag\]](#tostringtag) [\[species\]](#species)

### Accessors[](#accessors)

[maxAge](#maxage) [maxSize](#maxsize) [size](#size)

### Methods[](#methods)

[\[iterator\]](#iterator) [clear](#clear) [delete](#delete) [entries](#entries) [entriesAscending](#entriesascending) [entriesDescending](#entriesdescending) [evict](#evict) [expiresIn](#expiresin) [forEach](#foreach) [get](#get) [has](#has) [keys](#keys) [peek](#peek) [resize](#resize) [set](#set) [values](#values)

## Constructors[](#constructors-1)

### constructor[](#constructor)

-   new default<[KeyType](#constructordefaultkeytype), [ValueType](#constructordefaultvaluetype)\>(  
        options: [Options](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Options/)<[KeyType](#keytype), [ValueType](#valuetype)\>,  
    ): default<[KeyType](#keytype), [ValueType](#valuetype)\>[](#constructordefault)
    
    Simple ["Least Recently Used" (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29).
    
    The instance is an [`Iterable`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols) of `[key, value]` pairs so you can use it directly in a [`for…of`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/for...of) loop.
    
    #### Type Parameters
    
    -   KeyType
    -   ValueType
    
    #### Parameters
    
    -   options: [Options](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Options/)<[KeyType](#keytype), [ValueType](#valuetype)\>
    
    #### Returns default<[KeyType](#keytype), [ValueType](#valuetype)\>
    
    #### Example[](#example)
    
    ```typescript
    import QuickLRU from 'quick-lru';
    
    const lru = new QuickLRU({maxSize: 1000});
    
    lru.set('🦄', '🌈');
    
    lru.has('🦄');
    //=> true
    
    lru.get('🦄');
    //=> '🌈'
    ```
    
    Overrides Map<KeyType, ValueType>.constructor
    

## Properties[](#properties-1)

### `Readonly`\[toStringTag\][](#tostringtag)

"\[toStringTag\]": string

Inherited from Map.\[toStringTag\]

### `Static` `Readonly`\[species\][](#species)

"\[species\]": MapConstructor

Inherited from Map.\[species\]

## Accessors[](#accessors-1)

### maxAge[](#maxage)

-   get maxAge(): number
    
    The set max age.
    
    #### Returns number
    

### maxSize[](#maxsize)

-   get maxSize(): number
    
    The set max size.
    
    #### Returns number
    

### size[](#size)

-   get size(): number
    
    The stored item count.
    
    #### Returns number
    
    Overrides Map.size
    

## Methods[](#methods-1)

### \[iterator\][](#iterator)

-   "\[iterator\]"(): [IterableIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IterableIterator/)<\[[KeyType](#keytype), [ValueType](#valuetype)\]\>[](#iterator-1)
    
    #### Returns [IterableIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IterableIterator/)<\[[KeyType](#keytype), [ValueType](#valuetype)\]\>
    
    Implementation of [Iterable](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Iterable/).[\[iterator\]](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Iterable/#iterator)
    
    Overrides Map.\[iterator\]
    

### clear[](#clear)

-   clear(): void[](#clear-1)
    
    Delete all items.
    
    #### Returns void
    
    Overrides Map.clear
    

### delete[](#delete)

-   delete(key: [KeyType](#keytype)): boolean[](#delete-1)
    
    Delete an item.
    
    #### Parameters
    
    -   key: [KeyType](#keytype)
    
    #### Returns boolean
    
    `true` if the item is removed or `false` if the item doesn't exist.
    
    Overrides Map.delete
    

### entries[](#entries)

-   entries(): [MapIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.MapIterator/)<\[[KeyType](#keytype), [ValueType](#valuetype)\]\>[](#entries-1)
    
    Returns an iterable of key, value pairs for every entry in the map.
    
    #### Returns [MapIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.MapIterator/)<\[[KeyType](#keytype), [ValueType](#valuetype)\]\>
    
    Inherited from Map.entries
    

### entriesAscending[](#entriesascending)

-   entriesAscending(): [IterableIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IterableIterator/)<\[[KeyType](#keytype), [ValueType](#valuetype)\]\>[](#entriesascending-1)
    
    Iterable for all entries, starting with the oldest (ascending in recency).
    
    #### Returns [IterableIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IterableIterator/)<\[[KeyType](#keytype), [ValueType](#valuetype)\]\>
    

### entriesDescending[](#entriesdescending)

-   entriesDescending(): [IterableIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IterableIterator/)<\[[KeyType](#keytype), [ValueType](#valuetype)\]\>[](#entriesdescending-1)
    
    Iterable for all entries, starting with the newest (descending in recency).
    
    #### Returns [IterableIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IterableIterator/)<\[[KeyType](#keytype), [ValueType](#valuetype)\]\>
    

### evict[](#evict)

-   evict(count?: number): void[](#evict-1)
    
    Evict the least recently used items from the cache.
    
    #### Parameters
    
    -   `Optional`count: number
        
        The number of items to evict. Defaults to 1.
        
        It will always keep at least one item in the cache.
        
    
    #### Returns void
    
    #### Example[](#example-1)
    
    ```typescript
    import QuickLRU from 'quick-lru';
    
    const lru = new QuickLRU({maxSize: 10});
    
    lru.set('a', 1);
    lru.set('b', 2);
    lru.set('c', 3);
    
    lru.evict(2); // Evicts 'a' and 'b'
    
    console.log(lru.has('a'));
    //=> false
    
    console.log(lru.has('c'));
    //=> true
    ```
    

### expiresIn[](#expiresin)

-   expiresIn(key: [KeyType](#keytype)): number | undefined[](#expiresin-1)
    
    Get the remaining time to live (in milliseconds) for the given item, or `undefined` when the item is not in the cache.
    
    -   Does not mark the item as recently used.
    -   Does not trigger lazy expiration or remove the entry when it is expired.
    -   Returns `Infinity` if the item has no expiration.
    -   May return a negative number if the item is already expired but not yet lazily removed.
    
    #### Parameters
    
    -   key: [KeyType](#keytype)
    
    #### Returns number | undefined
    
    Remaining time to live in milliseconds when set, `Infinity` when there is no expiration, or `undefined` when the item does not exist.
    

### forEach[](#foreach)

-   forEach(  
        callbackfn: (  
            value: [ValueType](#valuetype),  
            key: [KeyType](#keytype),  
            map: Map<[KeyType](#keytype), [ValueType](#valuetype)\>,  
        ) \=> void,  
        thisArg?: any,  
    ): void[](#foreach-1)
    
    Executes a provided function once per each key/value pair in the Map, in insertion order.
    
    #### Parameters
    
    -   callbackfn: (value: [ValueType](#valuetype), key: [KeyType](#keytype), map: Map<[KeyType](#keytype), [ValueType](#valuetype)\>) \=> void
    -   `Optional`thisArg: any
    
    #### Returns void
    
    Inherited from Map.forEach
    

### get[](#get)

-   get(key: [KeyType](#keytype)): [ValueType](#valuetype) | undefined[](#get-1)
    
    Get an item.
    
    #### Parameters
    
    -   key: [KeyType](#keytype)
    
    #### Returns [ValueType](#valuetype) | undefined
    
    The stored item or `undefined`.
    
    Overrides Map.get
    

### has[](#has)

-   has(key: [KeyType](#keytype)): boolean[](#has-1)
    
    Check if an item exists.
    
    #### Parameters
    
    -   key: [KeyType](#keytype)
    
    #### Returns boolean
    
    Overrides Map.has
    

### keys[](#keys)

-   keys(): [IterableIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IterableIterator/)<[KeyType](#keytype)\>[](#keys-1)
    
    Iterable for all the keys.
    
    #### Returns [IterableIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IterableIterator/)<[KeyType](#keytype)\>
    
    Overrides Map.keys
    

### peek[](#peek)

-   peek(key: [KeyType](#keytype)): [ValueType](#valuetype) | undefined[](#peek-1)
    
    Get an item without marking it as recently used.
    
    #### Parameters
    
    -   key: [KeyType](#keytype)
    
    #### Returns [ValueType](#valuetype) | undefined
    
    The stored item or `undefined`.
    

### resize[](#resize)

-   resize(maxSize: number): void[](#resize-1)
    
    Update the `maxSize` in-place, discarding items as necessary. Insertion order is mostly preserved, though this is not a strong guarantee.
    
    Useful for on-the-fly tuning of cache sizes in live systems.
    
    #### Parameters
    
    -   maxSize: number
    
    #### Returns void
    

### set[](#set)

-   set(key: [KeyType](#keytype), value: [ValueType](#valuetype), options?: { maxAge?: number }): this[](#set-1)
    
    Set an item. Returns the instance.
    
    Individual expiration of an item can be specified with the `maxAge` option. If not specified, the global `maxAge` value will be used in case it is specified in the constructor; otherwise the item will never expire.
    
    #### Parameters
    
    -   key: [KeyType](#keytype)
    -   value: [ValueType](#valuetype)
    -   `Optional`options: { maxAge?: number }
    
    #### Returns this
    
    The cache instance.
    
    Overrides Map.set
    

### values[](#values)

-   values(): [IterableIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IterableIterator/)<[ValueType](#valuetype)\>[](#values-1)
    
    Iterable for all the values.
    
    #### Returns [IterableIterator](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IterableIterator/)<[ValueType](#valuetype)\>
    
    Overrides Map.values
