asynchronize
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -1,24 +0,8 @@ | ||
/*global define */ | ||
/* global define */ | ||
(function (root) { | ||
'use strict'; | ||
// Utilities | ||
// --------- | ||
// process.nextTick polyfill for browsers | ||
var nextTick = ( | ||
typeof process !== 'undefined' && | ||
process.platform && | ||
process.nextTick | ||
) || setTimeout; | ||
// Asynchronize Function | ||
// --------------------- | ||
// | ||
// Make a synchronous function appear asynchronous. | ||
// | ||
function asynchronize (fn) { | ||
// Validate arguments | ||
if (typeof fn !== 'function') { | ||
@@ -28,18 +12,11 @@ throw new Error('Invalid argument, function expected'); | ||
// Curry a new function | ||
return function () { | ||
var args, next, error, result; | ||
// Get arguments, take the last one as a callback | ||
args = Array.prototype.slice.call(arguments); | ||
var args = Array.prototype.slice.call(arguments); | ||
var next = (typeof args[args.length - 1] === 'function' ? args.pop() : null); | ||
// Get the callback | ||
if (typeof args[args.length - 1] === 'function') { | ||
next = args.pop(); | ||
} | ||
// Defer execution | ||
nextTick(function () { | ||
var error; | ||
var result; | ||
// Get the result of the function call | ||
try { | ||
@@ -51,3 +28,2 @@ result = fn.apply(null, args); | ||
// Callback (if there is one) | ||
if (next) { | ||
@@ -63,6 +39,9 @@ next(error, result); | ||
// Compat function: process.nextTick/setTimeout | ||
var nextTick = ( | ||
typeof process !== 'undefined' && | ||
process.platform && | ||
process.nextTick | ||
) || setTimeout; | ||
// Exports | ||
// ------- | ||
// AMD | ||
@@ -83,3 +62,2 @@ if (typeof define !== 'undefined' && define.amd) { | ||
} (this)); |
{ | ||
"name": "asynchronize", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
@@ -20,9 +20,7 @@ "description": "Make synchronous functions look asynchronous", | ||
"devDependencies": { | ||
"browserify": "~2.2", | ||
"express": "~3.1", | ||
"jshint": "~0.9", | ||
"mocha": "~1.8", | ||
"proclaim": "~1.0", | ||
"sinon": "~1.6", | ||
"supervisor": "~0.5" | ||
"jshint": "~2.1", | ||
"mocha": "~1.11", | ||
"mocha-srv": "~0.1", | ||
"proclaim": "~1.3", | ||
"sinon": "~1.6" | ||
}, | ||
@@ -29,0 +27,0 @@ |
@@ -7,3 +7,3 @@ | ||
**Current Version:** *1.1.0* | ||
**Current Version:** *1.2.0* | ||
**Build Status:** [![Build Status][travis-status]][travis] | ||
@@ -44,8 +44,13 @@ **Node Support:** *0.6, 0.8, 0.10* | ||
On the client side, you can either install Asynchronize through [Component][component]: | ||
On the client side, you can either install Asynchronize through [Bower][bower]/[Component][component]: | ||
```sh | ||
$ bower install asynchronize | ||
$ component install rowanmanning/asynchronize | ||
``` | ||
```sh | ||
$ component install rowanmanning/asynchronize | ||
``` | ||
or by simply including `asynchronize.js` in your page: | ||
@@ -143,2 +148,3 @@ | ||
[async]: https://github.com/caolan/async | ||
[bower]: http://bower.io/ | ||
[component]: https://github.com/component/component | ||
@@ -145,0 +151,0 @@ [make]: http://gnuwin32.sourceforge.net/packages/make.htm |
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
7853
5
6
153
55