Socket
Socket
Sign inDemoInstall

loader-cache

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loader-cache - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

69

index.js

@@ -38,4 +38,4 @@ /*!

* @param {String} `ext`
* @param {Function} `fn`
* @param {String|Object} `types`
* @param {Function|Array} `fn`
* @param {String} `type`
* @return {Object}

@@ -45,22 +45,10 @@ * @api private

Loaders.prototype._register = function(ext, fn, types) {
Loaders.prototype._register = function(ext, fn, type) {
ext = formatExt(ext);
if (types && typeof types === 'string') {
var type = types;
types = {};
types[type] = true;
if (Array.isArray(fn)) {
return this.compose(ext, fn, type);
}
forOwn(types, function (value, key) {
var type = pickLoader(key);
if (value && type) {
if (Array.isArray(fn)) {
return this.compose(ext, fn, type);
}
fn.type = type;
this.cache[type] = this.cache[type] || {};
this.cache[type][ext] = [fn];
}
}, this);
fn.type = type;
this.cache[type] = this.cache[type] || {};
this.cache[type][ext] = [fn];
return this;

@@ -470,23 +458,2 @@ };

/**
* Determine if the string is a valid and supported loader type.
*
* @param {String} `str` string to validate
* @return {String} validated string
*/
function pickLoader(str) {
if (!str || typeof str !== 'string') return undefined;
var type;
var capital = /[A-Z]/.exec(str);
if (capital) {
var i = str.indexOf(capital);
type = str.slice(i).toLowerCase();
} else {
type = str;
}
if (Loaders.loaderTypes.indexOf(type) === -1) return undefined;
return type;
}
/**
* Get a loader based on the given pattern.

@@ -519,21 +486,1 @@ *

}
/**
* Iterate over the key/value pairs on an object and do something.
*
* @param {Object} `obj` Object to iterate over
* @param {Function} `cb` Iterator callback
* @param {Object} `thisArg` Optional `this` context
* @api private
*/
function forOwn(obj, cb, thisArg) {
var keys = Object.keys(obj);
var len = keys.length;
var i = 0;
while (len--) {
var key = keys[i++];
var value = obj[key];
cb.call(thisArg, value, key);
}
}

2

package.json
{
"name": "loader-cache",
"description": "Register loader functions that dynamically read, parse or otherwise transform file contents when the name of the loader matches a file extension. You can also compose loaders from other loaders.",
"version": "0.2.2",
"version": "0.2.3",
"homepage": "https://github.com/jonschlinkert/loader-cache",

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

@@ -44,15 +44,2 @@ /*!

});
it('should add a child loader for all types', function () {
loaders._register('foo', ['read'], { isSync: true, isAsync: true, isPromise: true, isStream: true });
loaders.cache.sync.should.have.properties('read', 'foo');
loaders.cache.async.should.have.properties('read', 'foo');
loaders.cache.promise.should.have.properties('read', 'foo');
loaders.cache.stream.should.have.properties('read', 'foo');
loaders.cache.sync.foo[0].type.should.eql('sync');
loaders.cache.async.foo[0].type.should.eql('async');
loaders.cache.promise.foo[0].type.should.eql('promise');
loaders.cache.stream.foo[0].type.should.eql('stream');
});
});

@@ -59,0 +46,0 @@

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