Socket
Socket
Sign inDemoInstall

@types/fs-extra

Package Overview
Dependencies
3
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/fs-extra

TypeScript definitions for fs-extra


Version published
Weekly downloads
5.1M
increased by3.83%
Maintainers
1
Install size
3.85 MB
Created
Weekly downloads
 

Package description

What is @types/fs-extra?

The @types/fs-extra package provides TypeScript type definitions for the fs-extra library, which is an extension of the Node.js standard 'fs' module. It adds file system methods that aren't included in the native 'fs' module and provides promise support. This package is essential for TypeScript developers using fs-extra to ensure type safety and to take advantage of IntelliSense and code completion features in their IDE.

What are @types/fs-extra's main functionalities?

File Copying

This feature allows for copying files and directories from one location to another. The code sample demonstrates how to use the async/await syntax to copy files.

import fs from 'fs-extra';

async function copyFiles() {
  try {
    await fs.copy('/path/to/source', '/path/to/dest');
    console.log('Files copied successfully!');
  } catch (err) {
    console.error(err);
  }
}

Reading and Writing JSON Files

This feature simplifies the process of reading and writing JSON files. The code sample shows how to read a JSON file, modify its content, and then write it back.

import fs from 'fs-extra';

async function readAndWriteJson() {
  try {
    const data = await fs.readJson('/path/to/some.json');
    console.log(data);
    data.newProp = 'newValue';
    await fs.writeJson('/path/to/some.json', data);
    console.log('JSON file updated successfully!');
  } catch (err) {
    console.error(err);
  }
}

Ensuring a Directory Exists

This feature checks if a directory exists, and if it does not, creates it. The code sample demonstrates how to ensure a directory exists.

import fs from 'fs-extra';

async function ensureDir() {
  try {
    await fs.ensureDir('/path/to/dir');
    console.log('Directory exists or was created successfully!');
  } catch (err) {
    console.error(err);
  }
}

Other packages similar to @types/fs-extra

Readme

Source

Installation

npm install --save @types/fs-extra

Summary

This package contains type definitions for fs-extra (https://github.com/jprichardson/node-fs-extra).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/fs-extra.

Additional Details

Credits

These definitions were written by Alan Agius, midknight41, Brendan Forster, Mees van Dijk, Justin Rockwood, Sang Dang, Florian Keller, Piotr Błażejewicz, Tiger Oakes, and BendingBender.

FAQs

Last updated on 07 Nov 2023

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