/*! co-work - v0.4.3 - 2015-12-07 * https://github.com/thiagoh/co-work * Copyright (c) 2015 Thiago Andrade; Licensed */ !function(a){"use strict";var b=function(a,b,c,d){if("undefined"==typeof b||null===b)throw new Error("Routines must be defined");if("function"==typeof b&&(b=[b]),!(b.length<=0)){if(a="string"==typeof a?parseInt(a,10):a,isNaN(a)===!0)throw new Error("Invalid slots");if(0>a)throw new Error("Invalid slots. It must be positive");if(0===a)throw new Error("Invalid slots. It must be at least 1");"function"==typeof c&&"function"!=typeof d?(d=c,c=[]):c="undefined"==typeof c||"[object Array]"!==Object.prototype.toString.call(c)?[]:c;var e,f=[],g=Math.max(b.length,c.length),h=g,i=function(){var a=f.shift();return--h,"undefined"==typeof a&&f.length<=0?void(0===h&&"function"==typeof d&&d()):void j(a.command,a.arg)},j=function(a,b){var c=a.call(null,b);if("undefined"==typeof c)i();else{var d=c["finally"]||c.fin||c.then;"function"==typeof d?d.call(c,function(){i()}):i()}};for(a=Math.min(a,g),e=a;g>e;e++)f.push({command:b[e]||b[0],arg:(c||[])[e],index:e});for(e=0;a>e;e++)j(b[e]||b[0],(c||[])[e])}};a.work=b,a.batch=b}("object"==typeof exports&&exports||this);