npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

obsidian-search

v0.1.1

Published

The (unofficial) API for Obsidian.md searching functionality.

Downloads

8

Readme

obsidian-search

The (unofficial) API for Obsidian.md searching functionality.

Obsidian does not provide an API for using it's search functionality, forcing developers to either build their own - with limited features, depend on something like dataview, or perform a gross hack in which we query the DOM of the search plugin. NO MORE

This library provides a parse function to convert a query string into a FileFilter, a search function to directly query the app from a given query, and direct access to the corresponding FileFilters.

How to use

This library is still in ALPHA due to limited test coverage. Use at your own risk!

Install

# Using npm
npm install obsidian-search

# Using yarn
yarn add obsidian-search

Search

import { search } from 'obsidian-search'

const asyncResults = search(`file:filename OR path:sub/folder OR [has property:with value]`, app) // the App made available to your plugin
for await (const file of asyncResults) {
    // do something with the file
}

Of course, the query provided could be a string that your users passed into an input somewhere.

Parse

If you need more direct access to the file filters for finer control over when and how you filter for files, you may also use the parse function:

import { parse } from 'obsidian-search'

const filter = parse(`file:filename OR path:sub/folder OR [has property:with value]`, app.metadataCache) // the App made available to your plugin

const files = app.value.getMarkdownFiles();

for (const file of files) {
    if (await filter.appliesTo(file)) {
        // do something with the file
    }
}

Contributing

Thank you for considering contributing to the obsidian-search library! Contributions are welcome and encouraged.

Bug Reports and Feature Requests

If you find a bug or have a feature request, please open an issue on the issue tracker. When creating an issue, provide as much detail as possible, including steps to reproduce for bugs.

Pull Requests

If you would like to contribute directly to the codebase, you can follow these steps to submit a pull request:

  1. Fork the repository.

  2. Create a new branch for your feature or bug fix:

    git checkout -b feature-name
  3. Write new tests for your changes if applicable.

  4. Run the tests to ensure nothing broke (and your changes work):

    npm run test:unit
  5. Commit your changes:

    git commit -m "Add your commit message here"
  6. Push your branch to your fork:

    git push origin feature-name
  7. Open a new Pull Request from the feature branch in your fork