UNPKG

@wordpress/data

Version:
8 lines (7 loc) 1.5 kB
{ "version": 3, "sources": ["../src/create-selector.ts"], "sourcesContent": ["/**\n * External dependencies\n */\nimport memoize from 'rememo';\n\n/**\n * Returns the array of immutable references on which a memoized selector\n * depends for computing its result. The memoize cache is preserved only as\n * long as those dependant references remain the same.\n */\nexport type GetDependants = ( ...args: any[] ) => any[];\n\n/**\n * The memoization methods a selector returned by `createSelector` is\n * enhanced with.\n */\nexport interface EnhancedSelector {\n\tgetDependants: GetDependants;\n\n\t/**\n\t * Clears the memoization cache.\n\t */\n\tclear: () => void;\n}\n\n/*\n * The signature mirrors `rememo`'s, but is declared here so that consumers'\n * emitted declarations reference `@wordpress/data` rather than `rememo`,\n * which they do not declare as a dependency.\n */\n\n/**\n * Creates a memoized selector that caches the computed values according to the array of \"dependants\"\n * and the selector parameters, and recomputes the values only when any of them changes.\n *\n * See The documentation for the `rememo` package from which the `createSelector` function is reexported.\n */\nexport const createSelector: < S extends ( ...args: any[] ) => any >(\n\tselector: S,\n\tgetDependants?: GetDependants\n) => S & EnhancedSelector = memoize;\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAoB;AAkCb,IAAM,iBAGe,cAAAA;", "names": ["memoize"] }