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

fount

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fount - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0-1

11

CHANGELOG.md

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

## 0.2.x
### 0.2.0
* bug fix - inject and resolve across multiple containers now works correctly
* functions that can't be resolved in static or scoped lifecycles immediately will be once all dependencies become available
## 0.1.X
### 0.1.1
* #10 - Calls to previously resolved scope/key pairs return promises for consistency
### 0.1.0

@@ -4,0 +15,0 @@

5

package.json
{
"name": "fount",
"version": "0.1.0",
"version": "0.2.0-1",
"description": "A source from which dependencies flow",

@@ -36,4 +36,5 @@ "main": "./src/index.js",

"postal": "^1.0.2",
"sinon": "~1.14.1"
"sinon": "~1.14.1",
"whistlepunk": "^0.3.3"
}
}

72

src/index.js

@@ -216,3 +216,2 @@ var _ = require( 'lodash' );

if ( _.isFunction( fn ) ) {

@@ -240,8 +239,9 @@ dependencies = checkDependencies( fn, dependencies );

var originalKey = k;
var effectiveContainer = ctr;
var parts = k.split( /[._]/ );
if ( parts.length > 1 ) {
ctr = container( parts[ 0 ] );
effectiveContainer = container( parts[ 0 ] );
k = parts[ 1 ];
}
hash[ originalKey ] = ctr[ k ]( scopeName );
hash[ originalKey ] = effectiveContainer[ k ]( scopeName );
} );

@@ -307,8 +307,28 @@ return whenKeys.all( hash );

if ( cache[ key ] ) {
return cache[ key ];
} else if ( _.isFunction( value ) && dependencies && canResolve( containerName, dependencies, scopeName ) ) {
var args = dependencies.map( function( key ) {
return resolve( containerName, key, scopeName );
} );
return whenFn.apply( value, args ).then( store );
return when.resolve( cache[ key ] );
} else if ( _.isFunction( value ) ) {
if( dependencies && canResolve( containerName, dependencies, scopeName ) ) {
var args = dependencies.map( function( key ) {
return resolve( containerName, key, scopeName );
} );
return whenFn.apply( value, args ).then( store );
} else {
var resolvedValue;
return function() {
if( resolvedValue ) {
return when( resolvedValue );
} else {
return when.promise( function( res ) {
if( dependencies && canResolve( containerName, dependencies ) ) {
var args = dependencies.map( function( key ) {
return resolve( containerName, key, scopeName );
} );
res( whenFn.apply( value, args ).then( store ) );
} else {
res( value );
}
} );
}
};
}
} else {

@@ -328,7 +348,31 @@ return when.promise( function( resolve ) {

var promise;
if ( _.isFunction( value ) && dependencies && canResolve( containerName, dependencies ) ) {
var args = dependencies.map( function( key ) {
return resolve( containerName, key );
} );
promise = whenFn.apply( value, args );
if ( _.isFunction( value ) ) {
if( dependencies && canResolve( containerName, dependencies ) ) {
var args = dependencies.map( function( key ) {
return resolve( containerName, key );
} );
promise = whenFn.apply( value, args );
} else {
var resolvedValue;
return function() {
if( resolvedValue ) {
return when( resolvedValue );
} else {
return when.promise( function( res ) {
if( dependencies && canResolve( containerName, dependencies ) ) {
var args = dependencies.map( function( key ) {
return resolve( containerName, key );
} );
whenFn.apply( value, args )
.then( function( x ) {
resolvedValue = x;
res( x );
} );
} else {
res( value );
}
} );
}
};
}
} else {

@@ -335,0 +379,0 @@ promise = ( value && value.then ) ? value : when( value );

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