You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ls

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ls - npm Package Compare versions

Comparing version

to
0.2.1

2

lib/ls.js

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {

@@ -3,0 +3,0 @@ var fs, glob, list, path;

@@ -5,3 +5,3 @@ {

"author": "Awnist <hi@awnist.com> (http://awnist.com)",
"version": "0.2.0",
"version": "0.2.1",
"main": "./lib/ls",

@@ -8,0 +8,0 @@ "repository": {

@@ -1,7 +0,11 @@

## What's "ls"?
## What is "ls"?
ls is a node module for cleanly traversing directories and listing files.
`ls` is a node module for cleanly traversing directories and listing files.
The primary goal is a flexible, expressive syntax.
## Installation
$ npm i ls
## Overview

@@ -11,13 +15,18 @@

ls = require "ls"
var ls = require('ls');
Then we can be as sparse as
for file in ls "/path"
console.log file.name
for (var file of ls('/path/*')) {
console.log(file.name)
}
Or as elaborate as
Or as elaborate as
ls ["/path/foo*", "/another/path/"], { recurse: true }, /jpg/, ->
console.log @name, "is in", @path, "and is", @stat.size
ls(
'/path/*',
{ recurse: true },
/jpg/,
file => console.log `${file.name} is in ${$file.path} and is ${file.stat.size}`
)

@@ -28,8 +37,8 @@ ## Usage

ls [path/s], {config}, /file regex/, -> iterator function
ls([path/s], {config}, /file regex/, iteratorFunction)
Each file produces an object with the following parameters:
* full: The path and file (/foo/bar/baz.jpg)
* path: The path to the file (/foo/bar/)
* full: The path and file (/foo/bar/baz.jpg)
* file: The file (baz.jpg)

@@ -41,10 +50,11 @@ * name: The file without an extension (baz)

all_files = ls "/path"
for file in all_files
console.log file.name, "is", file.stat.size
all_files = ls('/path/*')
for (var file of all_files) {
console.log(file.name, 'is', file.stat.size);
}
Or use an iterator function, with the context being the file's object
ls "/path", ->
console.log @name, "is", @stat.size
var prettysize = require('prettysize');
ls('/tmp/*', file => console.log(`${file.name} is ${prettysize(file.stat.size)}`));

@@ -54,18 +64,10 @@ The {config} object accepts the following parameters:

* recurse: Should we recurse into directories? (Boolean, default is false)
* type: What kind of files should we return? ("all", "dir", "file", default is "all")
* type: What kind of files should we return? ('all', 'dir', 'file', default is 'all')
The /regex/ will only return matching files. All directories will still be recursed.
The -> iterator function is mostly a style preference, but can be handy if you need to throw an error and stop traversal.
The iterator function is mostly a style preference, but can be handy if you need to throw an error and stop traversal.
## Installation
## License
The recommended way is through the excellent [npm](http://www.npmjs.org/):
$ npm install ls
Otherwise, you can check it in your repository and then expose it:
$ git clone git://github.com/awnist/ls.git node_modules/ls/
ls is [UNLICENSED](http://unlicense.org/).
ls is [UNLICENSED](http://unlicense.org/). Do whatever you want with it.