Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fs-utils-sync

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-utils-sync

Streamline synchronous file system interactions in your Node.js projects with the lightweight fs-utils-sync package. It provides a collection of well-defined utility functions that enforce consistency across projects, ensuring an unified approach to file

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by200%
Maintainers
0
Weekly downloads
 
Created
Source

Filesystem Utils Sync

Streamline synchronous file system interactions in your Node.js projects with the lightweight fs-utils-sync package. It provides a collection of well-defined utility functions that enforce consistency across projects, ensuring an unified approach to file system operations.


Getting Started

Install the package:

$ npm install -S fs-utils-sync

Usage Examples

project
    │
    some-dir/
    │    └───...
    │
    some-file.json
import { pathExist, getPathElement } from 'fs-utils-sync';

pathExists('project/some-dir'); // true
pathExists('project/some-file.json'); // true
pathExists('project/other-file.json'); // false

getPathElement('project/other-file.json'); // null
getPathElement('project/some-file.json');
// {
//    path: 'project/some-file.json',
//    baseName: 'some-file.json',
//    extName: '.json',
//    isFile: true,
//    isDirectory: false,
//    isSymbolicLink: false,
//    size: 8647,
//    creation: 1715264137289,
// }

API

General Actions

  • pathExists(path: string): boolean

  • getPathElement(path: string): IPathElement | null

Directory Actions

  • isDirectory(path: string): boolean

  • deleteDirectory(path: string): void

  • createDirectory(path: string, deleteIfExists?: boolean): void

  • copyDirectory(srcPath: string, destPath: string): void

  • createDirectorySymLink(target: string, path: string): void

  • readDirectory(path: string, recursive?: boolean): string[]

  • getDirectoryElements(path: string, options?: Partial<IDirectoryElementsOptions>): IDirectoryPathElements

File Actions

  • isFile(path: string): boolean

  • writeFile(path: string, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void

  • writeTextFile(path: string, data: string): void

  • writeJSONFile(path: string, data: object | string, space?: number): void

  • writeBufferFile(path: string, data: Buffer): void

  • readFile(path: string, options?: IReadFileOptions): string | Buffer

  • readTextFile(path: string): string

  • readJSONFile(path: string): object

  • readBufferFile(path: string): Buffer

  • copyFile(srcPath: string, destPath: string): void

  • deleteFile(path: string): void

  • createFileSymLink(target: string, path: string)


Built With

  • TypeScript

Running the Tests

# Unit Tests
$ npm run test:unit

# Integration Tests
$ npm run test:integration

License

MIT


Acknowledgments

  • ...

@TODOS

  • Upgrade the docs
  • Implement and test compressDirectory and decompressDirectory
  • Implement and test compressFile and decompressFile

Deployment

Install dependencies:

$ npm install

Build the library:

$ npm start

Publish to npm:

$ npm publish

Keywords

FAQs

Package last updated on 08 Jul 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc