1.1.10 • Published 4 years ago

lookfs v1.1.10

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

Contents

  • Example
  • Reference - root - fs(... path) - class LookFS - lookfs.ls - lookfs.all - lookfs.flat(depth) - lookfs.up(height) - lookfs.down(depth) - lookfs.size() - lookfs.fsize() - lookfs.height() - lookfs.depth() - lookfs.print() - lookfs.remove() - lookfs.chmod(mode) - lookfs.chown(owner, group) - lookfs.touch(atime, mtime) - class List - NodeList.from(asyncIterator) - NodeList.of(... nodes) - NodeList.concat(... lists) - NodeList.clone(list) - list.toArray() - list.map(func) - list.reduce(aggrFunc, initValue) - list.empty() - list.count() - list.some(cond) - list.every(cond) - list.find(cond) - list.parents - list.roots - list.filter(cond) - list.dirs - list.files - list.hidden - list.visible - list.ext(... exts) - list.access(mode) - list.loop - list.limit(count) - list.skip(offset) - class DirList - dirlist.get(... path) - class FileList - class Node - node.root - node.parent - node.name - node.ext - node.path - node.absPath - node.type - node.isRoot - node.isDir - node.isFile - node.isLink - node.isFIFO - node.isSocket - node.isBlock - node.isChar - node.isDot - node.toString() - node.toList() - node.access(mode) - node.isAccess(mode) - node.stat() - class Dir - class Root - class File - class Link - class BlockDevice - class CharacterDevice - class FIFO - class Socket - class Unknown

Example

import {fs, root} from 'lookfs'

root // absolute root dir
const myRoot = fs('/path/to/root'); // local root

(async function(){

	await myRoot.ls.print(); // print children
	await myRoot.ls.ls.print(); // print children of children
	await myRoot.flat(2).print(); // print children and children of children
	await myRoot.all.print(); // print all children and root
	await myRoot.ls.all.print(); // print all children
	await myRoot.all.dirs.print(); // print all children dirs and root
	await myRoot.all.files.limit(100).print(); // print first 100 children files
	// print children of images in /path/to/root/images dir
	const myRoot.get('images').ls.ext('jpeg', 'jpg', 'png', 'gif').print();
	// search files by name
	const myRoot.all.search(/^zuzuka/i).print();

	console.log(await myRoot.size()); // calc total size of myRoot
	console.log(await myRoot.depth()); // calc max depth of children
	console.log(await myRoot.ls.all.count()); // count all children of myRoot

	for await(const node of myRoot.all.files){

		console.log(`${node.name} ${await node.fsize()}`);
		// print all filenames of regylar file and formated size
	}

	// get file
	await file = myRoot.get('images/image.jpg');

	console.log(file.name); // print "image.jpg"
	console.log(file.path); // print "images/image.jpg"
	console.log(file.absPath); // print "/path/to/root/images/image.jpg"
	console.log(file.parent); // print /path/to/root/image dir
	console.log(file.root); // print /path/to/root dir
	console.log(file.height()); // print 2 - level of file
	console.log(await file.stat()); // stat
	console.log(await file.size()); // size

	await myRoot.chmod(0x777); // chmod myRoot
	await myRoot.all.dirs.chown(1000, 1000); // chown myRoot and all files

	await myRoot.ls.hidden.remove(); // unlink all hidden files in myRoot
	await myRoot.remove(); // remove dir myRoot with all files

})()

Reference

root

Absolute root dir

fs(... path)

Reletive root dir

class LookFS

lookfs.ls

Children iterator

lookfs.all

Self and all descendants iterator

lookfs.flat(depth)

lookfs.up(height)

lookfs.down(depth)

lookfs.size()

lookfs.fsize()

lookfs.height()

lookfs.depth()

lookfs.print()

lookfs.remove()

lookfs.chmod(mode)

lookfs.chown(owner, group)

lookfs.touch(atime, mtime)

class List

NodeList.from(asyncIterator)

NodeList.of(... nodes)

NodeList.concat(... lists)

NodeList.clone(list)

list.toArray()

list.map(func)

list.reduce(aggrFunc, initValue)

  • return any value

list.empty()

list.count()

list.some(cond)

list.every(cond)

list.find(cond)

list.parents

list.roots

list.filter(cond)

list.dirs

list.files

list.hidden

list.visible

list.ext(... exts)

list.access(mode)

list.loop

list.limit(count)

list.skip(offset)

class DirList

dirlist.get(... path)

class FileList

class Node

node.root

node.parent

Name of node

node.name

Filename of node

node.ext

File extends of node

node.path

Reletive path of node

node.absPath

node.type

node.isRoot

node.isDir

node.isFile

node.isLink

node.isFIFO

node.isSocket

node.isBlock

node.isChar

node.isDot

node.toString()

node.toList()

node.access(mode)

node.isAccess(mode)

node.stat()

class Dir

dir.get(... path)

class Root

class File

class Link

class BlockDevice

class CharacterDevice

class FIFO

class Socket

class Unknown

1.1.9

4 years ago

1.1.10

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.2

4 years ago

1.0.0

4 years ago