Skip to content

Commit

Permalink
added licence
Browse files Browse the repository at this point in the history
  • Loading branch information
espretto committed May 20, 2014
1 parent 4102e56 commit c830ba1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 26 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,8 @@ in your browser ( requires `grunt build` )
```sh
$ python -m SimpleHTTPServer
```
then fire up your favorite browser and point it to [localhost:8000/test](http://localhost:8000/test) to run the tests or [localhost:8000/docs](localhost:8000/docs/src/whif.js.html) to read Promise's story - the annotated source.
then fire up your favorite browser and point it to [localhost:8000/test](http://localhost:8000/test) to run the tests or [localhost:8000/docs](localhost:8000/docs/src/whif.js.html) to read Promise's story - the annotated source.

licence
-------
[MIT](http://mariusrunge.com/mit-licence.html)
6 changes: 6 additions & 0 deletions src/whif.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

/*!
* whif javascript library released under MIT licence
* http://mariusrunge.com/mit-licence.html
*/

( function( root ) {

// baseline setup
Expand Down
58 changes: 33 additions & 25 deletions test/whif.test.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -7541,6 +7541,12 @@ if (typeof module !== 'undefined' && module.exports) {

},{}],39:[function(require,module,exports){
(function (process){

/*!
* whif javascript library released under MIT licence
* http://mariusrunge.com/mit-licence.html
*/

( function( root ) {

// baseline setup
Expand Down Expand Up @@ -7580,29 +7586,15 @@ if (typeof module !== 'undefined' && module.exports) {
}
);
}() ),

// inspired by [WebReflection](https://gist.github.com/WebReflection/2953527)
nextTick = ( function(){

var nextTick = typeof process === str_object && process.nextTick,
prefixes = 'webkitR-mozR-msR-oR-r'.split( '-' ),
i = prefixes.length;

while( i-- && !isFunction( nextTick ) ){
nextTick = root[ prefixes[ i ] + 'equestAnimationFrame' ];
}

return nextTick || root.setImmediate || setTimeout;

}() ),

array_forEach = [].forEach || function( iter ) {
for ( var array = this, i = array.length; i--; iter( array[ i ], i, array ) );
};

function id( value ) { return value }
function cancel( error ) { throw error }
function isPrimitve( value ){

function isPrimitive( value ){
var type = typeof value;
return value == null || type !== str_object && type !== str_function;
}
Expand All @@ -7622,7 +7614,7 @@ if (typeof module !== 'undefined' && module.exports) {

var that = this;

if ( !( that instanceof whif ) ) return new whif( then );
if ( !( that instanceof whif ) ) return new whif( then, sync );

that._state = PENDING;
that._queue = [];
Expand Down Expand Up @@ -7695,7 +7687,7 @@ if (typeof module !== 'undefined' && module.exports) {
adopt( that, value._state, value._value );
}

} else if ( !isPrimitve( value ) ) {
} else if ( !isPrimitive( value ) ) {

var called = false, then;

Expand Down Expand Up @@ -7785,30 +7777,46 @@ if (typeof module !== 'undefined' && module.exports) {
if( promise._sync ){
_run();
} else {
nextTick( _run );
whif.nextTick( _run );
}
}

// whif.__when__ ( public )
// __whif.nextTick__ ( public )
//
// inspired by [WebReflection](https://gist.github.com/WebReflection/2953527)
//
whif.nextTick = ( function(){

var nextTick = typeof process === str_object && process.nextTick,
prefixes = 'webkitR-mozR-msR-oR-r'.split( '-' ),
i = prefixes.length;

while( !isFunction( nextTick ) && i-- ){
nextTick = root[ prefixes[ i ] + 'equestAnimationFrame' ];
}

return nextTick || root.setImmediate || setTimeout;

}() );

// __whif.when__ ( public )
//
// - group whifs and resolve when all are resolved,
// reject as soon as one is rejected
// - `._resolve()` each passed item and proxy its future value
// or the item _as is_ to a newly created whif which in turn
// resolves/rejects the master whif
//
whif.group = function() {
whif.group = function( args, sync ) {

var args = arguments;

return new whif( function( resolve, reject ) {

var args_len = args.length,
values = Array( args_len );

// the index `i` needs be closured
array_forEach.call( args, function( value, i ) {
var proxy = new whif();
var proxy = new whif( null, sync );
proxy.then(
function( value ) {
values[ i ] = value;
Expand All @@ -7822,7 +7830,7 @@ if (typeof module !== 'undefined' && module.exports) {
);
proxy._resolve( value );
} )
} );
}, sync );
}

// export
Expand Down

0 comments on commit c830ba1

Please sign in to comment.