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

file-reader

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-reader - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

44

index.js

@@ -19,4 +19,7 @@ /*!

read: function(fp) {
fp = path.resolve(fp);
return reader(path.extname(fp))(fp);
var ext = path.extname(fp);
if (!reader.hasOwnProperty(ext)) {
ext = '.txt';
}
return reader[ext](path.resolve(fp));
}

@@ -35,23 +38,18 @@ }, options));

function reader(ext) {
switch (ext) {
// Requireable files
case '.js':
case '.json':
return require;
var reader = {
// Functions
'.js' : require,
// Strings
case '.txt':
case '.md':
case '.hbs':
return fs.readFileSync;
// Strings
'.hbs' : fs.readFileSync,
'.md' : fs.readFileSync,
'.tmpl': fs.readFileSync,
'.txt' : fs.readFileSync,
// Data
case '.yml':
case '.yaml':
return fs.readYAMLSync;
}
}
// Objects
'.json': require,
'.yaml': fs.readYAMLSync,
'.yml' : fs.readYAMLSync,
};
/**

@@ -66,8 +64,12 @@ * Camelcase rename function to pass to [map-files].

var str = path.basename(fp, path.extname(fp));
if (/\./.test(str)) {
str = str.split('.')[0];
}
if (str.length === 1) {
return str;
}
return str.toLowerCase().replace(/[-_.](\w|$)/g, function (_, ch) {
str = str.replace(/^[-_.\s]+/, '').toLowerCase();
return str.replace(/[-_.]+(\w|$)/g, function (_, ch) {
return ch.toUpperCase();
});
}
{
"name": "file-reader",
"description": "Read a glob of files, dynamically choosing the reader or requiring the files based on the file extension.",
"version": "0.2.1",
"version": "0.2.2",
"homepage": "https://github.com/jonschlinkert/file-reader",

@@ -6,0 +6,0 @@ "author": {

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