Treeify

treeify

converts a JS object into a nice and readable tree structure for the console

Say, you an object that has the dependencies of a node module and you want to represent it as a tree structure or may you have a filesystem hierarchy to display on CLI, it's kina tough right? Well...here is treeify for you!

Get it: npm install treeify

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var treeify = require('treeify');

var deps = {
    "[email protected]": {
        "[email protected]": null,
        "[email protected]": null,
        "[email protected]": null,
        "[email protected]": "[email protected]"
    }
};

console.log(
   treeify.asTree(deps, true)
);

//or

treeify.asLines(deps, true, function(line){
  console.log(line);
});

Both would output:

1
2
3
4
5
└─ npm@2.1.12
   ├─ archy@1.0.0
   ├─ abbrev@1.0.5
   ├─ char-spinner@1.0.1
   └─ block-stream@0.0.7: inherits@2.0.1

GIF FTW:

treeify

Thanks to Luke Plaster for making our life a bit more easier on the CLI.

Tldr

tldr

If you are new to CLI or not able to recall the flags of your CLI tool, you would consult man pages.

tldr is "Too Long Didn't Read" version of man pages ;) i.e it shows us the common usages of a given command.

tldr covers:

  • Common commands.

  • GNU/Linux.

  • OSX.

  • SunOS.

Install it as a CLI app: $ npm install -g tldr

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ tldr sudo

  execute a command as another user

  - Listing of an unreadable directory:

  sudo ls /usr/local/scrt

  - To edit a file as user www:

  sudo -u www vi /var/www/index.html

  - To shutdown the machine:

  sudo shutdown -r +10 "Cya soon!"

  - To repeat the last command as sudo

  sudo !!

GIF FTW!

tldr

All TLDR pages are in markdown format, checkout sudo page for an example, this is a community dirven effort, so please feel free to contribute :)

Fake-identity

fake-identity

Generate random identity objects including name, address, etc. This may be useful if you are trying to fill your application with random personal data.

What else?

  • Generates a single random identity or multiple identities in an array.
  • Includes first and last names, email address, phone number, street, city, state, zip code, date of birth, sex, company, and department.
  • Email address is based off of name.
  • First name matches sex.
  • All names, streets, and cities are commonly found in the US.
  • States are weighted on population, so more populous states appear more often.
  • Zip codes are loosely based on state. Zip codes are weird so it's not perfect, though.
  • Date of birth will be between 18 and 60.
  • Usable in the browser or Node.js.
  • No dependencies.

Install it: npm install fake-identity

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
identity = require('fake-identity')
identity.generate();
/* 
Would result in a random object like:
{ sex: 'male',
  firstName: 'Jonathan',
  lastName: 'Murphy',
  emailAddress: '[email protected]',
  phoneNumber: '(555) 555-2739',
  street: '4473 Highland Avenue',
  city: 'Glendale',
  state: 'KS',
  zipCode: '67069',
  dateOfBirth: Mon Jan 24 1955 00:00:00 GMT+0530 (IST),
  company: 'Woodgrove Bank',
  department: 'Engineering' }
*/

identity.generate(2); // Int val for the number of records.

/*[ { sex: 'male',
    firstName: 'Nathan',
    lastName: 'Morgan',
    emailAddress: '[email protected]',
    phoneNumber: '(555) 555-5027',
    street: '2897 Meadow Lane',
    city: 'Ashland',
    state: 'CA',
    zipCode: '94347',
    dateOfBirth: Fri Jan 14 1966 00:00:00 GMT+0530 (IST),
    company: 'Northwind Traders',
    department: 'Product Management' },
  { sex: 'male',
    firstName: 'Jackson',
    lastName: 'Wilson',
    emailAddress: '[email protected]',
    phoneNumber: '(555) 555-7407',
    street: '514 Court Street',
    city: 'Shiloh',
    state: 'MO',
    zipCode: '64416',
    dateOfBirth: Sun Apr 02 1995 00:00:00 GMT+0530 (IST),
    company: 'Fourth Coffee',
    department: 'Information Systems' } ]
*/

GIF FTW!

fake-identity

This is pretty modular and sweet util, that needs some more configurability, thanks to Travis Horn for fake-identity.

Npm-check-updates

npm-check-updates

Finding all updates to dependencies and updating them is very easy with npm-check-updates.

Install it globally: npm install -g npm-check-updates

Sample usage:

1
2
3
4
5
6
7
8
9
10
$ npm-check-updates
npm http GET http://registry.npmjs.org/read-chunk
npm http GET http://registry.npmjs.org/mocha
npm http GET http://registry.npmjs.org/browserify
npm http 304 http://registry.npmjs.org/browserify
npm http 304 http://registry.npmjs.org/read-chunk
npm http 304 http://registry.npmjs.org/mocha

"browserify" can be updated from ^3.0.0 to ^6.3.2 (Installed: 3.44.2, Latest: 6.3.2)
"read-chunk" can be updated from ^0.1.0 to ^1.0.0 (Installed: 0.1.0, Latest: 1.0.0)
1
2
3
4
5
6
7
8
9
10
$ npm-check-updates -u

"browserify" can be updated from ^3.0.0 to ^6.3.2 (Installed: 3.44.2, Latest: 6.3.2)
"read-chunk" can be updated from ^0.1.0 to ^1.0.0 (Installed: 0.1.0, Latest: 1.0.0)

package.json upgraded

$ npm-check-updates

All dependencies match the latest package versions :)

GIF FTW!

Thanks to Tomas Junnonen for this cute little util.

Npm-me

npm-me

Get a list of download counts over the last month for a particular user's packages.

Installing it: npm install npm-me or npm install -g npm-me

