Socket
Socket
Sign inDemoInstall

dir-fs-utils

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dir-fs-utils

A NodeJS library that creates several utility functions over the native fs module for directories


Version published
Weekly downloads
1.8K
increased by16.72%
Maintainers
1
Install size
9.47 kB
Created
Weekly downloads
 

Changelog

Source

v1.1.2 (2021-02-01)

Full Changelog

Merged pull requests:

Readme

Source

Dir Utils

issues forks stars license version

dir-fs-utils is aiming to be a collection of the utility functions for directories build on top of the native fs module.

Installation

npm i dir-fs-utils

Then anywhere in your code.

import { DirUtils } from 'dir-fs-utils`

or

const { DirUtils } = require('dir-fs-utils');

How to use it

await DirUtils.getFolderSize(folder_path);

await DirUtils.listFolderContent(folder_path);

Methods (3)

(1)

async listFolderContent(path: string): Promise<string[]> {}

This method will return an array with all the files in a folder.

If the provided path does not exist or is not accessible, then it will generate an error.


(2)

async getFolderSize(path: string): Promise<number> {}

This method will return the total size of a folder in bytes.

If the provided path does not exist or is not accessible, then it will generate an error.


(3)

async unwrap(folderPath: string, options?: UnwrapOptions): Promise<Map<string, string>>
export interface UnwrapOptions {
  keepFolder?: boolean;
  force?: boolean;
}

This method will open the contents of a folder. By default, it will remove the original folder and undo only files for which the destination path does not exist.

The returned value is a map that will contain all the files that failed to be unwrapped. If the size of the map is 0, then all the files were unwrapped successfully.

  • keepFolder?:boolean - if this property is set to true, then the original folder will remain intact(files will not be deleted)
  • force?:boolean - if this property is set to true, then the destination of the unwrapped files will overwritten

Contributing

Pull requests and stars are always welcome. Please check the guidelines.

Stay in touch

Author - Stan Georgian

License

This project is licensed under the MIT License

Keywords

FAQs

Last updated on 01 Feb 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc