No Proscribed Meaning

    local-search
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.2 • Public • Published

    local-search

    A package for DOM lookup and markup. Based on any input from the user (keyword/DOM selector), regular expressions are supported.

    • DOM search based on keywords or selectors.
    • Result mark(optional).

    Install

    $ yarn add local-search

    Usage

    Online demo here.

    // in react
    let search = new LocalSearch({ useRegexp: true });
    function App() {
      const [keywords, setKeywords] = useState("");
      useEffect(() => {
        search.setSearch(keywords);
      }, [keywords, search]);
      function handleClick() {
        search.begin().then(() => {
          search.next();
        });
      }
      function handleNext() {
        search.next();
      }
      return <div>...</div>;
    }

    API

    new LocalSearch(options: IOptions)

    export type KeywordsOrSelector = 
      | string
      | keyof HTMLElementTagNameMap
      | keyof SVGElementTagNameMap;
     
    interface IOption {
      input?: KeywordsOrSelector; // keywords or selector
      useRegexp?: boolean; // default: false
      scope?: HTMLElement | string; // rootDom, default: document.body
    }

    instance of const instance = new LocalSearch(options)

    export interface IDomFormated {
      dom: HTMLElement;
      type: typeof TypeSelector | typeof TypeText;
    }
    class LocalSearch {
      setSearch(input: KeywordsOrSelector): void; // set keywords
      begin(): Promise<IDomFormated[]> | undefined; // begin to search
      next(): boolean; // mark one search result, returns has next search result or not
    }

    ChangeLog

    see from CHANGELOG.md

    Install

    npm i local-search

    DownloadsWeekly Downloads

    1

    Version

    1.1.2

    License

    MIT

    Unpacked Size

    17.1 kB

    Total Files

    18

    Last publish

    Collaborators

    • limoer