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

arc-resolver

v3.0.0

Published

<a href="https://www.ebay.com"> <img src="https://img.shields.io/badge/ebay-open%20source-01d5c2.svg" alt="ebay open source"/> </a> <a href="https://img.shields.io/github/license/eBay/arc.svg"> <img src="https://img.shields.io/github/license/eBay/ar

Downloads

19

Readme

arc-resolver

API

new Resolver(fs)

import Resolver from 'arc-resolver';
  • fs (optional): a filesystem that conforms to the node.js fs api. Defaults to the built-in fs module

Instance methods

  • clearCache()
  • getMatchesSync(path)
  • getDirMatchesSync(dir, request)
  • resolveSync(path, flags)
  • isAdaptiveSync(path)

new MatchSet(matches) an iterable

import { MatchSet } from 'arc-resolver';
  • matches (required): an Array of Objects with the keys flags and value:
    • flags: an Array of strings representing the required flags for the value
    • value: any value to associate with the flags

Properties

  • count: the number of possible matches
  • default: the default value (the least specific, the one with no flags)

Methods

  • match(flags): return the matching value for a flagset
    • flags: an Object where each key represents a flag and the value is a boolean indicating whether that flag is active

Defining flags

arc adapts files based on a filenaming convension:

style.css
style[android].css

How it works

Write your application as though the flagged version of the file did not exist:

@import url('./style.css');

When bundling the css (using arc-webpack or arc-lasso), if the android flag is set, style[android].css will replace style.css in the output bundle.

Multiple flags

Require all flags (AND)

Use the plus (+) to specify that all of the listed flags need to match:

style[mobile+android].css

Require any flag (OR)

Use the comma (,) to specify that one of the listed flags needs to match:

style[android,ios].css

Combining flag logic

The plus (+) has higher precedence than the comma (,), similar to how && has higher precedence than || in JavaScript.

For example,

style[mobile+ios,mobile+android].css

Is logically equivalent to:

(mobile && ios) || (mobile && android)
Subgroups of flags

To increase the precedence of a group, you can wrap it in []:

style[mobile+[ios,android]].css

This is logically equivalent to the previous example.

Specificity

More Flags === Higher Specificity

Given the following files:

style.css
style[mobile,tablet,headset,desktop].css
style[mobile+[ios,android]].css
style[mobile+ios+chrome,safari].css

The matching logic looks something like:

if mobile & ios & chrome
  'style[mobile+ios+chrome,safari].css'

else if mobile & ios
  'style[mobile+[ios,android]].css'

else if mobile & android
  'style[mobile+[ios,android]].css'

else if safari
  'style[mobile+ios+chrome,safari].css'

else if mobile
  'style[mobile,tablet,headset,desktop].css'

else if tablet
  'style[mobile,tablet,headset,desktop].css'

else if headset
  'style[mobile,tablet,headset,desktop].css'

else if desktop
  'style[mobile,tablet,headset,desktop].css'

else
  'style.css'