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

@absolunet/fss

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@absolunet/fss - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

43

index.js

@@ -8,2 +8,3 @@ //--------------------------------------------------------

const gracefulFs = require('graceful-fs');
const yaml = require('js-yaml');
const junk = require('junk');

@@ -70,9 +71,41 @@ const klaw = require('klaw-sync');

//-- YAML
readYaml: (file) => {
ow(file, ow.string.label('file').nonEmpty);
return yaml.safeLoad(gracefulFs.readFileSync(file, 'utf8'));
},
writeYaml: (file, object) => {
ow(file, ow.string.label('file').nonEmpty);
ow(object, ow.object.label('object'));
gracefulFs.writeFileSync(file, yaml.safeDump(object));
},
outputYaml: (file, object) => {
ow(file, ow.string.label('file').nonEmpty);
ow(object, ow.object.label('object'));
const dir = path.dirname(file);
if (!gracefulFs.existsSync(dir)) {
fsExtra.mkdirsSync(dir);
}
gracefulFs.writeFileSync(file, yaml.safeDump(object));
},
//-- scandir
scandir: (root, type, { recursive = false, fullPath = false, pattern = '**', keepJunk = false } = {}) => {
ow(root, ow.string.label('root').nonEmpty);
ow(type, ow.string.label('type').nonEmpty.is(() => { return ['file', 'dir'].includes(type) || `Must be 'file' or 'dir'`; }));
ow(root, ow.string.label('root').nonEmpty);
ow(type, ow.string.label('type').nonEmpty.is(() => { return ['file', 'dir'].includes(type) || `Must be 'file' or 'dir'`; }));
ow(recursive, ow.boolean.label('recursive'));
ow(fullPath, ow.boolean.label('fullPath'));
ow(pattern, ow.string.label('pattern').nonEmpty);
ow(keepJunk, ow.boolean.label('keepJunk'));
ow(fullPath, ow.boolean.label('fullPath'));
ow(pattern, ow.string.label('pattern').nonEmpty);
ow(keepJunk, ow.boolean.label('keepJunk'));

@@ -79,0 +112,0 @@ // Remove trailing slash

6

package.json
{
"name": "@absolunet/fss",
"version": "1.1.0",
"version": "1.2.0",
"description": "graceful-fs / fs-extra sync wrapper",

@@ -16,3 +16,4 @@ "definition": "",

"klaw",
"sync"
"sync",
"yaml"
],

@@ -40,2 +41,3 @@ "license": "MIT",

"graceful-fs": "^4.1.11",
"js-yaml": "^3.12.0",
"junk": "^2.1.0",

@@ -42,0 +44,0 @@ "klaw-sync": "^4.0.0",

@@ -28,3 +28,3 @@ # @absolunet/fss

## API mapper
## API

@@ -132,2 +132,20 @@ > `fs` is [graceful-fs](https://github.com/isaacs/node-graceful-fs)

### outputYaml(file, object)
Almost the same as writeYaml, except that if the directory does not exist, it's created.
#### file
*Required*<br>
Type: `String`<br>
Path of file to write.
#### object
*Required*<br>
Type: `Object`<br>
Object to write.
<br>
### pathExists

@@ -151,2 +169,16 @@ Maps [`fse.pathExistsSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/pathExists-sync.md)

### readYaml(file)
Reads a YAML file and then parses it into an object.<br>
Return `Object`
#### file
*Required*<br>
Type: `String`<br>
Path of file to read.
<br>
### realpath

@@ -167,30 +199,3 @@ Maps [`fs.realpathSync`](https://nodejs.org/api/fs.html#fs_fs_realpathsync_path_options)

### stat
Maps [`fs.statSync`](https://nodejs.org/api/fs.html#fs_fs_statsync_path_options)
### symlink
Maps [`fs.symlinkSync`](https://nodejs.org/api/fs.html#fs_fs_symlinksync_target_path_type)
### truncate
Maps [`fs.truncateSync`](https://nodejs.org/api/fs.html#fs_fs_truncatesync_path_len)
### unlink
Maps [`fs.unlinkSync`](https://nodejs.org/api/fs.html#fs_fs_unlinksync_path)
### utimes
Maps [`fs.utimesSync`](https://nodejs.org/api/fs.html#fs_fs_utimessync_path_atime_mtime)
### writeFile
Maps [`fs.writeFileSync`](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options)
### write
Maps [`fs.writeSync`](https://nodejs.org/api/fs.html#fs_fs_writesync_fd_buffer_offset_length_position)
### writeJson
Maps [`fse.writeJsonSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/writeJson-sync.md)
## API custom
### scandir(root, type, [options])

@@ -230,6 +235,50 @@ Uses [klaw-sync](https://github.com/manidlou/node-klaw-sync) to scan directory for files or directories.<br>

<br>
### stat
Maps [`fs.statSync`](https://nodejs.org/api/fs.html#fs_fs_statsync_path_options)
### symlink
Maps [`fs.symlinkSync`](https://nodejs.org/api/fs.html#fs_fs_symlinksync_target_path_type)
### truncate
Maps [`fs.truncateSync`](https://nodejs.org/api/fs.html#fs_fs_truncatesync_path_len)
### unlink
Maps [`fs.unlinkSync`](https://nodejs.org/api/fs.html#fs_fs_unlinksync_path)
### utimes
Maps [`fs.utimesSync`](https://nodejs.org/api/fs.html#fs_fs_utimessync_path_atime_mtime)
### writeFile
Maps [`fs.writeFileSync`](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options)
### write
Maps [`fs.writeSync`](https://nodejs.org/api/fs.html#fs_fs_writesync_fd_buffer_offset_length_position)
### writeJson
Maps [`fse.writeJsonSync`](https://github.com/jprichardson/node-fs-extra/blob/master/docs/writeJson-sync.md)
### writeYaml(file, object)
Writes an object to a YAML file.
#### file
*Required*<br>
Type: `String`<br>
Path of file to write.
#### object
*Required*<br>
Type: `Object`<br>
Object to write.
<br>
## License
MIT © [Absolunet](https://absolunet.com)
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