Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

operative

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

operative - npm Package Compare versions

Comparing version 0.4.5 to 0.4.6

2

bower.json
{
"name": "operative",
"version": "0.4.5",
"version": "0.4.6",
"main": "dist/operative.js",

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

{
"name": "operative",
"version": "0.4.5",
"version": "0.4.6",
"main": "dist/operative.js",

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

@@ -8,3 +8,3 @@ /*!

* @repo http://github.com/padolsey/operative
* @version 0.4.5
* @version 0.4.6
* @license MIT

@@ -446,2 +446,5 @@ */

break;
case 'deferred_reject_error':
this.deferreds[data.token].reject(data.error);
break;
case 'result':

@@ -636,2 +639,22 @@

function reject(r, transfers) {
if (r instanceof Error) {
// Create an error object that can be cloned: (See #44/#45):
var cloneableError = {
message: r.message,
stack: r.stack,
name: r.name,
code: r.code
};
for (var i in r) {
if (r.hasOwnProperty(i)) {
cloneableError[i] = r[i];
}
}
postMessage({
cmd: 'deferred_reject_error',
token: data.token,
error: cloneableError
});
return;
}
returnResult({

@@ -638,0 +661,0 @@ isDeferred: true,

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

/** Operative v0.4.5 (c) 2013 James padolsey, MIT-licensed, http://github.com/padolsey/operative **/
!function(){function a(c,d){var e=a.getBaseURL,f=a.getSelfURL,g=a.hasWorkerSupport?a.Operative.BrowserWorker:a.Operative.Iframe;if("function"==typeof c){var h=new g({main:c},d,e,f),i=function(){return h.api.main.apply(h,arguments)};i.transfer=function(){return h.api.main.transfer.apply(h,arguments)};for(var j in h.api)b.call(h.api,j)&&(i[j]=h.api[j]);return i}return new g(c,d,e,f).api}if("undefined"!=typeof window||!self.importScripts){var b={}.hasOwnProperty,c=document.getElementsByTagName("script"),d=c[c.length-1],e=/operative/.test(d.src)&&d.src;a.pool=function(b,c,d){b=0|Math.abs(b)||1;for(var e=[],f=0,g=0;g<b;++g)e.push(a(c,d));return{terminate:function(){for(var a=0;a<b;++a)e[a].destroy()},next:function(){return f=f+1===b?0:f+1,e[f]}}},a.hasWorkerSupport=!!window.Worker,a.hasWorkerViaBlobSupport=!1,a.hasTransferSupport=!1;var f=(location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")+location.pathname).replace(/[^\/]+$/,"");a.objCreate=Object.create||function(a){function b(){}return b.prototype=a,new b},a.setSelfURL=function(a){e=a},a.getSelfURL=function(a){return e},a.setBaseURL=function(a){f=a},a.getBaseURL=function(){return f},window.operative=a}}(),function(){function a(a){this.value=a}function b(a,b,d,e){var f=this;a.get=a.get||function(a){return this[a]},a.set=a.set||function(a,b){return this[a]=b},this._curToken=0,this._queue=[],this._getBaseURL=d,this._getSelfURL=e,this.isDestroyed=!1,this.isContextReady=!1,this.module=a,this.dependencies=b||[],this.dataProperties={},this.api={},this.callbacks={},this.deferreds={},this._fixDependencyURLs(),this._setup();for(var g in a)c.call(a,g)&&this._createExposedMethod(g);this.api.__operative__=this,this.api.destroy=this.api.terminate=function(){return f.destroy()}}if("undefined"!=typeof window||!self.importScripts){var c={}.hasOwnProperty,d=[].slice,e={}.toString;operative.Operative=b;var f=b.Promise=window.Promise;b.prototype={_marshal:function(a){return a},_demarshal:function(a){return a},_enqueue:function(a){this._queue.push(a)},_fixDependencyURLs:function(){for(var a=this.dependencies,b=0,c=a.length;b<c;++b){var d=a[b];/\/\//.test(d)||(a[b]=d.replace(/^\/?/,this._getBaseURL().replace(/([^\/])$/,"$1/")))}},_dequeueAll:function(){for(var a=0,b=this._queue.length;a<b;++a)this._queue[a].call(this);this._queue=[]},_buildContextScript:function(a){var b,c=[],d=this.module,e=this.dataProperties;for(var f in d)b=d[f],"function"==typeof b?c.push('\tself["'+f.replace(/"/g,'\\"')+'"] = '+b.toString()+";"):e[f]=b;return c.join("\n")+(a?"\n("+a.toString()+"());":"")},_createExposedMethod:function(b){var c=this,g=this.api[b]=function(){function e(){c.isContextReady?c._runMethod(b,g,h,j):c._enqueue(e)}if(c.isDestroyed)throw new Error("Operative: Cannot run method. Operative has already been destroyed");var g=++c._curToken,h=d.call(arguments),i="function"==typeof h[h.length-1]&&h.pop(),j=h[h.length-1]instanceof a&&h.pop();if(!i&&!f)throw new Error("Operative: No callback has been passed. Assumed that you want a promise. But `operative.Promise` is null. Please provide Promise polyfill/lib.");if(i)c.callbacks[g]=i,setTimeout(function(){e()},1);else if(f)return new f(function(a,b){var d;a.fulfil||a.fulfill?(d=a,d.fulfil=d.fulfill=a.fulfil||a.fulfill):d={fulfil:a,fulfill:a,resolve:a,reject:b,transferResolve:a,transferReject:b},c.deferreds[g]=d,e()})};g.transfer=function(){var b=[].slice.call(arguments),c="function"==typeof b[b.length-1]?b.length-2:b.length-1,d=b[c],f=e.call(d);if("[object Array]"!==f)throw new Error("Operative:transfer() must be passed an Array of transfers as its last arguments (Expected: [object Array], Received: "+f+")");return b[c]=new a(d),g.apply(null,b)}},destroy:function(){this.isDestroyed=!0}}}}(),function(){function makeBlobURI(a){var b;try{b=new Blob([a],{type:"text/javascript"})}catch(c){b=new BlobBuilder,b.append(a),b=b.getBlob()}return URL.createObjectURL(b)}function workerBoilerScript(){var postMessage=self.postMessage,structuredCloningSupport=null,toString={}.toString;self.console={},self.isWorker=!0,["log","debug","error","info","warn","time","timeEnd"].forEach(function(a){self.console[a]=function(){postMessage({cmd:"console",method:a,args:[].slice.call(arguments)})}}),self.addEventListener("message",function(e){function callback(){returnResult({args:[].slice.call(arguments)})}function returnResult(a,b){postMessage({cmd:"result",token:data.token,result:a},self.hasTransferSupport&&b||[])}function extractTransfers(a){var b=a[a.length-1];if("[object Array]"!==toString.call(b))throw new Error("Operative: callback.transfer() must be passed an Array of transfers as its last arguments");return b}var data=e.data;if("string"==typeof data&&0===data.indexOf("EVAL|"))return void eval(data.substring(5));if(null==structuredCloningSupport)return structuredCloningSupport="PING"===e.data[0],self.postMessage(structuredCloningSupport?"pingback:structuredCloningSupport=YES":"pingback:structuredCloningSupport=NO"),void(structuredCloningSupport||(postMessage=function(a){return self.postMessage(JSON.stringify(a))}));structuredCloningSupport||(data=JSON.parse(data));var defs=data.definitions,isDeferred=!1,args=data.args;if(defs)for(var i in defs)self[i]=defs[i];else{callback.transfer=function(){var a=[].slice.call(arguments),b=extractTransfers(a);returnResult({args:a},b)},args.push(callback),self.deferred=function(){function a(a,b){return returnResult({isDeferred:!0,action:"resolve",args:[a]},b),c}function b(a,b){returnResult({isDeferred:!0,action:"reject",args:[a]},b)}isDeferred=!0;var c={};return c.fulfil=c.fulfill=c.resolve=function(b){return a(b)},c.reject=function(a){return b(a)},c.transferResolve=function(b){var c=extractTransfers(arguments);return a(b,c)},c.transferReject=function(a){var c=extractTransfers(arguments);return b(a,c)},c};var result=self[data.method].apply(self,args);isDeferred||void 0===result||returnResult({args:[result]}),self.deferred=function(){throw new Error("Operative: deferred() called at odd time")}}})}if("undefined"==typeof window&&self.importScripts)return void workerBoilerScript();var Operative=operative.Operative,URL=window.URL||window.webkitURL,BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder,workerViaBlobSupport=function(){try{new Worker(makeBlobURI(";"))}catch(a){return!1}return!0}(),transferrableObjSupport=function(){try{var a=new ArrayBuffer(1);return new Worker(makeBlobURI(";")).postMessage(a,[a]),!a.byteLength}catch(a){return!1}}();operative.hasWorkerViaBlobSupport=workerViaBlobSupport,operative.hasTransferSupport=transferrableObjSupport,Operative.BrowserWorker=function(){Operative.apply(this,arguments)};var WorkerProto=Operative.BrowserWorker.prototype=operative.objCreate(Operative.prototype);WorkerProto._onWorkerMessage=function(a){var b=a.data;if("string"==typeof b&&0===b.indexOf("pingback"))return"pingback:structuredCloningSupport=NO"===b&&(this._marshal=function(a){return JSON.stringify(a)},this._demarshal=function(a){return JSON.parse(a)}),this.isContextReady=!0,this._postMessage({definitions:this.dataProperties}),void this._dequeueAll();switch(b=this._demarshal(b),b.cmd){case"console":window.console&&window.console[b.method].apply(window.console,b.args);break;case"result":var c=this.callbacks[b.token],d=this.deferreds[b.token],e=b.result&&b.result.isDeferred&&b.result.action;d&&e?d[e](b.result.args[0]):c?c.apply(this,b.result.args):d&&d.fulfil(b.result.args[0])}},WorkerProto._isWorkerViaBlobSupported=function(){return workerViaBlobSupport},WorkerProto._setup=function(){var a,b=this,c=this._getSelfURL(),d=this._isWorkerViaBlobSupported(),e=this._buildContextScript(d?workerBoilerScript:"");if(this.dependencies.length&&(e='importScripts("'+this.dependencies.join('", "')+'");\n'+e),d)a=this.worker=new Worker(makeBlobURI(e));else{if(!c)throw new Error("Operaritve: No operative.js URL available. Please set via operative.setSelfURL(...)");a=this.worker=new Worker(c),a.postMessage("EVAL|"+e)}a.postMessage("EVAL|self.hasTransferSupport="+transferrableObjSupport),a.postMessage(["PING"]),a.addEventListener("message",function(a){b._onWorkerMessage(a)})},WorkerProto._postMessage=function(a){var b=transferrableObjSupport&&a.transfers;return b?this.worker.postMessage(a,b.value):this.worker.postMessage(this._marshal(a))},WorkerProto._runMethod=function(a,b,c,d){this._postMessage({method:a,args:c,token:b,transfers:d})},WorkerProto.destroy=function(){this.worker.terminate(),Operative.prototype.destroy.call(this)}}(),function(){function a(){window.__run__=function(a,b,c,d){function e(){return c.apply(this,arguments)}var f=!1;window.deferred=function(){return f=!0,d},e.transfer=function(){return c.apply(this,[].slice.call(arguments,0,arguments.length-1))},c&&b.push(e);var g=window[a].apply(window,b);window.deferred=function(){throw new Error("Operative: deferred() called at odd time")},f||void 0===g||e(g)}}if("undefined"!=typeof window||!self.importScripts){var b=operative.Operative;b.Iframe=function(a){b.apply(this,arguments)};var c=b.Iframe.prototype=operative.objCreate(b.prototype),d=0;c._setup=function(){var b=this,c="__operativeIFrameLoaded"+ ++d;this.module.isWorker=!1;var e=this.iframe=document.body.appendChild(document.createElement("iframe"));e.style.display="none";var f=this.iframeWindow=e.contentWindow,g=f.document;window[c]=function(){window[c]=null;var d=g.createElement("script"),e=b._buildContextScript(a);void 0!==d.text?d.text=e:d.innerHTML=e,g.documentElement.appendChild(d);for(var h in b.dataProperties)f[h]=b.dataProperties[h];b.isContextReady=!0,b._dequeueAll()},g.open();var h="";this.dependencies.length&&(h+='\n<script src="'+this.dependencies.join('"></script><script src="')+'"></script>'),g.write(h+"\n<script>setTimeout(window.parent."+c+",0);</script>"),g.close()},c._runMethod=function(a,b,c){var d=this,e=this.callbacks[b],f=this.deferreds[b];this.iframeWindow.__run__(a,c,function(a){var b=e,c=f;b?b.apply(d,arguments):c&&c.fulfil(a)},f)},c.destroy=function(){this.iframe.parentNode.removeChild(this.iframe),b.prototype.destroy.call(this)}}}();
/** Operative v0.4.6 (c) 2013 James padolsey, MIT-licensed, http://github.com/padolsey/operative **/
!function(){function a(c,d){var e=a.getBaseURL,f=a.getSelfURL,g=a.hasWorkerSupport?a.Operative.BrowserWorker:a.Operative.Iframe;if("function"==typeof c){var h=new g({main:c},d,e,f),i=function(){return h.api.main.apply(h,arguments)};i.transfer=function(){return h.api.main.transfer.apply(h,arguments)};for(var j in h.api)b.call(h.api,j)&&(i[j]=h.api[j]);return i}return new g(c,d,e,f).api}if("undefined"!=typeof window||!self.importScripts){var b={}.hasOwnProperty,c=document.getElementsByTagName("script"),d=c[c.length-1],e=/operative/.test(d.src)&&d.src;a.pool=function(b,c,d){b=0|Math.abs(b)||1;for(var e=[],f=0,g=0;g<b;++g)e.push(a(c,d));return{terminate:function(){for(var a=0;a<b;++a)e[a].destroy()},next:function(){return f=f+1===b?0:f+1,e[f]}}},a.hasWorkerSupport=!!window.Worker,a.hasWorkerViaBlobSupport=!1,a.hasTransferSupport=!1;var f=(location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")+location.pathname).replace(/[^\/]+$/,"");a.objCreate=Object.create||function(a){function b(){}return b.prototype=a,new b},a.setSelfURL=function(a){e=a},a.getSelfURL=function(a){return e},a.setBaseURL=function(a){f=a},a.getBaseURL=function(){return f},window.operative=a}}(),function(){function a(a){this.value=a}function b(a,b,d,e){var f=this;a.get=a.get||function(a){return this[a]},a.set=a.set||function(a,b){return this[a]=b},this._curToken=0,this._queue=[],this._getBaseURL=d,this._getSelfURL=e,this.isDestroyed=!1,this.isContextReady=!1,this.module=a,this.dependencies=b||[],this.dataProperties={},this.api={},this.callbacks={},this.deferreds={},this._fixDependencyURLs(),this._setup();for(var g in a)c.call(a,g)&&this._createExposedMethod(g);this.api.__operative__=this,this.api.destroy=this.api.terminate=function(){return f.destroy()}}if("undefined"!=typeof window||!self.importScripts){var c={}.hasOwnProperty,d=[].slice,e={}.toString;operative.Operative=b;var f=b.Promise=window.Promise;b.prototype={_marshal:function(a){return a},_demarshal:function(a){return a},_enqueue:function(a){this._queue.push(a)},_fixDependencyURLs:function(){for(var a=this.dependencies,b=0,c=a.length;b<c;++b){var d=a[b];/\/\//.test(d)||(a[b]=d.replace(/^\/?/,this._getBaseURL().replace(/([^\/])$/,"$1/")))}},_dequeueAll:function(){for(var a=0,b=this._queue.length;a<b;++a)this._queue[a].call(this);this._queue=[]},_buildContextScript:function(a){var b,c=[],d=this.module,e=this.dataProperties;for(var f in d)b=d[f],"function"==typeof b?c.push('\tself["'+f.replace(/"/g,'\\"')+'"] = '+b.toString()+";"):e[f]=b;return c.join("\n")+(a?"\n("+a.toString()+"());":"")},_createExposedMethod:function(b){var c=this,g=this.api[b]=function(){function e(){c.isContextReady?c._runMethod(b,g,h,j):c._enqueue(e)}if(c.isDestroyed)throw new Error("Operative: Cannot run method. Operative has already been destroyed");var g=++c._curToken,h=d.call(arguments),i="function"==typeof h[h.length-1]&&h.pop(),j=h[h.length-1]instanceof a&&h.pop();if(!i&&!f)throw new Error("Operative: No callback has been passed. Assumed that you want a promise. But `operative.Promise` is null. Please provide Promise polyfill/lib.");if(i)c.callbacks[g]=i,setTimeout(function(){e()},1);else if(f)return new f(function(a,b){var d;a.fulfil||a.fulfill?(d=a,d.fulfil=d.fulfill=a.fulfil||a.fulfill):d={fulfil:a,fulfill:a,resolve:a,reject:b,transferResolve:a,transferReject:b},c.deferreds[g]=d,e()})};g.transfer=function(){var b=[].slice.call(arguments),c="function"==typeof b[b.length-1]?b.length-2:b.length-1,d=b[c],f=e.call(d);if("[object Array]"!==f)throw new Error("Operative:transfer() must be passed an Array of transfers as its last arguments (Expected: [object Array], Received: "+f+")");return b[c]=new a(d),g.apply(null,b)}},destroy:function(){this.isDestroyed=!0}}}}(),function(){function makeBlobURI(a){var b;try{b=new Blob([a],{type:"text/javascript"})}catch(c){b=new BlobBuilder,b.append(a),b=b.getBlob()}return URL.createObjectURL(b)}function workerBoilerScript(){var postMessage=self.postMessage,structuredCloningSupport=null,toString={}.toString;self.console={},self.isWorker=!0,["log","debug","error","info","warn","time","timeEnd"].forEach(function(a){self.console[a]=function(){postMessage({cmd:"console",method:a,args:[].slice.call(arguments)})}}),self.addEventListener("message",function(e){function callback(){returnResult({args:[].slice.call(arguments)})}function returnResult(a,b){postMessage({cmd:"result",token:data.token,result:a},self.hasTransferSupport&&b||[])}function extractTransfers(a){var b=a[a.length-1];if("[object Array]"!==toString.call(b))throw new Error("Operative: callback.transfer() must be passed an Array of transfers as its last arguments");return b}var data=e.data;if("string"==typeof data&&0===data.indexOf("EVAL|"))return void eval(data.substring(5));if(null==structuredCloningSupport)return structuredCloningSupport="PING"===e.data[0],self.postMessage(structuredCloningSupport?"pingback:structuredCloningSupport=YES":"pingback:structuredCloningSupport=NO"),void(structuredCloningSupport||(postMessage=function(a){return self.postMessage(JSON.stringify(a))}));structuredCloningSupport||(data=JSON.parse(data));var defs=data.definitions,isDeferred=!1,args=data.args;if(defs)for(var i in defs)self[i]=defs[i];else{callback.transfer=function(){var a=[].slice.call(arguments),b=extractTransfers(a);returnResult({args:a},b)},args.push(callback),self.deferred=function(){function a(a,b){return returnResult({isDeferred:!0,action:"resolve",args:[a]},b),c}function b(a,b){if(a instanceof Error){var c={message:a.message,stack:a.stack,name:a.name,code:a.code};for(var d in a)a.hasOwnProperty(d)&&(c[d]=a[d]);return void postMessage({cmd:"deferred_reject_error",token:data.token,error:c})}returnResult({isDeferred:!0,action:"reject",args:[a]},b)}isDeferred=!0;var c={};return c.fulfil=c.fulfill=c.resolve=function(b){return a(b)},c.reject=function(a){return b(a)},c.transferResolve=function(b){var c=extractTransfers(arguments);return a(b,c)},c.transferReject=function(a){var c=extractTransfers(arguments);return b(a,c)},c};var result=self[data.method].apply(self,args);isDeferred||void 0===result||returnResult({args:[result]}),self.deferred=function(){throw new Error("Operative: deferred() called at odd time")}}})}if("undefined"==typeof window&&self.importScripts)return void workerBoilerScript();var Operative=operative.Operative,URL=window.URL||window.webkitURL,BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder,workerViaBlobSupport=function(){try{new Worker(makeBlobURI(";"))}catch(a){return!1}return!0}(),transferrableObjSupport=function(){try{var a=new ArrayBuffer(1);return new Worker(makeBlobURI(";")).postMessage(a,[a]),!a.byteLength}catch(a){return!1}}();operative.hasWorkerViaBlobSupport=workerViaBlobSupport,operative.hasTransferSupport=transferrableObjSupport,Operative.BrowserWorker=function(){Operative.apply(this,arguments)};var WorkerProto=Operative.BrowserWorker.prototype=operative.objCreate(Operative.prototype);WorkerProto._onWorkerMessage=function(a){var b=a.data;if("string"==typeof b&&0===b.indexOf("pingback"))return"pingback:structuredCloningSupport=NO"===b&&(this._marshal=function(a){return JSON.stringify(a)},this._demarshal=function(a){return JSON.parse(a)}),this.isContextReady=!0,this._postMessage({definitions:this.dataProperties}),void this._dequeueAll();switch(b=this._demarshal(b),b.cmd){case"console":window.console&&window.console[b.method].apply(window.console,b.args);break;case"deferred_reject_error":this.deferreds[b.token].reject(b.error);break;case"result":var c=this.callbacks[b.token],d=this.deferreds[b.token],e=b.result&&b.result.isDeferred&&b.result.action;d&&e?d[e](b.result.args[0]):c?c.apply(this,b.result.args):d&&d.fulfil(b.result.args[0])}},WorkerProto._isWorkerViaBlobSupported=function(){return workerViaBlobSupport},WorkerProto._setup=function(){var a,b=this,c=this._getSelfURL(),d=this._isWorkerViaBlobSupported(),e=this._buildContextScript(d?workerBoilerScript:"");if(this.dependencies.length&&(e='importScripts("'+this.dependencies.join('", "')+'");\n'+e),d)a=this.worker=new Worker(makeBlobURI(e));else{if(!c)throw new Error("Operaritve: No operative.js URL available. Please set via operative.setSelfURL(...)");a=this.worker=new Worker(c),a.postMessage("EVAL|"+e)}a.postMessage("EVAL|self.hasTransferSupport="+transferrableObjSupport),a.postMessage(["PING"]),a.addEventListener("message",function(a){b._onWorkerMessage(a)})},WorkerProto._postMessage=function(a){var b=transferrableObjSupport&&a.transfers;return b?this.worker.postMessage(a,b.value):this.worker.postMessage(this._marshal(a))},WorkerProto._runMethod=function(a,b,c,d){this._postMessage({method:a,args:c,token:b,transfers:d})},WorkerProto.destroy=function(){this.worker.terminate(),Operative.prototype.destroy.call(this)}}(),function(){function a(){window.__run__=function(a,b,c,d){function e(){return c.apply(this,arguments)}var f=!1;window.deferred=function(){return f=!0,d},e.transfer=function(){return c.apply(this,[].slice.call(arguments,0,arguments.length-1))},c&&b.push(e);var g=window[a].apply(window,b);window.deferred=function(){throw new Error("Operative: deferred() called at odd time")},f||void 0===g||e(g)}}if("undefined"!=typeof window||!self.importScripts){var b=operative.Operative;b.Iframe=function(a){b.apply(this,arguments)};var c=b.Iframe.prototype=operative.objCreate(b.prototype),d=0;c._setup=function(){var b=this,c="__operativeIFrameLoaded"+ ++d;this.module.isWorker=!1;var e=this.iframe=document.body.appendChild(document.createElement("iframe"));e.style.display="none";var f=this.iframeWindow=e.contentWindow,g=f.document;window[c]=function(){window[c]=null;var d=g.createElement("script"),e=b._buildContextScript(a);void 0!==d.text?d.text=e:d.innerHTML=e,g.documentElement.appendChild(d);for(var h in b.dataProperties)f[h]=b.dataProperties[h];b.isContextReady=!0,b._dequeueAll()},g.open();var h="";this.dependencies.length&&(h+='\n<script src="'+this.dependencies.join('"></script><script src="')+'"></script>'),g.write(h+"\n<script>setTimeout(window.parent."+c+",0);</script>"),g.close()},c._runMethod=function(a,b,c){var d=this,e=this.callbacks[b],f=this.deferreds[b];this.iframeWindow.__run__(a,c,function(a){var b=e,c=f;b?b.apply(d,arguments):c&&c.fulfil(a)},f)},c.destroy=function(){this.iframe.parentNode.removeChild(this.iframe),b.prototype.destroy.call(this)}}}();

@@ -5,3 +5,3 @@ {

"description": "Operative: Inline Web-Worker Helper",
"version": "0.4.5",
"version": "0.4.6",
"author": "James Padolsey (http://git.io/padolsey)",

@@ -27,2 +27,2 @@ "main": "dist/operative.min.js",

"license": "MIT"
}
}

@@ -319,2 +319,6 @@ # Operative

### Changelog
* 0.4.6 (19 Jan 2017)
* Fix uncloneable native `Error` obj issue (see [#44](https://github.com/padolsey/operative/issues/44) & [#45](https://github.com/padolsey/operative/issues/45))
* 0.4.5
* Fix error `Uncaught ReferenceError: hasTransferSupport is not defined` (see [#43](https://github.com/padolsey/operative/issues/43))
* 0.4.4 (27 Apr 2015)

@@ -321,0 +325,0 @@ * Reverted to a global variable to fix undefined errors in bundles

@@ -89,2 +89,5 @@ /**

break;
case 'deferred_reject_error':
this.deferreds[data.token].reject(data.error);
break;
case 'result':

@@ -279,2 +282,22 @@

function reject(r, transfers) {
if (r instanceof Error) {
// Create an error object that can be cloned: (See #44/#45):
var cloneableError = {
message: r.message,
stack: r.stack,
name: r.name,
code: r.code
};
for (var i in r) {
if (r.hasOwnProperty(i)) {
cloneableError[i] = r[i];
}
}
postMessage({
cmd: 'deferred_reject_error',
token: data.token,
error: cloneableError
});
return;
}
returnResult({

@@ -281,0 +304,0 @@ isDeferred: true,

@@ -100,2 +100,18 @@ describe('Operative (forced iframe context)', function() {

});
describe('Rejecting with an error', function() {
it('Should reject correctly', function(done) {
var op = operative(function() {
var deferred = this.deferred();
deferred.reject(new Error('foo 789'));
});
op().then(function() {
expect(true).to.be.false; // fail
done();
}).catch(function(err) {
console.log(err);
expect(err.message).to.equal('foo 789'); // pass
done();
});
});
});
});

@@ -102,0 +118,0 @@ });

@@ -110,2 +110,35 @@ describe('Operative (worker Context)', function() {

});
describe('Rejecting with an error', function() {
it('Should reject correctly', function(done) {
var op = operative(function() {
var deferred = this.deferred();
deferred.reject(new Error('foo 789'));
});
op().then(function() {
expect(true).to.be.false; // fail
done();
}).catch(function(err) {
expect(err.message).to.equal('foo 789'); // pass
done();
});
});
describe('With additional props', function() {
it('Should reject correctly and be received with props', function(done) {
var op = operative(function() {
var deferred = this.deferred();
var error = new Error('foo');
error.custom = 123;
deferred.reject(error);
});
op().then(function() {
expect(true).to.be.false; // fail
done();
}).catch(function(err) {
expect(err.message).to.equal('foo');
expect(err.custom).to.equal(123);
done();
});
});
});
});
});

@@ -112,0 +145,0 @@ });

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc