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

rescript-anymatch

v0.1.0

Published

ReScript bindings for anymatch

Downloads

16

Readme

rescript-anymatch

ReScript bindings for anymatch

Installation

npm i rescript-anymatch

In your bsconfig.json add it to bs-dependencies

{
  ...,
  "bs-dependencies": [..., "rescript-anymatch"],
}

Examples

let matchers = [
  Anymatch.path("path/to/file.js"),
  Anymatch.glob("path/anyjs/**/*.js"),
  Anymatch.regex(%re("/foo.js$/")),
  Anymatch.fun(s => s->Js.String2.includes("bar") && s->Js.String2.length > 10),
]

Anymatch.anymatch(matchers, "path/to/file.js")->Js.log // true
Anymatch.anymatch(matchers, "path/anyjs/baz.js")->Js.log // true
Anymatch.anymatch(matchers, "path/to/foo.js")->Js.log // true
Anymatch.anymatch(matchers, "path/to/bar.js")->Js.log // true
Anymatch.anymatch(matchers, "bar.js")->Js.log // false

Anymatch.anymatchIndex(matchers, "foo.js")->Js.log // 2
Anymatch.anymatchIndex(matchers, "path/anyjs/foo.js")->Js.log // 1

// currying

let match = Anymatch.anymatch(matchers)
match("path/to/file.js")->Js.log // true

// options

Anymatch.anymatch(~options=Picomatch.options(~dot=true, ()), matchers, "path/anyjs/.baz.js")->Js.log // true

Caveats

The original library can accept an array instead of a string as a match target. Here what it does in that case:

If passed as an array, the first element of the array will be used as the testString for non-function matchers, while the entire array will be applied as the arguments for function matchers.

This is difficult to define with ReScript. If you need this feature open an issue and let's discuss the options.


With the original library you can create a match function const match = anymatch(matchers) and then at the call time of that functions decide whether you want index or boolean as the return value. With these bindings you'll have to create two separate functions.

I didn't find a good way to support this edge-case without making normal use more difficult.