loader-cache
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.
Example usage
var LoaderCache = ;var loaders = ; // register a loader for reading filesloaders; // register a loader for parsing YAMLloaders; // create a loader from any combination of other// registered loaders and functions.loaders; // pass a loader stack or the name of a loader to `.compose()` // to create the actual function to be used for loadingvar fn = loaders;var data = ;
Install
Install with npm
$ npm i loader-cache --save
API
LoaderCache
Create a new instance of LoaderCache
Example
var LoaderCache = ;var loaders = ;
.iterator
Register an iterator function of the given type
. Types typically represent a kind of flow-control, like sync
, promise
, stream
, async
etc.
Params
type
{String}options
{Object}fn
{Function}: The actual iterator function.returns
{Object}
Example
loader;
.loader
Register a loader. The first argument is the name of the loader to register.
Params
name
{String}options
{Object}fns
{Function|Array}: One or more loader functions or names of other registered loaders.returns
{Array}
Example
// create a loader from other loaders.loaders;// pass a functionloaders;// combinationloaders;
.compose
Compose the actual load
function from a loader stack.
Params
name
{String}: The name of the loader stack to use.options
{Object}stack
{Array|Function}: Additional loader names or functions.returns
{Function}
Example
var fn = loaders;// load some filesvar files = ;
Related libs
- config-cache: General purpose JavaScript object storage methods.
- cache-base: Generic object cache for node.js/javascript projects.
- engine-cache: express.js inspired template-engine manager.
- helper-cache: Easily register and get helper functions to be passed to any template engine or node.js… more
- option-cache: Simple API for managing options in JavaScript applications.
- parser-cache: Cache and load parsers, similiar to consolidate.js engines.
Running tests
Install dev dependencies:
$ npm i -d && npm test
Code coverage
Please help improve code coverage by adding unit tests.
-----------------|-----------|-----------|-----------|-----------|File | % Stmts |% Branches | % Funcs | % Lines |-----------------|-----------|-----------|-----------|-----------| loader-cache/ | 9127 | 8235 | 8571 | 925 | indexjs | 9127 | 8235 | 8571 | 925 |-----------------|-----------|-----------|-----------|-----------|All files | 9127 | 8235 | 8571 | 925 |-----------------|-----------|-----------|-----------|-----------|
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on June 29, 2015.