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

boxcars

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

boxcars

boxcars is a tiny collection library that comes with built-in caching for preloading contents.

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-43.75%
Maintainers
1
Weekly downloads
 
Created
Source

boxcars is a zero-dependency tiny library for fetching remote resources. It supports both NodeJS and web browsers.

Tested Platforms: Node, IE6, Chrome, Firefox

Install

$ npm install boxcars

Usage

one-liner:

var boxcars  = require('boxcars');

boxcars('http://google.com', 'http://amazon.com', 'http://github.com')(function(error, homepages){
  console.log( homepages[0] ); // puts the homepage of google.com
});

Defining collections:


var templates = boxcars('templates/foo.html', 'templates/bar.html', 'templates/qux.html');

templates('templates/corge.html', function(error, templates){

  console.log( templates.length ); // 4
  console.log( templates[0] ); // will put the content of templates/foo.html

});

Passing Objects:

templates({ 'corge': 'templates/corge.html', 'eggs': 'templates/eggs.html' }, function(error, moreTemplates){
 if(error) throw error;

 console.log( moreTemplates.corge );

});

Preloading:

templates.cache({
  'quux.json': '{}',
  'templates/foo.html': '<strong>Hello {{ name }}!</strong>',
  'templates/bar.html': '<strong>Hello {{ name }}!</strong>'
});

Reset the cache:

templates.cache(undefined);

Testing

Publish the tests and visit localhost:1314 with the browser you want to test.

$ make test

To run the tests on NodeJS:

$ make test do=command cmd=node

To see the summary of the results;

$ make test do=verify

Keywords

FAQs

Package last updated on 01 May 2012

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