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

t2-project

v1.0.1

Published

Build a project for deployment to a Tessel 2

Downloads

15

Readme

t2-project

Travis-CI Build Status Appveyor Build status

Given a specified entry point file, determine and resolve the dependency graph.

Dependencies

The resulting output is an array of data objects containing the following properties:

| Name | Description | | ---- | ----------- | | id | Unique file identity | | file | Absolute path to file | | source | The contents of the file |

For example, the following program:

var Project = require('t2-project');

var project = new Project({
  entry: 'eg/project-conditional/index.js',
});

project.exclude(['b.js']);
project.exclude(['c.*']);

project.collect((error, entries) => console.log(entries));

Where eg/project-conditional/ contains:

.
├── a.js
├── b.js
├── c.js
└── index.js

0 directories, 4 files

Would have the following result (just assume ${ABSOLUTE_PATH} is the absolute path to project-conditional):

[{
  id: '${ABSOLUTE_PATH}/eg/project-conditional/a.js',
  source: 'module.exports = function() {\n  return \'a\';\n};\n',
  deps: {},
  file: '${ABSOLUTE_PATH}/eg/project-conditional/a.js'
}, {
  file: '${ABSOLUTE_PATH}/eg/project-conditional/index.js',
  entry: true,
  id: '${ABSOLUTE_PATH}/eg/project-conditional/index.js',
  source: 'var conditional = true ? require(\'./a\') : require(\'./b\');\n\nrequire(\'./c\');\n\n\nconsole.log(conditional());\n',
  deps: {
    './b': '${ABSOLUTE_PATH}/eg/project-conditional/b.js',
    './c': '${ABSOLUTE_PATH}/eg/project-conditional/c.js',
    './a': '${ABSOLUTE_PATH}/eg/project-conditional/a.js'
  }
}]

Usage

Install via npm:

npm install t2-project
var Project = require('t2-project');

var a = new Project({
  entry: './eg/project-simple/index.js',
});

a.collect((error, entries) => {
  console.log('DONE: a', entries.length);
  entries.forEach(entry => console.log(entry.file));
});

var b = new Project({
  entry: './eg/project-conditional/index.js',
});

b.exclude(['b.js', 'c.*']);

/*
Or...

b.exclude('b.js');
b.exclude('c.*');

Or... 

b.exclude({
  files: ['b.js', 'c.*'],
  basedir: (optionally specify a basedir)
});
*/

var p = b.collect((error, entries) => {
  console.log('CALLBACK: b', entries.length);
  entries.forEach(entry => console.log(entry));
});

p.then(entries => {
  console.log('RESOLVED: b', entries.length);
  entries.forEach(entry => console.log(entry.file));
});

API

  • exclude(file): Call this method with a string file name to exclude a single file.
  • exclude([ ...files]): Call this method with an array of string file names to exclude many files.
  • exclude({ files: [ ...files], basedir: '...' }): Call this method with an object containing a files property, whose value is an array of string file names to exclude many files; and optionally a basedir property to specify the base directory to exclude from.
  • filter: meh, this is unfinished and might not live to see another day.

License

Copyright (c) 2015 Rick Waldron [email protected] Licensed under the MIT license.