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

ls-fs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ls-fs

Some file utilities

  • 1.2.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

ls-fs Build Status Circle CI

File utils

Snuffles

Usage

var lsFs = require('ls-fs');

lsFs.readJson('settings.json').then(function(settings) {
    console.log(settings.prop1);
    console.log(settings.prop2);
});

API

readJson

lsFs.readJson(path, [opts]).then(function(parsedJsonObj) {
    console.log(parsedJsonObj);
});
Arguments
  1. path (String) The path to the JSON file to read

writeJson

lsFs.writeJson(path, obj, [opts]).then(function(pathToJson) {
    
});
Arguments
  1. path (String) The path to the JSON file to write
  2. obj (*) The thing to JSON.stringify

readIni

lsFs.readIni(path, [opts]).then(function(parsedIniObj) {
    console.log(parsedIniObj);
});
Arguments
  1. path (String) The path to the INI file to read
  2. [opts] (Object) Identical to q-io/fs.read options

writeIni

lsFs.writeIni(path, obj, [opts]).then(function(pathToIni) {
    console.log('wrote ' + pathToIni);
});
Arguments
  1. path (String) The path to the INI file to write
  2. obj (*) The thing to stringify into INI format
  3. opts (Object) Merge of options for ini and q-io/fs.write

tmpDir

lsFs.tmpDir([opts]).then(function(pathToTmpDir) {
    // do stuff with my temporary directory
});
Arguments
  1. [opts] (Object) Same as https://github.com/raszi/node-tmp#directory-creation

requireDir

Takes a path to a directory and returns an object containing all the required modules in that directory.

For example, if you have a directory with:

some-module.js
other-module.js
static-content.json

requireDir on that directory would return an object like:

{
  someModule: <module.exports of some-module.js>,
  ...
}
Usage
lsFs.requireDir(pathToDir).then(function(requiredDirObj) {
    // use required modules
});
Arguments
  1. pathToDir (String) Path to the directory you would like to recursively require

Keywords

FAQs

Package last updated on 26 Feb 2015

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