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

mirror

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mirror

  • 0.1.0
  • npm
  • Socket score

Version published
Weekly downloads
118
increased by55.26%
Maintainers
0
Weekly downloads
 
Created
Source

Mirror

Mirror node.js module files to the browser. Simplifies application development when writing js code that is used both client-side and server-side.

Tested with

  • joyent node v0.2.6
  • creationix step v0.0.4
  • visionmedia express 1.0.7

Usage

Mirror works by resolving module paths using the node module object cache. Module files to be mirrored should be represented by a string path:

[module]/[filepath]
  • module is the module name as would be used when calling require().
  • filepath is the path to the desired file relative to the module root directory.

Files can be mirrored directly or packaged together in the case javascript, css or other text files.

// Express middleware that serves file described by <asset>
mirror.file( <asset> );

// Express middleware that serves assets joined (\n). [headers] is an
// optional headers object, defaults to that suitable for javascript.
mirror.asset( [ <asset1>, <asset2>, ... <assetn> ], [headers] );

Example

Create an Express server, add a vendor.js package of assets and serve some module css/image files:

var server = require('express').createServer();
var mirror = require('mirror');

server.get('/vendor.js', mirror.assets([
    'underscore/underscore.js',
    'backbone/backbone.js',
    'bones/bones.js',
    'bones-admin/bones-admin.js'
]));
server.get('/bones-admin.css', mirror.file('bones-admin/bones-admin.css'));
server.get('/bones-admin.png', mirror.file('bones-admin/bones-admin.png'));

server.listen(8889);

Authors

  • Young Hahn

FAQs

Package last updated on 02 May 2011

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