New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

file-stat

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-stat - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

119

index.js

@@ -6,4 +6,4 @@ 'use strict';

module.exports = function fileStats() {
return utils.through.obj(function (file, enc, cb) {
getStats(file, function (err, res) {
return utils.through.obj(function(file, enc, cb) {
lstat(file, function(err, res) {
if (err) {

@@ -18,4 +18,21 @@ cb(err);

function getStats(file, cb) {
utils.fs.lstat(file.path, function (err, stat) {
/**
* Asynchronously add a `stat` property from `fs.stat` to the given file object.
*
* ```js
* var File = require('vinyl');
* var stats = require('{%= name %}');
* stats.stat(new File({path: 'README.md'}), function(err, file) {
* console.log(file.stat.isFile());
* //=> true
* });
* ```
* @name .stat
* @param {Object} `file` File object
* @param {Function} `cb`
* @api public
*/
function stat(file, cb) {
utils.fs.stat(file.path, function(err, stat) {
if (err) {

@@ -31,5 +48,95 @@ cb(err);

/**
* Expose `getStats`
* Asynchronously add a `lstat` property from `fs.lstat` to the given file object.
*
* ```js
* var File = require('vinyl');
* var stats = require('{%= name %}');
* stats.lstat(new File({path: 'README.md'}), function(err, file) {
* console.log(file.lstat.isFile());
* //=> true
* });
* ```
* @name .lstat
* @param {Object} `file` File object
* @param {Function} `cb`
* @api public
*/
module.exports.getStats = getStats;
function lstat(file, cb) {
utils.fs.lstat(file.path, function(err, stat) {
if (err) {
cb(err);
return;
}
file.stat = stat;
cb(null, file);
});
}
/**
* Synchronously add a `stat` property from `fs.stat` to the given file object.
*
* ```js
* var File = require('vinyl');
* var stats = require('{%= name %}');
* var file = new File({path: 'README.md'});
* stats.statSync(file);
* console.log(file.stat.isFile());
* //=> true
* ```
* @name .statSync
* @param {Object} `file` File object
* @param {Function} `cb`
* @api public
*/
function statSync(file) {
var stat;
Object.defineProperty(file, 'stat', {
configurable: true,
set: function(val) {
stat = val;
},
get: function() {
return stat || (stat = utils.fs.statSync(this.path));
}
});
}
/**
* Synchronously add a `lstat` property from `fs.lstat` to the given file object.
*
* ```js
* var File = require('vinyl');
* var stats = require('{%= name %}');
* var file = new File({path: 'README.md'});
* stats.statSync(file);
* console.log(file.lstat.isFile());
* //=> true
* ```
* @name .lstatSync
* @param {Object} `file` File object
* @param {Function} `cb`
* @api public
*/
function lstatSync(file) {
var lstat;
Object.defineProperty(file, 'lstat', {
configurable: true,
set: function(val) {
lstat = val;
},
get: function() {
return lstat || (lstat = utils.fs.lstatSync(this.path));
}
});
}
/**
* Expose `stat`
*/
module.exports.stat = stat;
module.exports.lstatSync = lstatSync;
module.exports.statSync = statSync;

38

package.json
{
"name": "file-stat",
"description": "Set the `stat` property on a file object. Abstraction from vinyl-fs to support stream or non-stream usage.",
"version": "0.1.3",
"version": "0.2.0",
"homepage": "https://github.com/jonschlinkert/file-stat",

@@ -24,13 +24,13 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"dependencies": {
"graceful-fs": "^4.1.2",
"lazy-cache": "^0.2.3",
"through2": "^2.0.0"
"graceful-fs": "^4.1.4",
"lazy-cache": "^2.0.1",
"through2": "^2.0.1"
},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-istanbul": "^0.10.1",
"gulp-jshint": "^1.11.2",
"gulp-mocha": "^2.1.3",
"jshint-stylish": "^2.0.1",
"mocha": "*"
"gulp": "^3.9.1",
"gulp-eslint": "^2.0.0",
"gulp-format-md": "^0.1.9",
"gulp-istanbul": "^1.0.0",
"gulp-mocha": "^2.2.0",
"mocha": "^2.5.3"
},

@@ -58,4 +58,20 @@ "keywords": [

]
}
},
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"lint": {
"reflinks": true
},
"reflinks": [
"vinyl-fs",
"verb-readme-generator",
"verb"
]
}
}
'use strict';
var utils = require('lazy-cache')(require);
/**
* Temporarily re-assign `require` so we can fool browserify
* into recognizing lazy deps.
*/
var fn = require;

@@ -15,3 +9,2 @@ require = utils;

* Lazily required module dependencies
* (here, `require` is actually lazy-cache)
*/

@@ -18,0 +11,0 @@

Sorry, the diff of this file is not supported yet

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