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

flacon

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flacon - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

8

index.js

@@ -0,1 +1,3 @@

'use strict';
// A dependency injection container, holding all modules, mocks and dependencies.

@@ -19,3 +21,4 @@ var Flacon = function () {

if (module.cache === notCached) {
var hasMocks = Object.keys(mocks).length > 0;
if (module.cache === notCached || hasMocks) {
// merge dependencies and mocks

@@ -29,3 +32,4 @@ deps = module.deps.map(function (id) {

});
module.cache = module.factory.apply(null, deps);
if (hasMocks) return module.factory.apply({}, deps);
module.cache = module.factory.apply({}, deps);
}

@@ -32,0 +36,0 @@

{
"name": "flacon",
"description": "A hyperminimal dependency injection framework.",
"version": "0.3.0",
"version": "0.3.1",
"main": "index.js",

@@ -6,0 +6,0 @@ "files": ["index.js", "readme.md"],

@@ -88,3 +88,3 @@ # flacon

During testing, we can easily **manipulate or mock a dependency**.
During testing, we can easily **manipulate or mock a dependency**. Note that this loads the module without caching.

@@ -116,4 +116,31 @@ ```js

## API
### `flacon(id, [mocks])`
Loads a module by `id`. Returns the module.
If `mocks` are passed, they will be used to instead of its dependencies. Otherwise the module will be cached.
- `id`: The identifier, unique to the container.
- `mocks`: A map of callbacks, mapped by module `id`. The return value of each callback will be the mock.
### `flacon.publish(id, [deps], factory)`
Registers a module by `id`. Returns the module's `factory`.
- `id`: The identifier, unique to the container.
- `deps`: An optional array of dependency `id`s. Their corresponding modules will be passed into `factory`.
- `factory`: A function, taking the dependencies, that returns the module.
### `flacon.flush()`
Removes a module from the cache. Returns the container.
- `id`: The identifier, unique to the container.
## Contributing
If you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/derhuerst/flacon/issues).
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