Socket
Socket
Sign inDemoInstall

clone-stats

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    clone-stats

Safely clone node's fs.Stats instances without losing their class methods


Version published
Weekly downloads
4.2M
increased by7.16%
Maintainers
1
Install size
4.37 kB
Created
Weekly downloads
 

Package description

What is clone-stats?

The clone-stats npm package is designed to clone the stats from one fs.Stats instance to another. This is particularly useful when you're working with file system operations in Node.js and need to replicate file or directory statistics accurately without modifying the original stats object. It provides a straightforward and efficient way to copy stats, ensuring that all the properties are cloned correctly.

What are clone-stats's main functionalities?

Cloning fs.Stats instance

This code demonstrates how to clone the statistics of a file system object using clone-stats. It first requires the clone-stats and fs modules. Then, it uses fs.stat to get the stats of a specific file and clone-stats to clone these stats into a new variable, allowing for manipulation or comparison without affecting the original stats object.

const cloneStats = require('clone-stats');
const fs = require('fs');

fs.stat('/path/to/file', (err, stats) => {
  if (err) throw err;
  const clonedStats = cloneStats(stats);
  console.log(clonedStats);
});

Other packages similar to clone-stats

Readme

Source

clone-stats Flattr this!experimental

Safely clone node's fs.Stats instances without losing their class methods, i.e. stat.isDirectory() and co.

Usage

clone-stats

copy = require('clone-stats')(stat)

Returns a clone of the original fs.Stats instance (stat).

License

MIT. See LICENSE.md for details.

Keywords

FAQs

Last updated on 17 May 2016

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