Skip to content
This repository has been archived by the owner on May 4, 2020. It is now read-only.

brechtcs/lazy-path

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lazy-path

Wrapper around the NodeJS path module that lazily returns the properties of a parsed path. It also normalizes and joins any input by default.

Usage

var Path = require('lazy-path')

var path = Path.from('path/to/file.txt')
console.log(path.dir) // 'path/to'
console.log(path.base) // 'file.txt'
console.log(path.name) // 'file'
console.log(path.ext) // '.txt'

// The `crumbs` property gives an array of the directies in the path
console.log(path.crumbs) // ['path', 'to']

// `abs` is a boolean answering whether the path is absolute or not
console.log(path.abs) // false

// `res` gives the resolved absolute path
console.log(path.res) // e.g. '/home/user/path/to/other.jpg'

// Using the `from` constructor with multiple arguments will join (and normalize) the path
var another = Path.from('another', 'file.txt')
console.log(another.toString()) // 'another/file.txt'

// The replacement for Node's `path.relative` is the `to` method
Path.from('one/file.txt').to(another) // '../another'

Todo

License

Apache-2.0

About

Lazy wrapper around the NodeJS path module

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published