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

webpack-hmr-singleton

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-hmr-singleton

Utility lib to help define a hot-reloadable singleton

  • 1.0.0-dev
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
117
increased by34.48%
Maintainers
1
Weekly downloads
 
Created
Source

Webpack HMR Singleton

Utility lib to help define a hot-reloadable singleton

If you want something fancier, you might want to try ud. This goal of this lib is to remain very small in scope, bytes and dependencies.

Install

npm install webpack-hmr-singleton

Usage

var single = require('webpack-hmr-singleton');

var thing = single(module, 'thing', function() {
  return { anything: ['you', 'want'] };
});

On the first run, the function will be called and single will return the object you've specified. After every hot reload the function won't be called and you'll just get the first one back again.

This is only really useful if the value is something mutable, that you modify during the running of your program, and want it to stick around after a hot reload.

Docs

single(module, key, fn)

  • module - The CommonJS module object
  • key - A key to identify this item, must be unique per module
  • fn - A function that will return the object to singleton.

License

Copyright 2016 Glen Mailer.

MIT Licened.

Keywords

FAQs

Package last updated on 28 Feb 2016

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