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

@types/fs-extra

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/fs-extra

TypeScript definitions for fs-extra

  • 9.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

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

FAQs

Package last updated on 11 Oct 2020

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