Gathering detailed insights and metrics for file-contents
Gathering detailed insights and metrics for file-contents
Gathering detailed insights and metrics for file-contents
Gathering detailed insights and metrics for file-contents
Set the `contents` property on a file object. Abstraction from vinyl-fs to support stream or non-stream usage.
npm install file-contents
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
8 Stars
39 Commits
3 Watching
2 Branches
2 Contributors
Updated on 14 Sept 2022
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-10.4%
15,561
Compared to previous day
Last week
-3.2%
84,012
Compared to previous week
Last month
-1.4%
362,617
Compared to previous month
Last year
0.8%
5,538,593
Compared to previous year
Set the
contents
property on a file object. Abstraction from vinyl-fs to support stream or non-stream usage.
Install with npm:
1$ npm install --save file-contents
This is inspired by the code in vinyl-fs src
. I needed a function that essentially did the same thing but could be used with stream or non-stream code.
1var through = require('through2'); 2var contents = require('file-contents'); 3 4function toStream(fp) { 5 var stream = through.obj(); 6 stream.write({path: fp}); 7 stream.end(); 8 return stream; 9} 10 11toStream('README.md') 12 .pipe(contents()) 13 .on('data', function(file) { 14 console.log(file.contents.toString()); 15 }); 16
async
An .async()
method is exposed for non-stream, async usage.
1contents.async({path: 'README.md'}, function (err, file) { 2 // results in something like: 3 // 4 // { path: 'README.md', 5 // stat: 6 // { dev: 16777218, 7 // mode: 33188, 8 // nlink: 1, 9 // uid: 501, 10 // gid: 20, 11 // rdev: 0, 12 // blksize: 4096, 13 // ino: 26436116, 14 // size: 2443, 15 // blocks: 8, 16 // atime: Fri Jul 17 2015 03:01:54 GMT-0400 (EDT), 17 // mtime: Wed Jul 15 2015 02:46:55 GMT-0400 (EDT), 18 // ctime: Wed Jul 15 2015 02:46:55 GMT-0400 (EDT), 19 // birthtime: Tue Jul 14 2015 23:03:58 GMT-0400 (EDT) }, 20 // contents: <Buffer 23 20 66 69 6c 65 2d 63 6f 6e 74 65 6e 74 73 20 5b 21 5b 4e 50 4d 20 76 65 72 73 69 6f 6e 5d 28 68 74 74 70 73 3a 2f 2f 62 61 64 67 65 2e 66 75 72 79 ... > } 21});
sync
A .sync()
method is exposed for non-stream, sync usage.
1var file = {path: 'README.md'}; 2contents.sync(file); 3// results in something like: 4// 5// { path: 'README.md', 6// stat: 7// { dev: 16777218, 8// mode: 33188, 9// nlink: 1, 10// uid: 501, 11// gid: 20, 12// rdev: 0, 13// blksize: 4096, 14// ino: 26436116, 15// size: 2443, 16// blocks: 8, 17// atime: Fri Jul 17 2015 03:01:54 GMT-0400 (EDT), 18// mtime: Wed Jul 15 2015 02:46:55 GMT-0400 (EDT), 19// ctime: Wed Jul 15 2015 02:46:55 GMT-0400 (EDT), 20// birthtime: Tue Jul 14 2015 23:03:58 GMT-0400 (EDT) }, 21// contents: <Buffer 23 20 66 69 6c 65 2d 63 6f 6e 74 65 6e 74 73 20 5b 21 5b 4e 50 4d 20 76 65 72 73 69 6f 6e 5d 28 68 74 74 70 73 3a 2f 2f 62 61 64 67 65 2e 66 75 72 79 ... > }
v0.2.0
.getContents
method to .async
.sync
methodstat
property on a file object. Abstraction from vinyl-fs to support stream or… more | homepagestat
property on a file object. | homepagePull requests and stars are always welcome. For bugs and feature requests, please create an issue.
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
1$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
1$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. MIT
This file was generated by verb-generate-readme, v0.4.2, on February 03, 2017.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More