CLI usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
nmotw> npm-me hemanth

NAME                 COUNT
has-properties          10
color-type              11
yoda-said               12
systemize               12
inpm                    13
cani                    13
randhex                 14
gulp-prune-html         14
gignore                 15
all-builtins            15
gandhi-said             15
an-async                16
npm-repo                16
ip2dword                16
generator-webrtc        17
gulp-html2txt           17
ndocs                   17
get-pdf-urls            18
gulp-html2md            19
is-deprecated           19
humem                   19
climagic                20
gntr                    21
broccoli-md             22
broccoli-xml2json       22
lie-fs                  26
gulp-js2coffee          26
octodex                 29
generator-atom          30
broccoli-es6-arrow      31
bjs                     33
xkcd-imgs               35
prepend-file            37
gulp-html2jade          39
grunt-html2jade         42
gulp-hogan              43
is-keyword              50
inline-elements         54
edich                   61
gulp-jstransform       104
is-builtin             114
is-m4a                 145
is-mp3                 146
is-ogg                 148
is-wav                 148
is-flac                150
audio-type             157
gulp-removelogs        223
gulp-cleanhtml         448
rsj                    574
generator-node         606
enable               1,193
void-elements      142,794

Total  147,889

API:

1
2
3
4
5
var npmme = require('npm-me');

npmme('hemanth', function(err, packages){
  // packages => [{name: '', count:0},...]
});

GIF FTW!

Thanks to Hugh Kennedy for this cheeky util!

Npm-clone

npm-clone

This is a CLI util that will help you to:

  • Clone a node module from it's name.

  • Install all the dependencies.

  • Run its tests!

Get it: npm install -g npm-clone

Usage example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# clone a node module
npm-clone is-mp3

# clone using its private url
npm-clone --ssh is-mp3
npm-clone --https is-mp3

# clone and install dependencies
npm-clone install is-mp3

# clone, install dependencies and run its tests
npm-clone install test is-mp3

# with a short form
npm-clone all is-mp3

# flags still apply
npm-clone --ssh all is-mp3

GIF FTW!

npm-clone

Thanks to Julian Gruber for this helper! :)

Propagate

propagate

Propagate events from one event emitter into another.

An other sweet and simple module, that helps to propagate events!

Get it: npm install propagate

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
var EventEmitter = require('events').EventEmitter;
var propagate = require('propagate');

var evn1 = new EventEmitter();
var evn2 = new EventEmitter();

propagate(evn1,evn2);

evn2.on('event',function(msg) {
  console.log('Got a propagated event', msg);
});

evn1.emit('event', 'Yo!')
// Got a propagated event Yo!

GIF FTW!

propagate

Thanks to Pedro Teixeira for propagate.

Http-teapot

http-teapot

Add support for RFC 2324 to any HTTP server.

P.S: Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0) was a April fools RFC ;) HTTP status code 418.

BTW if you are wondering why this made in to this list, http-teapot module is the 100,000th module to npm today!

Installation

1
npm install http-teapot

Usage

Just add http-teapot as a routing function.

Express example:

1
2
3
4
5
6
7
var teapot = require('http-teapot');
var express = require('express');
var app = express();

app.get('/teapot', teapot);

app.listen(3000);

GIF FTW!

http-teapot

Thanks to Thomas Watson Steen for implementing this RFC and giving us a teapot image ;)

Is

is

This is a definitive JavaScript type testing library.

Get it: npm install is

Sample usage:

1
2
3
4
5
6
7
8
9
var is = require('is');
is.type(true, 'boolean');
is.type(1, 'boolean');
is.type(1, 'number');
is.type([], 'object');
is.array([]);
is.odd(9);
is.even(2);
// So on...

It has all uber cool is checks as below:

[ 'type', 'a', 'defined', 'empty', 'equal', 'hosted', 'instanceof', 'instance', 'null', 'nil', 'undefined', 'undef', 'arguments', 'args', 'array', 'arraylike', 'boolean', 'false', 'true', 'date', 'element', 'error', 'function', 'fn', 'number', 'infinite', 'decimal', 'divisibleBy', 'int', 'maximum', 'minimum', 'nan', 'even', 'odd', 'ge', 'gt', 'le', 'lt', 'within', 'object', 'hash', 'regexp', 'string' ]

GIT FTW:

is

Thanks to Enrico Marino for is :)

Progress

progress

Flexible ascii progress bar.

Install it: npm install progress

Example usage:

  • Create a ProgressBar.
  • Give it a format string.
  • Give the total, telling the progress bar when to stop!
  • Finally do tick() appropriately.
1
2
3
4
5
6
7
8
9
10
var ProgressBar = require('progress');

var bar = new ProgressBar(':bar', { total: 10 });
var timer = setInterval(function () {
  bar.tick();
  if (bar.complete) {
    console.log('\ncomplete\n');
    clearInterval(timer);
  }
}, 100);

Options

These are keys in the options object you can pass to the progress bar along with total as seen in the example above.

  • total total number of ticks to complete
  • width the displayed width of the progress bar defaulting to total
  • stream the output stream defaulting to stderr
  • complete completion character defaulting to "="
  • incomplete incomplete character defaulting to "-"
  • clear option to clear the bar on completion defaulting to false
  • callback optional function to call when the progress bar completes

Tokens

These are tokens you can use in the format of your progress bar.

  • :bar the progress bar itself
  • :current current tick number
  • :total total ticks
  • :elapsed time elapsed in seconds
  • :percent completion percentage
  • :eta estimated completion time in seconds

Do checkout their examples folder.

GIF FTW!

Thanks to TJ and rest of the maintainers for node-progress!