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

fs-utils

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-utils

fs extras and utilities to extend the node.js file system module. Used in Assemble and many other projects.

  • 0.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.9K
decreased by-69.68%
Maintainers
2
Weekly downloads
 
Created
Source

fs-utils NPM version

fs extras and utilities to extend the node.js file system module. Used in Assemble and many other projects.

Install

Install with npm:
npm i fs-utils --save-dev

Run tests

npm test

Usage

var fs = require('fs-utils');

API

.stripcr

  • str {String}
  • returns: {String}

Strip carriage returns from a string.

.stripBOM

Strip byte order marks from a string.

  • str {String}
  • returns: {String}

See BOM

.forwardSlash

  • str {String}
  • returns: {String}

Normalize all slashes to forward slashes.

.isEmpty

  • filepath {String}
  • returns: {Boolean}

Return true if the file exists and is empty.

.isDir

  • filepath {String}
  • returns: {Boolean}

Return true if the filepath is a directory.

  • filepath {String}
  • returns: {Boolean}

True if the filepath is a symbolic link.

.glob

  • patterns {String|Array}
  • returns: {options}

Glob files using globby. Or glob files synchronously with glob.sync.

.readFileSync

  • filepath {String}
  • returns: {String}

Read a file synchronously. Also strips any byte order marks.

readFile

  • filepath {String}
  • options {Object}
  • normalize {Boolean}: Strip carriage returns and BOM.
  • encoding {String}: Default is utf8
  • callback {Function}

Read a file asynchronously.

.readJSONSync

  • filepath {String}
  • returns: {Object}

Read a file synchronously and parse contents as JSON. marks.

.readJSON

  • filepath {String}
  • callback {Function}
  • returns: {Object}

Read JSON file asynchronously and parse content as JSON

.readYAMLSync

  • filepath {String}
  • returns: {Object}

Read a YAML file synchronously and parse its content as JSON

.readYAML

  • filepath {String}
  • returns: {Object}

Read a YAML file synchronously and parse its content as JSON

.readDataSync

  • filepath {String}
  • options {String}
  • returns: {String}

Read JSON or YAML. Determins the reader automatically based on file extension.

.readData

  • filepath {String}
  • options {String}
  • returns: {String}

Read JSON or YAML async. Determins the reader automatically based on file extension.

.writeFile

Write

.writeFileSync

  • dest {String}
  • str {String}
  • options {Options}

Synchronously write files to disk, creating any intermediary directories if they don't exist.

.writeJSONSync

  • dest {String}
  • str {String}
  • options {Options}

Synchronously write JSON to disk, creating any intermediary directories if they don't exist.

.writeJSON

  • dest {String}
  • str {String}
  • options {Options}

Asynchronously write files to disk, creating any intermediary directories if they don't exist.

.writeYAMLSync

  • dest {String}
  • str {String}
  • options {Options}

Synchronously write YAML to disk, creating any intermediary directories if they don't exist.

.writeYAML

  • dest {String}
  • str {String}
  • options {Options}

Aynchronously write YAML to disk, creating any intermediary directories if they don't exist.

.writeDataSync

Synchronously write JSON or YAML to disk, creating any intermediary directories if they don't exist. Data type is determined by the dest file extension.

  • dest {String}
  • str {String}
  • options {Options}
writeDataSync('foo.yml', {foo: "bar"});

.writeData

Asynchronously write JSON or YAML to disk, creating any intermediary directories if they don't exist. Data type is determined by the dest file extension.

  • dest {String}
  • str {String}
  • options {Options}
writeDataSync('foo.yml', {foo: "bar"});

.copyFileSync

  • src {String}
  • dest {String}

Copy files synchronously;

.rmdir

  • dir {String}
  • {Function}: `cb
  • returns: {Function}

Asynchronously remove dirs and child dirs that exist.

.ext

  • filepath {String}
  • returns: {String}

Return the file extension.

.dirname

  • filepath {String}
  • returns: {String}

Directory path excluding filename.

.last

  • filepath {String}
  • returns: {String}

The last n segments of a filepath. If a number isn't passed for n, the last segment is returned.

.first

  • filepath {String}
  • returns: {String}

The first n segments of a filepath. If a number isn't passed for n, the first segment is returned.

.lastChar

Returns the last character in filepath

  • filepath {String}
  • returns: {String}
lastChar('foo/bar/baz/');
//=> '/'

.addSlash

Add a trailing slash to the filepath.

  • filepath {String}
  • returns: {String}

Note, this does not consult the file system to check if the filepath is file or a directory.

.normalizePath

  • filepath {String}
  • returns: {String}

Normalize a filepath and remove trailing slashes.

.relative

  • filepath {String}
  • returns: {String}

Resolve the relative path from a to `b.

.isAbsolute

  • {[type]}: filepath
  • returns: {Boolean}

Return true if the path is absolute.

.equivalent

  • filepath {String}
  • a {String}
  • b {String}
  • returns: {Boolean}

Return true if path a is the same as path `b.

.doesPathContain

True if descendant path(s) contained within ancestor path. Note: does not test if paths actually exist.

  • ancestor {String}: The starting path.
  • returns: {Boolean}

Sourced from [Grunt].

.isPathCwd

True if a filepath is the CWD.

  • filepath {String}
  • returns: {Boolean}

Sourced from [Grunt].

.isPathInCwd

  • filepath {String}
  • returns: {Boolean}

True if a filepath is contained within the CWD.

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on October 06, 2014.

Keywords

FAQs

Package last updated on 06 Oct 2014

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