/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails oncall+recoil * @flow strict-local * @format */ 'use strict'; import type { GetHandlers, NodeCacheRoute, NodeValueGet, SetHandlers, TreeCacheBranch, TreeCacheLeaf, TreeCacheNode } from './Recoil_TreeCacheImplementationType'; const nullthrows = require('recoil-shared/util/Recoil_nullthrows'); const recoverableViolation = require('recoil-shared/util/Recoil_recoverableViolation'); export type Options = { mapNodeValue?: (value: mixed) => mixed, onHit?: (node: TreeCacheLeaf) => void, onSet?: (node: TreeCacheLeaf) => void, }; declare class TreeCache { _numLeafs: number, _root: TreeCacheNode | null, _onHit: $NonMaybeType['onHit']>, _onSet: $NonMaybeType['onSet']>, _mapNodeValue: $NonMaybeType['mapNodeValue']>, constructor(options?: Options): any, size(): number, root(): TreeCacheNode | null, get(getNodeValue: NodeValueGet, handlers?: GetHandlers): ?T, getLeafNode(getNodeValue: NodeValueGet, handlers?: GetHandlers): ?TreeCacheLeaf, set(route: NodeCacheRoute, value: T, handlers?: SetHandlers): void, delete(node: TreeCacheNode): boolean, clear(): void, } declare var findLeaf: (root: ?TreeCacheNode, getNodeValue: NodeValueGet, handlers?: GetHandlers) => ?TreeCacheLeaf; declare var addLeaf: (root: ?TreeCacheNode, route: NodeCacheRoute, parent: ?TreeCacheBranch, value: T, branchKey: ?mixed, handlers?: SetHandlers, onAbort: () => void) => TreeCacheNode; declare var pruneNodeFromTree: (root: TreeCacheNode, node: TreeCacheNode, parent: ?TreeCacheBranch) => boolean; declare var pruneUpstreamBranches: (root: TreeCacheNode, branchNode: TreeCacheBranch, parent: ?TreeCacheBranch) => boolean; declare var countDownstreamLeaves: (node: TreeCacheNode) => number; module.exports = { TreeCache };