UNPKG

@3mo/command-palette

Version:

Command-palettes are a common way to provide users with a list of actions they can perform in a given context.

25 lines (24 loc) 809 B
import { __decorate } from "tslib"; import { Memoize as memoize } from 'typescript-memoize'; export class CommandPaletteDataSource { constructor() { this.take = CommandPaletteDataSource.take; this.id = Math.random().toString(36).substring(7); this.order = Number.MAX_SAFE_INTEGER; } async fetchData() { const results = await this.fetch(); return results.map(result => this.getItem(result)); } async searchData(keyword) { const results = await this.search(keyword); return results.map(result => this.getItem(result)); } } CommandPaletteDataSource.take = 5; __decorate([ memoize() ], CommandPaletteDataSource.prototype, "fetchData", null); __decorate([ memoize() ], CommandPaletteDataSource.prototype, "searchData", null);