Interface Cache

A cache that functions may use to store results.

A cache implements the ReadonlyFlags interface. All functions that take a ReadonlyFlags objects can be given a cache instead to utilize the cache. Example:

const flags: ReadonlyFlags = getFlags();
const cache = toCache(flags);

toCharSet(element, flags); // uncached
toCharSet(element, cache); // cached

Whether the cache is actually utilized depends on the implementation of the function.

To get a cache for some flags, use the toCache function.

Assumption

Caches assume that the regexpp AST of cached nodes is immutable. If this assumption is broken, then the cache may return old or incorrect results.

The AST may be changed before the cache first sees a node of the AST and after the cached last sees a node of the AST. Changes are allowed as long as the AST appears to be immutable from the perspective of the cache.

Memory

The cache uses regexpp Node objects as keys in WeakMaps internally. They will not cause memory leaks.

This means that caches may out-live the nodes they cache information for.

Hierarchy

Properties

__cache?: undefined
dotAll: boolean

The s flag.

Default

false
global: boolean

The g flag.

Default

false
hasIndices: boolean

The d flag.

Default

false
ignoreCase: boolean

The i flag.

Default

false
multiline: boolean

The m flag.

Default

false
sticky: boolean

The y flag.

Default

false
unicode: boolean

The u flag.

Default

false
unicodeSets: boolean

The v flag.

Default

false