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

glob-resolve

v1.0.5

Published

resolves a glob filename array into it's segments and transforms it into a new array.

Downloads

14

Readme

glob-resolve

resolves a glob filename array into it's segments and transforms it into a new array.

why?

use it when you want to transform the glob filename Array.

how does it work?

  • it uses glob with variables. see: glob-var
  • you can use the whole glob syntax in the src and dest pattern, as well as the glob-var variables starting with a colon :
  • instead of the glob filename Array, glob-resolve returns a search object with:
    • src: glob-var object for the source pattern
    • dest: glob-var object for the destination pattern
  • you are most likely interrested in the result.dest.path Array, which is the transformed glob filenames Array.

install

npm install glob-resolve

use


var resolve = require('glob-resolve');

// async
var src = __dirname + '/fixtures/:module/public/**';
var dest = __dirname + '/public/:module/**';
resolve(src, dest, function(err, result) {
    // result.dest.path is the transformed files array
    console.log('destination files array', result.dest.path);
});
//or sync version
var result = resolve.sync('fixtures/:module/public', 'public/:module');
// result.dest.path is the transformed files array
result == {
 "src": {
   "pattern": "fixtures/:module/public",
   "glob": "fixtures/*/public",
   "globstars": 0,
   "named": [
     "module"
   ],
   "unnamed": [],
   "vars": [
     {
       "segment": ":module",
       "compiled": "*",
       "type": "named",
       "name": "module",
       "globstar": false,
       "index": 1
     }
   ],
   "segments": [
     {
       "segment": "fixtures",
       "compiled": "fixtures",
       "type": "text",
       "globstar": false,
       "index": 0
     },
     {
       "segment": ":module",
       "compiled": "*",
       "type": "named",
       "name": "module",
       "globstar": false,
       "index": 1
     },
     {
       "segment": "public",
       "compiled": "public",
       "type": "text",
       "globstar": false,
       "index": 2
     }
   ],
   "paths": [
     "fixtures/Irish-Pub/public",
     "fixtures/test_pub/public"
   ],
   "values": [
     {
       ":module": "Irish-Pub"
     },
     {
       ":module": "test_pub"
     }
   ]
 },
 "dest": {
   "pattern": "public/:module",
   "glob": "public/*",
   "globstars": 0,
   "named": [
     "module"
   ],
   "unnamed": [],
   "vars": [
     {
       "segment": ":module",
       "compiled": "*",
       "type": "named",
       "name": "module",
       "globstar": false,
       "index": 1
     }
   ],
   "segments": [
     {
       "segment": "public",
       "compiled": "public",
       "type": "text",
       "globstar": false,
       "index": 0
     },
     {
       "segment": ":module",
       "compiled": "*",
       "type": "named",
       "name": "module",
       "globstar": false,
       "index": 1
     }
   ],
   "values": [
     {
       ":module": "Irish-Pub"
     },
     {
       ":module": "test_pub"
     }
   ],
   "paths": [
     "public/Irish-Pub",
     "public/test_pub"
   ]
 }
}

functions

resolve(srcPattern, destPattern [,options] ,callback)

async glob resove version.

resolve.sync(pattern [,options])

sync glob resove version.

resolve.globvar

reference to the glob-var module

test

npm test

license

MIT