Socket
Socket
Sign inDemoInstall

catiline

Package Overview
Dependencies
0
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.8.1 to 2.8.3

component.json

2

bower.json
{
"name": "catiline",
"version": "2.8.1",
"version": "2.8.3",
"main": "dist/catiline.js",

@@ -5,0 +5,0 @@ "ignore": [

@@ -1,2 +0,2 @@

/*! catiline 2.8.1 2013-09-11*/
/*! catiline 2.8.3 2013-09-19*/
/*!©2013 Calvin Metcalf @license MIT https://github.com/calvinmetcalf/catiline */

@@ -12,251 +12,187 @@ if (typeof document === 'undefined') {

'use strict';
/*!From setImmediate Copyright (c) 2012 Barnesandnoble.com,llc, Donavon West, and Domenic Denicola @license MIT https://github.com/NobleJS/setImmediate */
(function(attachTo,global) {
if(global.setImmediate){
attachTo.setImmediate = global.setImmediate;
return;
//lifted mostly from when
//https://github.com/cujojs/when/
var nextTick;
if (typeof setImmediate === 'function') {
nextTick = setImmediate.bind(global,drainQueue);
}else{
var codeWord = 'com.catiline.setImmediate' + Math.random();
addEventListener('message', function (event) {
// This will catch all incoming messages (even from other windows!), so we need to try reasonably hard to
// avoid letting anyone else trick us into firing off. We test the origin is still this window, and that a
// (randomly generated) unpredictable identifying prefix is present.
if (event.source === window && event.data === codeWord) {
drainQueue();
}
}, false);
nextTick = function() {
postMessage(codeWord, '*');
};
}
var mainQueue = [];
/**
* Enqueue a task. If the queue is not currently scheduled to be
* drained, schedule it.
* @param {function} task
*/
catiline.nextTick = function(task) {
if (mainQueue.push(task) === 1) {
nextTick();
}
var tasks = (function () {
function Task(handler, args) {
this.handler = handler;
this.args = args;
}
Task.prototype.run = function () {
// See steps in section 5 of the spec.
if (typeof this.handler === 'function') {
// Choice of `thisArg` is not in the setImmediate spec; `undefined` is in the setTimeout spec though:
// http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html
this.handler.apply(undefined, this.args);
} else {
var scriptSource = '' + this.handler;
/*jshint evil: true */
eval(scriptSource);
}
};
};
var nextHandle = 1; // Spec says greater than zero
var tasksByHandle = {};
var currentlyRunningATask = false;
/**
* Drain the handler queue entirely, being careful to allow the
* queue to be extended while it is being processed, and to continue
* processing until it is truly empty.
*/
function drainQueue() {
var i = 0;
var task;
var innerQueue = mainQueue;
mainQueue = [];
/*jslint boss: true */
while (task = innerQueue[i++]) {
task();
}
return {
addFromSetImmediateArguments: function (args) {
var handler = args[0];
var argsToHandle = Array.prototype.slice.call(args, 1);
var task = new Task(handler, argsToHandle);
}
var func = 'function';
// Creates a deferred: an object with a promise and corresponding resolve/reject methods
function Deferred() {
// The `handler` variable points to the function that will
// 1) handle a .then(onFulfilled, onRejected) call
// 2) handle a .resolve or .reject call (if not fulfilled)
// Before 2), `handler` holds a queue of callbacks.
// After 2), `handler` is a simple .then handler.
// We use only one function to save memory and complexity.
var handler = function(onFulfilled, onRejected, value) {
// Case 1) handle a .then(onFulfilled, onRejected) call
if (onFulfilled !== handler) {
var createdDeffered = createDeferred();
handler.queue.push({
deferred: createdDeffered,
resolve: onFulfilled,
reject: onRejected
});
return createdDeffered.promise;
}
var thisHandle = nextHandle++;
tasksByHandle[thisHandle] = task;
return thisHandle;
},
runIfPresent: function (handle) {
// From the spec: 'Wait until any invocations of this algorithm started before this one have completed.'
// So if we're currently running a task, we'll need to delay this invocation.
if (!currentlyRunningATask) {
var task = tasksByHandle[handle];
if (task) {
currentlyRunningATask = true;
try {
task.run();
} finally {
delete tasksByHandle[handle];
currentlyRunningATask = false;
}
}
} else {
// Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
// 'too much recursion' error.
global.setTimeout(function () {
tasks.runIfPresent(handle);
}, 0);
}
},
remove: function (handle) {
delete tasksByHandle[handle];
// Case 2) handle a .resolve or .reject call
// (`onFulfilled` acts as a sentinel)
// The actual function signature is
// .re[ject|solve](sentinel, success, value)
var action = onRejected ? 'resolve' : 'reject';
for (var i = 0, l = handler.queue.length; i < l; i++) {
var queue = handler.queue[i];
var deferred = queue.deferred;
var callback = queue[action];
if (typeof callback !== func) {
deferred[action](value);
}
else {
execute(callback, value, deferred);
}
}
// Replace this handler with a simple resolved or rejected handler
handler = createHandler(promise, value, onRejected);
};
function Promise() {
this.then = function(onFulfilled, onRejected) {
return handler(onFulfilled, onRejected);
};
}());
// Installs an event handler on `global` for the `message` event: see
// * https://developer.mozilla.org/en/DOM/window.postMessage
// * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
}
var promise = new Promise();
this.promise = promise;
// The queue of deferreds
handler.queue = [];
var MESSAGE_PREFIX = 'com.catilinejs.setImmediate' + Math.random();
function isStringAndStartsWith(string, putativeStart) {
return typeof string === 'string' && string.substring(0, putativeStart.length) === putativeStart;
this.resolve = function(value) {
if (handler.queue) {
handler(handler, true, value);
}
};
function onGlobalMessage(event) {
// This will catch all incoming messages (even from other windows!), so we need to try reasonably hard to
// avoid letting anyone else trick us into firing off. We test the origin is still this window, and that a
// (randomly generated) unpredictable identifying prefix is present.
if (event.source === global && isStringAndStartsWith(event.data, MESSAGE_PREFIX)) {
var handle = event.data.substring(MESSAGE_PREFIX.length);
tasks.runIfPresent(handle);
}
this.fulfill = this.resolve;
this.reject = function(reason) {
if (handler.queue) {
handler(handler, false, reason);
}
if (global.addEventListener) {
global.addEventListener('message', onGlobalMessage, false);
} else {
global.attachEvent('onmessage', onGlobalMessage);
}
};
}
attachTo.setImmediate = function () {
var handle = tasks.addFromSetImmediateArguments(arguments);
function createDeferred() {
return new Deferred();
}
// Make `global` post a message to itself with the handle and identifying prefix, thus asynchronously
// invoking our onGlobalMessage listener above.
global.postMessage(MESSAGE_PREFIX + handle, '*');
// Creates a fulfilled or rejected .then function
function createHandler(promise, value, success) {
return function(onFulfilled, onRejected) {
var callback = success ? onFulfilled : onRejected;
if (typeof callback !== func) {
return promise;
}
var result = createDeferred();
execute(callback, value, result);
return result.promise;
};
}
return handle;
};
})(catiline,global);
catiline.deferred = (function (tick) {
var exports;
var func = 'function';
// Creates a deferred: an object with a promise and corresponding resolve/reject methods
function Deferred() {
// The `handler` variable points to the function that will
// 1) handle a .then(onFulfilled, onRejected) call
// 2) handle a .resolve or .reject call (if not fulfilled)
// Before 2), `handler` holds a queue of callbacks.
// After 2), `handler` is a simple .then handler.
// We use only one function to save memory and complexity.
var handler = function(onFulfilled, onRejected, value) {
// Case 1) handle a .then(onFulfilled, onRejected) call
var createdDeffered;
if (onFulfilled !== handler) {
createdDeffered = createDeferred();
handler.queue.push({
deferred: createdDeffered,
resolve: onFulfilled,
reject: onRejected
});
return createdDeffered.promise;
}
// Case 2) handle a .resolve or .reject call
// (`onFulfilled` acts as a sentinel)
// The actual function signature is
// .re[ject|solve](sentinel, success, value)
var action = onRejected ? 'resolve' : 'reject',
queue, deferred, callback;
for (var i = 0, l = handler.queue.length; i < l; i++) {
queue = handler.queue[i];
deferred = queue.deferred;
callback = queue[action];
if (typeof callback !== func) {
deferred[action](value);
}
else {
execute(callback, value, deferred);
}
}
// Replace this handler with a simple resolved or rejected handler
handler = createHandler(promise, value, onRejected);
};
function Promise() {
this.then = function(onFulfilled, onRejected) {
return handler(onFulfilled, onRejected);
};
// Executes the callback with the specified value,
// resolving or rejecting the deferred
function execute(callback, value, deferred) {
catiline.nextTick(function() {
try {
var result = callback(value);
if (result && typeof result.then === func) {
result.then(deferred.resolve, deferred.reject);
}
var promise = new Promise();
this.promise = promise;
// The queue of deferreds
handler.queue = [];
this.resolve = function(value) {
if(handler.queue){
handler(handler, true, value);
}
};
this.fulfill = this.resolve;
this.reject = function(reason) {
if(handler.queue){
handler(handler, false, reason);
}
};
else {
deferred.resolve(result);
}
}
function createDeferred() {
return new Deferred();
catch (error) {
deferred.reject(error);
}
// Creates a fulfilled or rejected .then function
function createHandler(promise, value, success) {
return function(onFulfilled, onRejected) {
var callback = success ? onFulfilled : onRejected,
result;
if (typeof callback !== func) {
return promise;
}
execute(callback, value, result = createDeferred());
return result.promise;
};
}
// Executes the callback with the specified value,
// resolving or rejecting the deferred
function execute(callback, value, deferred) {
tick(function() {
var result;
try {
result = callback(value);
if (result && typeof result.then === func) {
result.then(deferred.resolve, deferred.reject);
}
else {
deferred.resolve(result);
}
}
catch (error) {
deferred.reject(error);
}
});
}
exports = createDeferred;
// Returns a resolved promise
exports.resolve = function(value) {
var promise = {};
promise.then = createHandler(promise, value, true);
return promise;
};
// Returns a rejected promise
exports.reject = function(reason) {
var promise = {};
promise.then = createHandler(promise, reason, false);
return promise;
};
// Returns a deferred
});
}
catiline.deferred = createDeferred;
// Returns a resolved promise
catiline.resolve = function(value) {
var promise = {};
promise.then = createHandler(promise, value, true);
return promise;
};
// Returns a rejected promise
catiline.reject = function(reason) {
var promise = {};
promise.then = createHandler(promise, reason, false);
return promise;
};
// Returns a deferred
exports.all = function(array) {
var promise = createDeferred();
var len = array.length;
var resolved = 0;
var out = [];
var onSuccess = function(n) {
return function(v) {
out[n] = v;
resolved++;
if (resolved === len) {
promise.resolve(out);
}
};
};
array.forEach(function(v, i) {
v.then(onSuccess(i), function(a) {
promise.reject(a);
});
});
return promise.promise;
catiline.all = function(array) {
var promise = createDeferred();
var len = array.length;
var resolved = 0;
var out = [];
var onSuccess = function(n) {
return function(v) {
out[n] = v;
resolved++;
if (resolved === len) {
promise.resolve(out);
}
};
return exports;
})(catiline.setImmediate);
catiline.all = catiline.deferred.all;
catiline.resolve = catiline.deferred.resolve;
catiline.rejected = catiline.deferred.reject;
};
array.forEach(function(v, i) {
v.then(onSuccess(i), function(a) {
promise.reject(a);
});
});
return promise.promise;
};
catiline._hasWorker = typeof Worker !== 'undefined'&&typeof fakeLegacy === 'undefined';

@@ -342,3 +278,3 @@ catiline.URL = window.URL || window.webkitURL;

//much of the iframe stuff inspired by https://github.com/padolsey/operative
//mos tthings besides the names have since been changed
//most things besides the names have since been changed
function actualMakeI(script,codeword){

@@ -384,3 +320,3 @@ var iFrame = document.createElement('iframe');

window.addEventListener('message',function(e){
if(typeof e.data ==='string'&&e.data.length>codeword.length&&e.data.slice(0,codeword.length)===codeword){
if(e.data.slice && e.data.slice(0,codeword.length) === codeword){
worker.onmessage({data:JSON.parse(e.data.slice(codeword.length))});

@@ -402,3 +338,3 @@ }

};
//accepts an array of strings, joins them, and turns them into a worker.
function makeFallbackWorker(script){

@@ -410,2 +346,3 @@ catiline._noTransferable=true;

}
//accepts an array of strings, joins them, and turns them into a worker.
catiline.makeWorker = function (strings, codeword){

@@ -574,3 +511,3 @@ if(!catiline._hasWorker){

self.on('error',rejectPromises);
worker.onerror = function (e) {
worker.onerror =function (e) {
_fire('error', e);

@@ -788,3 +725,4 @@ };

}
//will be removed in v3
catiline.setImmediate = catiline.nextTick;
function initBrowser(catiline){

@@ -816,3 +754,3 @@ var origCW = global.cw;

}
catiline.version = '2.8.1';
catiline.version = '2.8.3';
})(this);}

@@ -1,5 +0,5 @@

/*! catiline 2.8.1 2013-09-11*/
/*! catiline 2.8.3 2013-09-19*/
/*!(c)2013 Calvin Metcalf @license MIT https://github.com/calvinmetcalf/catiline */
/*!Includes Promiscuous (c)2013 Ruben Verborgh @license MIT https://github.com/RubenVerborgh/promiscuous*/
/*!Includes Material from setImmediate Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, and Domenic Denicola @license MIT https://github.com/NobleJS/setImmediate */
"undefined"==typeof document?(self._noTransferable=!0,self.onmessage=function(e){eval(e.data)}):function(global){"use strict";function regexImports(e){for(var n=e,s=!0,i={},t=function(e,n){n&&"importScripts("+n.split(",").forEach(function(e){i[catiline.makeUrl(e.match(/\s*[\'\"](\S*)[\'\"]\s*/)[1])]=!0})+");\n"};s;)s=n.match(/(importScripts\(.*?\);?)/),n=n.replace(/(importScripts\(\s*(?:[\'\"].*?[\'\"])?\s*\);?)/,"\n"),s&&s[0].replace(/importScripts\(\s*([\'\"].*?[\'\"])?\s*\);?/g,t);return i=Object.keys(i),[i,n]}function moveImports(e){var n=regexImports(e),s=n[0],i=n[1];return s.length>0?"importScripts('"+s.join("','")+"');\n"+i:i}function moveIimports(e){var n=regexImports(e),s=n[0],i=n[1];return s.length>0?"importScripts('"+s.join("','")+"');eval(__scripts__);\n"+i:i}function getPath(){if("undefined"!=typeof SHIM_WORKER_PATH)return SHIM_WORKER_PATH;if("SHIM_WORKER_PATH"in catiline)return catiline.SHIM_WORKER_PATH;for(var e=document.getElementsByTagName("script"),n=e.length,s=0;n>s;){if(/catiline(\.min)?\.js/.test(e[s].src))return e[s].src;s++}}function appendScript(e,n){var s=e.createElement("script");"undefined"!=typeof s.text?s.text=n:s.innerHTML=n,"complete"===e.readyState?e.documentElement.appendChild(s):e.onreadystatechange=function(){"complete"===e.readyState&&e.documentElement.appendChild(s)}}function actualMakeI(e,n){var s=document.createElement("iframe");s.style.display="none",document.body.appendChild(s);var i=s.contentWindow,t=i.document,_=["try{ ","var __scripts__='';function importScripts(scripts){"," if(Array.isArray(scripts)&&scripts.length>0){"," scripts.forEach(function(url){"," var ajax = new XMLHttpRequest();"," ajax.open('GET',url,false);"," ajax.send();__scripts__+=ajax.responseText;"," __scripts__+='\\n;';"," });"," }","};",e,"}catch(e){"," window.parent.postMessage(['"+n+"','error'],'*')","}"].join("\n");return appendScript(t,_),s}function makeIframe(e,n){var s=catiline.deferred();return"complete"===document.readyState?s.resolve(actualMakeI(e,n)):window.addEventListener("load",function(){s.resolve(actualMakeI(e,n))},!1),s.promise}function makeFallbackWorker(e){catiline._noTransferable=!0;var n=new Worker(getPath());return n.postMessage(e),n}function catiline(e,n,s){return 1===arguments.length||!n||1>=n?new catiline.Worker(e):new catiline.Queue(e,n,s)}function initBrowser(e){var n=global.cw;e.noConflict=function(s){global.cw=n,s&&(global[s]=e)},global.catiline=e,global.cw=e,"communist"in global||(global.communist=e)}!function(attachTo,global){function isStringAndStartsWith(e,n){return"string"==typeof e&&e.substring(0,n.length)===n}function onGlobalMessage(e){if(e.source===global&&isStringAndStartsWith(e.data,MESSAGE_PREFIX)){var n=e.data.substring(MESSAGE_PREFIX.length);tasks.runIfPresent(n)}}if(global.setImmediate)return attachTo.setImmediate=global.setImmediate,void 0;var tasks=function(){function Task(e,n){this.handler=e,this.args=n}Task.prototype.run=function(){if("function"==typeof this.handler)this.handler.apply(void 0,this.args);else{var scriptSource=""+this.handler;eval(scriptSource)}};var nextHandle=1,tasksByHandle={},currentlyRunningATask=!1;return{addFromSetImmediateArguments:function(e){var n=e[0],s=Array.prototype.slice.call(e,1),i=new Task(n,s),t=nextHandle++;return tasksByHandle[t]=i,t},runIfPresent:function(e){if(currentlyRunningATask)global.setTimeout(function(){tasks.runIfPresent(e)},0);else{var n=tasksByHandle[e];if(n){currentlyRunningATask=!0;try{n.run()}finally{delete tasksByHandle[e],currentlyRunningATask=!1}}}},remove:function(e){delete tasksByHandle[e]}}}(),MESSAGE_PREFIX="com.catilinejs.setImmediate"+Math.random();global.addEventListener?global.addEventListener("message",onGlobalMessage,!1):global.attachEvent("onmessage",onGlobalMessage),attachTo.setImmediate=function(){var e=tasks.addFromSetImmediateArguments(arguments);return global.postMessage(MESSAGE_PREFIX+e,"*"),e}}(catiline,global),catiline.deferred=function(e){function Deferred(){function Promise(){this.then=function(n,s){return e(n,s)}}var e=function(r,o,a){var f;if(r!==e)return f=n(),e.queue.push({deferred:f,resolve:r,reject:o}),f.promise;for(var d,l,u,c=o?"resolve":"reject",g=0,b=e.queue.length;b>g;g++)d=e.queue[g],l=d.deferred,u=d[c],typeof u!==_?l[c](a):i(u,a,l);e=s(t,a,o)},t=new Promise;this.promise=t,e.queue=[],this.resolve=function(n){e.queue&&e(e,!0,n)},this.fulfill=this.resolve,this.reject=function(n){e.queue&&e(e,!1,n)}}function n(){return new Deferred}function s(e,s,t){return function(r,o){var a,f=t?r:o;return typeof f!==_?e:(i(f,s,a=n()),a.promise)}}function i(n,s,i){e(function(){var e;try{e=n(s),e&&typeof e.then===_?e.then(i.resolve,i.reject):i.resolve(e)}catch(t){i.reject(t)}})}var t,_="function";return t=n,t.resolve=function(e){var n={};return n.then=s(n,e,!0),n},t.reject=function(e){var n={};return n.then=s(n,e,!1),n},t.all=function(e){var s=n(),i=e.length,t=0,_=[],r=function(e){return function(n){_[e]=n,t++,t===i&&s.resolve(_)}};return e.forEach(function(e,n){e.then(r(n),function(e){s.reject(e)})}),s.promise},t}(catiline.setImmediate),catiline.all=catiline.deferred.all,catiline.resolve=catiline.deferred.resolve,catiline.rejected=catiline.deferred.reject,catiline._hasWorker="undefined"!=typeof Worker&&"undefined"==typeof fakeLegacy,catiline.URL=window.URL||window.webkitURL,catiline._noTransferable=!catiline.URL,catiline.makeIWorker=function(e,n){var s=moveIimports(e.join("")),i={onmessage:function(){}},t=makeIframe(s,n);return window.addEventListener("message",function(e){"string"==typeof e.data&&e.data.length>n.length&&e.data.slice(0,n.length)===n&&i.onmessage({data:JSON.parse(e.data.slice(n.length))})}),i.postMessage=function(e){t.then(function(n){n.contentWindow.postMessage(JSON.stringify(e),"*")})},i.terminate=function(){t.then(function(e){document.body.removeChild(e)})},i},catiline.makeWorker=function(e,n){if(!catiline._hasWorker)return catiline.makeIWorker(e,n);var s,i=moveImports(e.join(""));if(catiline._noTransferable)return makeFallbackWorker(i);try{s=new Worker(catiline.URL.createObjectURL(new Blob([i],{type:"text/javascript"})))}catch(t){try{s=makeFallbackWorker(i)}catch(_){s=catiline.makeIWorker(e,n)}}finally{return s}},catiline.makeUrl=function(e){var n=document.createElement("link");return n.href=e,n.href},catiline.Worker=function(e){function n(e,s){return e.indexOf(" ")>0?(e.split(" ").forEach(function(e){n(e,s)}),t):e in i?(i[e].forEach(function(e){e(s)}),t):t}"function"==typeof e&&(e={data:e});var s="com.catilinejs."+(catiline._hasWorker?"iframe":"worker")+Math.random(),i={},t=this;t.on=function(e,n,s){return s=s||t,e.indexOf(" ")>0?(e.split(" ").map(function(e){return t.on(e,n,s)},this),t):(e in i||(i[e]=[]),i[e].push(function(e){n.call(s,e)}),t)},t.fire=function(e,n,s){return catiline._noTransferable?l.postMessage([[e],n]):l.postMessage([[e],n],s),t},t.off=function(e,n){return e.indexOf(" ")>0?(e.split(" ").map(function(e){return t.off(e,n)}),t):e in i?(n?i[e].indexOf(n)>-1&&(i[e].length>1?delete i[e]:i[e].splice(i[e].indexOf(n),1)):delete i[e],t):t};var _=[],r=function(e){"string"!=typeof e&&"preventDefault"in e&&(e.preventDefault(),e=e.message),_.forEach(function(n){n&&n.reject(e)})};e.__codeWord__='"'+s+'"',"initialize"in e||(e.initialize="init"in e?e.init:function(){});var o="{\n ",a=function(e){var n=function(n,i){var t=_.length;return _[t]=catiline.deferred(),catiline._noTransferable?l.postMessage([[s,t],e,n]):l.postMessage([[s,t],e,n],i),_[t].promise};return n},f=0;for(var d in e)0!==f?o+=",\n ":f++,o=o+d+":"+e[d].toString(),t[d]=a(d);o+="}";var l=catiline.makeWorker(['"use strict";function _fire(e,n){return e.indexOf(" ")>0?(e.split(" ").forEach(function(e){_fire(e,n)}),void 0):(e in listeners&&listeners[e].forEach(function(e){e(n)}),void 0)}function makeConsole(e){return function(){for(var n=arguments.length,s=[],i=0;n>i;)s.push(arguments[i]),i++;_db.fire("console",[e,s])}}var _db=',o,',listeners={},__iFrame__="undefined"!=typeof document,__self__={onmessage:function(e){return _fire("messege",e.data[1]),e.data[0][0]===_db.__codeWord__?regMsg(e):(_fire(e.data[0][0],e.data[1]),void 0)}};__iFrame__?window.onmessage=function(e){"string"==typeof e.data&&(e={data:JSON.parse(e.data)}),__self__.onmessage(e)}:self.onmessage=__self__.onmessage,__self__.postMessage=function(e,n){if(self._noTransferable||__iFrame__)if(__iFrame__){var s=_db.__codeWord__+JSON.stringify(e);window.parent.postMessage(s,"*")}else self._noTransferable&&self.postMessage(e);else self.postMessage(e,n)},_db.on=function(e,n,s){return e.indexOf(" ")>0?e.split(" ").map(function(e){return _db.on(e,n,s)},_db):(s=s||_db,e in listeners||(listeners[e]=[]),listeners[e].push(function(e){n.call(s,e,_db)}),void 0)},_db.fire=function(e,n,s){__self__.postMessage([[e],n],s)},_db.off=function(e,n){return e.indexOf(" ")>0?e.split(" ").map(function(e){return _db.off(e,n)}):(e in listeners&&(n?listeners[e].indexOf(n)>-1&&(listeners[e].length>1?delete listeners[e]:listeners[e].splice(listeners[e].indexOf(n),1)):delete listeners[e]),void 0)};var console={};["log","debug","error","info","warn","time","timeEnd"].forEach(function(e){console[e]=makeConsole(e)});var regMsg=function(e){var n,s=function(n,s){__self__.postMessage([e.data[0],n],s)};if(__iFrame__)try{n=_db[e.data[1]](e.data[2],s,_db)}catch(e){_db.fire("error",JSON.stringify(e))}else n=_db[e.data[1]](e.data[2],s,_db);"undefined"!=typeof n&&s(n)};_db.initialize(_db);'],s);l.onmessage=function(e){n("message",e.data[1]),e.data[0][0]===s?(_[e.data[0][1]].resolve(e.data[1]),_[e.data[0][1]]=0):n(e.data[0][0],e.data[1])},t.on("error",r),l.onerror=function(e){n("error",e)},t.on("console",function(e){console[e[0]].apply(console,e[1])}),t._close=function(){return l.terminate(),r("closed"),catiline.resolve()},"close"in t||(t.close=t._close)},catiline.worker=function(e){return new catiline.Worker(e)},catiline.Queue=function(e,n,s){function i(e){e=e||"canceled",m=0;var n=b;return b=[],n.forEach(function(n){n[3].reject(e)}),l}function t(e){return function(n,s){return d(e,n,s)}}function _(e){return function(n){return catiline.all(n.map(function(n){return d(e,n)}))}}function r(e){return function(n){var s=this;return catiline.all(n.map(function(n){return d(e,n).then(s.__cb__)}))}}function o(e){return function(n){return catiline.all(n.map(function(n){return d(e,n[0],n[1])}))}}function a(e){return function(n){var s=this;return catiline.all(n.map(function(n){return d(e,n[0],n[1]).then(s.__cb__)}))}}function f(e){if(m){var n=b.shift();m--,u[e][n[0]](n[1],n[2]).then(function(s){f(e),n[3].resolve(s)},function(s){f(e),n[3].reject(s)})}else c++,g.push(e)}function d(e,i,t){var _=catiline.deferred();if(s)return _.promise.cancel=function(e){return _.reject(e)},u[~~(Math.random()*n)][e](i,t).then(function(e){return _.resolve(e)},function(e){return _.reject(e)}),_.promise;if(!m&&c){var r=g.pop();c--,_.promise.cancel=function(e){return _.reject(e)},u[r][e](i,t).then(function(e){f(r),_.resolve(e)},function(e){f(r),_.reject(e)})}else if(m||!c){var o=[e,i,t,_];_.promise.cancel=function(e){var n=b.indexOf(o);return n>-1&&(b.splice(n,1),m--),_.reject(e)},m=b.push(o)}return _.promise}var l=this;l.__batchcb__={},l.__batchtcb__={},l.batch=function(e){return"function"==typeof e?(l.__batchcb__.__cb__=e,l.__batchcb__):i(e)},l.batchTransfer=function(e){return"function"==typeof e?(l.__batchtcb__.__cb__=e,l.__batchtcb__):i(e)};for(var u=[],c=0,g=[],b=[],m=0;n>c;)u[c]=new catiline.Worker(e),g.push(c),c++;l.on=function(e,n,s){return u.forEach(function(i){i.on(e,n,s)}),l},l.off=function(e,n,s){return u.forEach(function(i){i.off(e,n,s)}),l};var p=function(e,n){return u.forEach(function(s){s.fire(e,n)}),l};l.fire=function(e,s){return u[~~(Math.random()*n)].fire(e,s),l},l.batch.fire=p,l.batchTransfer.fire=p;for(var v in e)l[v]=t(v),l.batch[v]=_(v),l.__batchcb__[v]=r(v),l.batchTransfer[v]=o(v),l.__batchtcb__[v]=a(v);l._close=function(){return catiline.all(u.map(function(e){return e._close()}))},"close"in l||(l.close=l._close)},catiline.queue=function(e,n,s){return new catiline.Queue(e,n,s)},"function"==typeof define?define(function(e){return catiline.SHIM_WORKER_PATH=e.toUrl("./catiline.js"),catiline}):"undefined"!=typeof module&&"exports"in module?module.exports=catiline:initBrowser(catiline),catiline.version="2.8.1"}(this);
"undefined"==typeof document?(self._noTransferable=!0,self.onmessage=function(e){eval(e.data)}):function(e){"use strict";function n(){var e,n=0,s=p;for(p=[];e=s[n++];)e()}function Deferred(){function Promise(){this.then=function(n,s){return e(n,s)}}var e=function(_,r,o){if(_!==e){var a=s();return e.queue.push({deferred:a,resolve:_,reject:r}),a.promise}for(var f=r?"resolve":"reject",d=0,l=e.queue.length;l>d;d++){var u=e.queue[d],c=u.deferred,g=u[f];typeof g!==v?c[f](o):t(g,o,c)}e=i(n,o,r)},n=new Promise;this.promise=n,e.queue=[],this.resolve=function(n){e.queue&&e(e,!0,n)},this.fulfill=this.resolve,this.reject=function(n){e.queue&&e(e,!1,n)}}function s(){return new Deferred}function i(e,n,i){return function(_,r){var o=i?_:r;if(typeof o!==v)return e;var a=s();return t(o,n,a),a.promise}}function t(e,n,s){c.nextTick(function(){try{var i=e(n);i&&typeof i.then===v?i.then(s.resolve,s.reject):s.resolve(i)}catch(t){s.reject(t)}})}function _(e){for(var n=e,s=!0,i={},t=function(e,n){n&&"importScripts("+n.split(",").forEach(function(e){i[c.makeUrl(e.match(/\s*[\'\"](\S*)[\'\"]\s*/)[1])]=!0})+");\n"};s;)s=n.match(/(importScripts\(.*?\);?)/),n=n.replace(/(importScripts\(\s*(?:[\'\"].*?[\'\"])?\s*\);?)/,"\n"),s&&s[0].replace(/importScripts\(\s*([\'\"].*?[\'\"])?\s*\);?/g,t);return i=Object.keys(i),[i,n]}function r(e){var n=_(e),s=n[0],i=n[1];return s.length>0?"importScripts('"+s.join("','")+"');\n"+i:i}function o(e){var n=_(e),s=n[0],i=n[1];return s.length>0?"importScripts('"+s.join("','")+"');eval(__scripts__);\n"+i:i}function a(){if("undefined"!=typeof SHIM_WORKER_PATH)return SHIM_WORKER_PATH;if("SHIM_WORKER_PATH"in c)return c.SHIM_WORKER_PATH;for(var e=document.getElementsByTagName("script"),n=e.length,s=0;n>s;){if(/catiline(\.min)?\.js/.test(e[s].src))return e[s].src;s++}}function f(e,n){var s=e.createElement("script");"undefined"!=typeof s.text?s.text=n:s.innerHTML=n,"complete"===e.readyState?e.documentElement.appendChild(s):e.onreadystatechange=function(){"complete"===e.readyState&&e.documentElement.appendChild(s)}}function d(e,n){var s=document.createElement("iframe");s.style.display="none",document.body.appendChild(s);var i=s.contentWindow,t=i.document,_=["try{ ","var __scripts__='';function importScripts(scripts){"," if(Array.isArray(scripts)&&scripts.length>0){"," scripts.forEach(function(url){"," var ajax = new XMLHttpRequest();"," ajax.open('GET',url,false);"," ajax.send();__scripts__+=ajax.responseText;"," __scripts__+='\\n;';"," });"," }","};",e,"}catch(e){"," window.parent.postMessage(['"+n+"','error'],'*')","}"].join("\n");return f(t,_),s}function l(e,n){var s=c.deferred();return"complete"===document.readyState?s.resolve(d(e,n)):window.addEventListener("load",function(){s.resolve(d(e,n))},!1),s.promise}function u(e){c._noTransferable=!0;var n=new Worker(a());return n.postMessage(e),n}function c(e,n,s){return 1===arguments.length||!n||1>=n?new c.Worker(e):new c.Queue(e,n,s)}function g(n){var s=e.cw;n.noConflict=function(i){e.cw=s,i&&(e[i]=n)},e.catiline=n,e.cw=n,"communist"in e||(e.communist=n)}var b;if("function"==typeof setImmediate)b=setImmediate.bind(e,n);else{var m="com.catiline.setImmediate"+Math.random();addEventListener("message",function(e){e.source===window&&e.data===m&&n()},!1),b=function(){postMessage(m,"*")}}var p=[];c.nextTick=function(e){1===p.push(e)&&b()};var v="function";c.deferred=s,c.resolve=function(e){var n={};return n.then=i(n,e,!0),n},c.reject=function(e){var n={};return n.then=i(n,e,!1),n},c.all=function(e){var n=s(),i=e.length,t=0,_=[],r=function(e){return function(s){_[e]=s,t++,t===i&&n.resolve(_)}};return e.forEach(function(e,s){e.then(r(s),function(e){n.reject(e)})}),n.promise},c._hasWorker="undefined"!=typeof Worker&&"undefined"==typeof fakeLegacy,c.URL=window.URL||window.webkitURL,c._noTransferable=!c.URL,c.makeIWorker=function(e,n){var s=o(e.join("")),i={onmessage:function(){}},t=l(s,n);return window.addEventListener("message",function(e){e.data.slice&&e.data.slice(0,n.length)===n&&i.onmessage({data:JSON.parse(e.data.slice(n.length))})}),i.postMessage=function(e){t.then(function(n){n.contentWindow.postMessage(JSON.stringify(e),"*")})},i.terminate=function(){t.then(function(e){document.body.removeChild(e)})},i},c.makeWorker=function(e,n){if(!c._hasWorker)return c.makeIWorker(e,n);var s,i=r(e.join(""));if(c._noTransferable)return u(i);try{s=new Worker(c.URL.createObjectURL(new Blob([i],{type:"text/javascript"})))}catch(t){try{s=u(i)}catch(_){s=c.makeIWorker(e,n)}}finally{return s}},c.makeUrl=function(e){var n=document.createElement("link");return n.href=e,n.href},c.Worker=function(e){function n(e,s){return e.indexOf(" ")>0?(e.split(" ").forEach(function(e){n(e,s)}),t):e in i?(i[e].forEach(function(e){e(s)}),t):t}"function"==typeof e&&(e={data:e});var s="com.catilinejs."+(c._hasWorker?"iframe":"worker")+Math.random(),i={},t=this;t.on=function(e,n,s){return s=s||t,e.indexOf(" ")>0?(e.split(" ").map(function(e){return t.on(e,n,s)},this),t):(e in i||(i[e]=[]),i[e].push(function(e){n.call(s,e)}),t)},t.fire=function(e,n,s){return c._noTransferable?l.postMessage([[e],n]):l.postMessage([[e],n],s),t},t.off=function(e,n){return e.indexOf(" ")>0?(e.split(" ").map(function(e){return t.off(e,n)}),t):e in i?(n?i[e].indexOf(n)>-1&&(i[e].length>1?delete i[e]:i[e].splice(i[e].indexOf(n),1)):delete i[e],t):t};var _=[],r=function(e){"string"!=typeof e&&"preventDefault"in e&&(e.preventDefault(),e=e.message),_.forEach(function(n){n&&n.reject(e)})};e.__codeWord__='"'+s+'"',"initialize"in e||(e.initialize="init"in e?e.init:function(){});var o="{\n ",a=function(e){var n=function(n,i){var t=_.length;return _[t]=c.deferred(),c._noTransferable?l.postMessage([[s,t],e,n]):l.postMessage([[s,t],e,n],i),_[t].promise};return n},f=0;for(var d in e)0!==f?o+=",\n ":f++,o=o+d+":"+e[d].toString(),t[d]=a(d);o+="}";var l=c.makeWorker(['"use strict";function _fire(e,n){return e.indexOf(" ")>0?(e.split(" ").forEach(function(e){_fire(e,n)}),void 0):(e in listeners&&listeners[e].forEach(function(e){e(n)}),void 0)}function makeConsole(e){return function(){for(var n=arguments.length,s=[],i=0;n>i;)s.push(arguments[i]),i++;_db.fire("console",[e,s])}}var _db=',o,',listeners={},__iFrame__="undefined"!=typeof document,__self__={onmessage:function(e){return _fire("messege",e.data[1]),e.data[0][0]===_db.__codeWord__?regMsg(e):(_fire(e.data[0][0],e.data[1]),void 0)}};__iFrame__?window.onmessage=function(e){"string"==typeof e.data&&(e={data:JSON.parse(e.data)}),__self__.onmessage(e)}:self.onmessage=__self__.onmessage,__self__.postMessage=function(e,n){if(self._noTransferable||__iFrame__)if(__iFrame__){var s=_db.__codeWord__+JSON.stringify(e);window.parent.postMessage(s,"*")}else self._noTransferable&&self.postMessage(e);else self.postMessage(e,n)},_db.on=function(e,n,s){return e.indexOf(" ")>0?e.split(" ").map(function(e){return _db.on(e,n,s)},_db):(s=s||_db,e in listeners||(listeners[e]=[]),listeners[e].push(function(e){n.call(s,e,_db)}),void 0)},_db.fire=function(e,n,s){__self__.postMessage([[e],n],s)},_db.off=function(e,n){return e.indexOf(" ")>0?e.split(" ").map(function(e){return _db.off(e,n)}):(e in listeners&&(n?listeners[e].indexOf(n)>-1&&(listeners[e].length>1?delete listeners[e]:listeners[e].splice(listeners[e].indexOf(n),1)):delete listeners[e]),void 0)};var console={};["log","debug","error","info","warn","time","timeEnd"].forEach(function(e){console[e]=makeConsole(e)});var regMsg=function(e){var n,s=function(n,s){__self__.postMessage([e.data[0],n],s)};if(__iFrame__)try{n=_db[e.data[1]](e.data[2],s,_db)}catch(e){_db.fire("error",JSON.stringify(e))}else n=_db[e.data[1]](e.data[2],s,_db);"undefined"!=typeof n&&s(n)};_db.initialize(_db);'],s);l.onmessage=function(e){n("message",e.data[1]),e.data[0][0]===s?(_[e.data[0][1]].resolve(e.data[1]),_[e.data[0][1]]=0):n(e.data[0][0],e.data[1])},t.on("error",r),l.onerror=function(e){n("error",e)},t.on("console",function(e){console[e[0]].apply(console,e[1])}),t._close=function(){return l.terminate(),r("closed"),c.resolve()},"close"in t||(t.close=t._close)},c.worker=function(e){return new c.Worker(e)},c.Queue=function(e,n,s){function i(e){e=e||"canceled",p=0;var n=m;return m=[],n.forEach(function(n){n[3].reject(e)}),l}function t(e){return function(n,s){return d(e,n,s)}}function _(e){return function(n){return c.all(n.map(function(n){return d(e,n)}))}}function r(e){return function(n){var s=this;return c.all(n.map(function(n){return d(e,n).then(s.__cb__)}))}}function o(e){return function(n){return c.all(n.map(function(n){return d(e,n[0],n[1])}))}}function a(e){return function(n){var s=this;return c.all(n.map(function(n){return d(e,n[0],n[1]).then(s.__cb__)}))}}function f(e){if(p){var n=m.shift();p--,u[e][n[0]](n[1],n[2]).then(function(s){f(e),n[3].resolve(s)},function(s){f(e),n[3].reject(s)})}else g++,b.push(e)}function d(e,i,t){var _=c.deferred();if(s)return _.promise.cancel=function(e){return _.reject(e)},u[~~(Math.random()*n)][e](i,t).then(function(e){return _.resolve(e)},function(e){return _.reject(e)}),_.promise;if(!p&&g){var r=b.pop();g--,_.promise.cancel=function(e){return _.reject(e)},u[r][e](i,t).then(function(e){f(r),_.resolve(e)},function(e){f(r),_.reject(e)})}else if(p||!g){var o=[e,i,t,_];_.promise.cancel=function(e){var n=m.indexOf(o);return n>-1&&(m.splice(n,1),p--),_.reject(e)},p=m.push(o)}return _.promise}var l=this;l.__batchcb__={},l.__batchtcb__={},l.batch=function(e){return"function"==typeof e?(l.__batchcb__.__cb__=e,l.__batchcb__):i(e)},l.batchTransfer=function(e){return"function"==typeof e?(l.__batchtcb__.__cb__=e,l.__batchtcb__):i(e)};for(var u=[],g=0,b=[],m=[],p=0;n>g;)u[g]=new c.Worker(e),b.push(g),g++;l.on=function(e,n,s){return u.forEach(function(i){i.on(e,n,s)}),l},l.off=function(e,n,s){return u.forEach(function(i){i.off(e,n,s)}),l};var v=function(e,n){return u.forEach(function(s){s.fire(e,n)}),l};l.fire=function(e,s){return u[~~(Math.random()*n)].fire(e,s),l},l.batch.fire=v,l.batchTransfer.fire=v;for(var O in e)l[O]=t(O),l.batch[O]=_(O),l.__batchcb__[O]=r(O),l.batchTransfer[O]=o(O),l.__batchtcb__[O]=a(O);l._close=function(){return c.all(u.map(function(e){return e._close()}))},"close"in l||(l.close=l._close)},c.queue=function(e,n,s){return new c.Queue(e,n,s)},c.setImmediate=c.nextTick,"function"==typeof define?define(function(e){return c.SHIM_WORKER_PATH=e.toUrl("./catiline.js"),c}):"undefined"!=typeof module&&"exports"in module?module.exports=c:g(c),c.version="2.8.3"}(this);
Changelog
===
##2.8.3
- brought lie back in, espetially as we just need a subset of setImmediate this make more sense for now.
##2.8.2
- added component.json
##2.8.1

@@ -5,0 +12,0 @@

@@ -15,2 +15,3 @@ var UglifyJS = require("uglify-js");

if(defit.errors){
console.log(defit.errors);
throw defit.errors;

@@ -49,3 +50,3 @@ }

},
files: {'dist/<%= pkg.name %>.min.js':['src/IE.js','src/setImmediate.js','src/lie.banner.js','node_modules/lie/src/lie.js','node_modules/lie/src/all.js','src/lie.footer.js','src/utils.js','src/temp.min.js','src/queue.js','src/wrapup.js']}
files: {'dist/<%= pkg.name %>.min.js':['src/IE.js','src/nextTick.js','src/promise.js','src/utils.js','src/temp.min.js','src/queue.js','src/wrapup.js']}
},

@@ -58,3 +59,3 @@ browser: {

},
files: {'dist/<%= pkg.name %>.js':['src/IE.js','src/setImmediate.js','src/lie.banner.js','node_modules/lie/src/lie.js','node_modules/lie/src/all.js','src/lie.footer.js','src/utils.js','src/temp.js','src/queue.js','src/wrapup.js']}
files: {'dist/<%= pkg.name %>.js':['src/IE.js','src/nextTick.js','src/promise.js','src/utils.js','src/temp.js','src/queue.js','src/wrapup.js']}
}

@@ -107,3 +108,4 @@ },

browserName: 'firefox',
platform: 'linux'
platform: 'linux',
version: '22'
},{

@@ -110,0 +112,0 @@ browserName: 'firefox',

{
"name": "catiline",
"version": "2.8.1",
"version": "2.8.3",
"description": "Multi proccessing with workers in the browser.",

@@ -41,3 +41,2 @@ "keywords": [

"defs": "~0.4.1",
"lie": "~1.0.0",
"mocha": "~1.12.1",

@@ -44,0 +43,0 @@ "grunt-mocha-phantomjs": "~0.3.0"

@@ -136,3 +136,3 @@ catiline.Worker = function Catiline(obj) {

self.on('error',rejectPromises);
worker.onerror = function (e) {
worker.onerror =function (e) {
_fire('error', e);

@@ -139,0 +139,0 @@ };

@@ -81,3 +81,3 @@ catiline._hasWorker = typeof Worker !== 'undefined'&&typeof fakeLegacy === 'undefined';

//much of the iframe stuff inspired by https://github.com/padolsey/operative
//mos tthings besides the names have since been changed
//most things besides the names have since been changed
function actualMakeI(script,codeword){

@@ -123,3 +123,3 @@ const iFrame = document.createElement('iframe');

window.addEventListener('message',function(e){
if(typeof e.data ==='string'&&e.data.length>codeword.length&&e.data.slice(0,codeword.length)===codeword){
if(e.data.slice && e.data.slice(0,codeword.length) === codeword){
worker.onmessage({data:JSON.parse(e.data.slice(codeword.length))});

@@ -141,3 +141,3 @@ }

};
//accepts an array of strings, joins them, and turns them into a worker.
function makeFallbackWorker(script){

@@ -149,2 +149,3 @@ catiline._noTransferable=true;

}
//accepts an array of strings, joins them, and turns them into a worker.
catiline.makeWorker = function (strings, codeword){

@@ -151,0 +152,0 @@ if(!catiline._hasWorker){

@@ -8,3 +8,4 @@ function catiline(object,queueLength,unmanaged){

}
//will be removed in v3
catiline.setImmediate = catiline.nextTick;
function initBrowser(catiline){

@@ -11,0 +12,0 @@ const origCW = global.cw;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc