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

smart-fs

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smart-fs - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

22

lib/logic/smart-read.js

@@ -17,10 +17,13 @@ const assert = require('assert');

assert(ctx.treatAs === null || typeof ctx.treatAs === 'string');
let result;
switch (ctx.treatAs || getExt(filepath)) {
case 'json':
return JSON.parse(fs.readFileSync(filepath, 'utf8'));
result = JSON.parse(fs.readFileSync(filepath, 'utf8'));
break;
case 'yml':
case 'yaml':
return yaml.load(filepath, {});
result = yaml.load(filepath, {});
break;

@@ -31,8 +34,17 @@ case 'js':

return require(filepath);
result = require(filepath);
break;
default:
return fs.readFileSync(filepath, 'utf8').split('\n');
result = fs.readFileSync(filepath, 'utf8').split('\n');
if (result[result.length - 1].trim() === '') {
result.pop();
}
break;
}
return result;
};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sb2dpYy9zbWFydC1yZWFkLmpzIl0sIm5hbWVzIjpbImFzc2VydCIsInJlcXVpcmUiLCJmcyIsInlhbWwiLCJnZXRFeHQiLCJtb2R1bGUiLCJleHBvcnRzIiwiZmlsZXBhdGgiLCJvcHRpb25zIiwiT2JqZWN0IiwiQXJyYXkiLCJpc0FycmF5IiwiY3R4IiwiYXNzaWduIiwidHJlYXRBcyIsImtleXMiLCJsZW5ndGgiLCJKU09OIiwicGFyc2UiLCJyZWFkRmlsZVN5bmMiLCJsb2FkIiwiY2FjaGUiLCJyZXNvbHZlIiwic3BsaXQiXSwibWFwcGluZ3MiOiJBQUFBLE1BQU1BLE1BQU0sR0FBR0MsT0FBTyxDQUFDLFFBQUQsQ0FBdEI7O0FBQ0EsTUFBTUMsRUFBRSxHQUFHRCxPQUFPLENBQUMsSU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XVpcmVcbiAgICAgIHJlc3VsdCA9IHJlcXVpcmUoZmlsZXBhdGgpO1xuICAgICAgYnJlYWs7XG4gICAgZGVmYXVsdDpcbiAgICAgIHJlc3VsdCA9IGZzLnJlYWRGaWxlU3luYyhmaWxlcGF0aCwgJ3V0ZjgnKS5zcGxpdCgnXFxuJyk7XG4gICAgICBpZiAocmVzdWx0W3Jlc3VsdC5sZW5ndGggLSAxXS50cmltKCkgPT09ICcnKSB7XG4gICAgICAgIHJlc3VsdC5wb3AoKTtcbiAgICAgIH1cbiAgICAgIGJyZWFrO1xuICB9XG4gIHJldHVybiByZXN1bHQ7XG59O1xuIl19
{
"name": "smart-fs",
"version": "1.1.1",
"version": "1.1.2",
"description": "Abstraction Layer for File Management.",

@@ -50,3 +50,3 @@ "main": "lib/index.js",

"coveralls": "3.0.3",
"js-gardener": "1.38.0",
"js-gardener": "1.38.1",
"nyc": "13.3.0",

@@ -53,0 +53,0 @@ "semantic-release": "15.13.3",

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