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

buildkit-globber

v0.1.12

Published

Buildkit file globbing utility

Downloads

32

Readme

#buildkit-treeglob Buildkit file globbing utility

What Does It Do?

Returns arrays of file and directory properties according to globs and a tree. Performs file and directory change watching according to globs and a tree.

Use

a. Install buildkit-globber

npm install --save buildkit-globber

b. Require

//node v4
var GlobCollection = require("buildkit-globber").GlobCollection;
var TreeContext = require("buildkit-globber").TreeContext;
var WatchCollection = require("buildkit-globber").WatchCollection;
var FileSystem = require("buildkit-globber").FileSystem;
var Location = require("buildkit-globber").Location;
var MATCH_TYPE = require("buildkit-globber").MATCH_TYPE;


//node v5+
var {GlobCollection,
	TreeContext,
	Tree,
	WatchCollection,
	Location,
	FileSystem,
	MATCH_TYPE} = require("buildkit-globber");

c. Use API. See below.

Glob

A description of the files / directories expected.

"*/*/*.js" // all javascript files, two directories into the tree
"*/**/*.js" // all javascript files, one directory and above in the tree
"src/*/js/**/*.js" // all of javascript files in the subfolders of the 'js' folder located in each of the "src" folder's sub directories.
"!**/.*" // not all nested hidden files
"!node_modules" // not the immediate node_modules folder
"!**/node_modules" // no any sub node_modules folder

var globs = new GlobCollection([
	"src/*/js/*.js",
	"src/*/js/**/*.js",
	"!**/.*"
]);

var ignores = new GlobCollection([
	"!node_modules",
	"!**/node_modules"
]);

##Tree Context An collection of options for a group of Tree objects.

var treecontext = new TreeContext({
	files: true,
	dirs: true,
	cache: true
});

treecontext.clearCache();

Tree

A directory "." relative to another directory "/home/user/Destkop".

var tree = treecontext.Tree(".","/working/project_number");

tree.populate();

tree.dirs;
tree.files;
tree.subtrees;
tree.TreeContext;

Alternatively, without a treecontext

var tree = new Tree(".","/working/project_number");

tree.populate();

tree.dirs;
tree.files;
tree.subtrees;
tree.TreeContext;

Glob + Tree Together

	
	//fetch all files + dirs in tree by globs:
	var locationObjects = tree.mapGlobs(globs, ignores);

	locationObjects.files[0-x].relativeLocation;
	locationObjects.files[0-x].ctime;
	locationObjects.files[0-x].mtime;
	locationObjects.files[0-x].size;
	locationObjects.files[0-x].isFile;
	locationObjects.files[0-x].isDir;
	locationObjects.files[0-x].basename;
	locationObjects.files[0-x].extname;
	locationObjects.files[0-x].filename;
	locationObjects.files[0-x].dirname;
	locationObjects.files[0-x].depth;
	locationObjects.files[0-x].location;
	locationObjects.files[0-x].relativeTo;

	locationObjects.dirs[0-x].relativeLocation;
	locationObjects.dirs[0-x].ctime;
	locationObjects.dirs[0-x].mtime;
	locationObjects.dirs[0-x].size;
	locationObjects.dirs[0-x].isFile;
	locationObjects.dirs[0-x].isDir;
	locationObjects.dirs[0-x].basename;
	locationObjects.dirs[0-x].extname;
	locationObjects.dirs[0-x].filename;
	locationObjects.dirs[0-x].dirname;
	locationObjects.dirs[0-x].depth;
	locationObjects.dirs[0-x].location;
	locationObjects.dirs[0-x].relativeTo;



	//watch all files + dirs in tree by globs:
	var watchObject = tree.watchGlobs(globs, ignores);
	watchObject.on("change", function(tree, files, dirs) {

		files[0-x].location.ctime;
		files[0-x].change = "updated/deleted/created";

	});
	watchObject.start();
	watchObject.stop();
	watchObject.start();

Location Object


	var location = new Location("src", ".");
	location.populate({cache: true});

	location.doesExist;
	location.isFile;
	location.isDir;
	location._isPopulated;
	location._populatedTimeStamp;
	location.depth;
	location.dirname;
	location.filename;
	location.extname;
	location.basename;
	location.relativeLocation;
	location.location;
	location.relativeTo;
	location.birthtime;
	location.ctime;
	location.mtime;
	location.size;
	location.clone();
	location.populate();



	Location.toAbsolute(string location, [string relativeTo]);
	Location.toRelative(string location, [string relativeTo]);
	Location.cwd();
	Location.home();
	Location.contextReplace(string handlebars, object context);
	Location.convertToPosixSlashes(string location);

##Watch Collection Object

	var watches = new WatchCollection();

	watches.push(watchObject);

	watches.start();
	watches.stop();
	watches.start();

##MATCH_TYPE


	MATCH_TYPE.NOTMATCHED = 0;
	MATCH_TYPE.NOTMATCHED.toString() = "NOTMATCHED";
	MATCH_TYPE.DESCEND = 1;
	MATCH_TYPE.DESCEND.toString() = "DESCEND";
	MATCH_TYPE.NOTEXCLUDED = 2;
	MATCH_TYPE.NOTEXCLUDED.toString() = "NOTEXCLUDED";
	MATCH_TYPE.MATCHED = 3;
	MATCH_TYPE.MATCHED.toString() = "MATCHED";
	MATCH_TYPE.MATCHED_DESCEND = 4;
	MATCH_TYPE.MATCHED_DESCEND.toString() = "MATCHED_DESCEND";

##FileSystem Object


	FileSystem.collate(string from, string to, string at, Array copyGlobs, Array destGlobs, function callback);
	FileSystem.copy(string from, string to, Array copyGlobs, function callback);
	FileSystem.mkdir(string dest);
	FileSystem.remove(string dest, Array removeGlobs);
	FileSystem.rm(string path);