Comparing version 0.1.0 to 0.2.0-1
@@ -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 @@ |
{ | ||
"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" | ||
} | ||
} |
@@ -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 ); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22670
400
0
7