inhabit-module-base
Advanced tools
Comparing version 1.1.4 to 1.2.0
@@ -7,2 +7,34 @@ "use strict"; | ||
/** | ||
* setImmediate polyfill | ||
*/ | ||
(function (global) { | ||
if (!global.setImmediate) global.setImmediate = function () { | ||
var head = {}, | ||
tail = head; | ||
var ID = Math.random(); | ||
function onmessage(e) { | ||
if (e.data != ID) return; | ||
head = head.next; | ||
var func = head.func; | ||
delete head.func; | ||
func(); | ||
} | ||
if (global.addEventListener) { | ||
// IE9+ | ||
global.addEventListener('message', onmessage); | ||
} else { | ||
// IE8 | ||
global.attachEvent('onmessage', onmessage); | ||
} | ||
return function (func) { | ||
tail = tail.next = { func: func }; | ||
global.postMessage(ID, "*"); | ||
}; | ||
}(); | ||
})(global || window); | ||
/** | ||
* | ||
@@ -30,33 +62,2 @@ * @param configuration | ||
/** | ||
* Get Content | ||
* @returns {*} | ||
*/ | ||
InhabitModuleBase.prototype.getContent = function () { | ||
setTimeout(this.getDeliveryMethod(), 1); | ||
return this.deferred.promise(); | ||
}; | ||
/** | ||
* | ||
* @returns {boolean} | ||
*/ | ||
InhabitModuleBase.prototype.hasContent = function () { | ||
return !!this.content.length; | ||
}; | ||
/** | ||
* Return a fetch method | ||
*/ | ||
InhabitModuleBase.prototype.getDeliveryMethod = function () { | ||
var deliveryMethod = this.configuration.deliveryMethod.name, | ||
deliveryParameters = this.configuration.deliveryMethod; | ||
if (typeof this[deliveryMethod] !== 'function') { | ||
throw Error('No such deliveryMethod: ' + deliveryMethod); | ||
} | ||
return this[deliveryMethod].bind(this, deliveryParameters); | ||
}; | ||
/** | ||
* Store dependencies | ||
@@ -63,0 +64,0 @@ * @param dependencies |
@@ -9,5 +9,6 @@ /** | ||
source: path.resolve('./src/'), | ||
destination: path.resolve('./build/') | ||
destination: path.resolve('./build/'), | ||
tests: path.resolve('./tests') | ||
}; | ||
module.exports = config; |
{ | ||
"name": "inhabit-module-base", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"description": "A Base Module class for InHabit.", | ||
@@ -29,4 +29,6 @@ "main": "build/InhabitModuleBase.js", | ||
"babel-plugin-transform-async-to-generator": "^6.8.0", | ||
"babel-preset-es2015": "^6.9.0" | ||
"babel-preset-es2015": "^6.9.0", | ||
"tap-spec": "^4.1.1", | ||
"tape": "^4.6.0" | ||
} | ||
} |
@@ -7,2 +7,31 @@ "use strict"; | ||
/** | ||
* setImmediate polyfill | ||
*/ | ||
(function (global) { | ||
if (!global.setImmediate) global.setImmediate = (function() { | ||
var head = { }, tail = head; | ||
var ID = Math.random(); | ||
function onmessage(e) { | ||
if(e.data != ID) return; | ||
head = head.next; | ||
var func = head.func; | ||
delete head.func; | ||
func(); | ||
} | ||
if(global.addEventListener) { // IE9+ | ||
global.addEventListener('message', onmessage); | ||
} else { // IE8 | ||
global.attachEvent('onmessage', onmessage ); | ||
} | ||
return function(func) { | ||
tail = tail.next = { func: func }; | ||
global.postMessage(ID, "*"); | ||
}; | ||
}()); | ||
})(global || window); | ||
/** | ||
* | ||
@@ -31,33 +60,2 @@ * @param configuration | ||
/** | ||
* Get Content | ||
* @returns {*} | ||
*/ | ||
InhabitModuleBase.prototype.getContent = function () { | ||
setTimeout(this.getDeliveryMethod(), 1); | ||
return this.deferred.promise(); | ||
}; | ||
/** | ||
* | ||
* @returns {boolean} | ||
*/ | ||
InhabitModuleBase.prototype.hasContent = function () { | ||
return !!this.content.length; | ||
}; | ||
/** | ||
* Return a fetch method | ||
*/ | ||
InhabitModuleBase.prototype.getDeliveryMethod = function () { | ||
var deliveryMethod = this.configuration.deliveryMethod.name, | ||
deliveryParameters = this.configuration.deliveryMethod; | ||
if (typeof this[deliveryMethod] !== 'function') { | ||
throw Error('No such deliveryMethod: ' + deliveryMethod); | ||
} | ||
return this[deliveryMethod].bind(this, deliveryParameters); | ||
}; | ||
/** | ||
* Store dependencies | ||
@@ -64,0 +62,0 @@ * @param dependencies |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
38155
18
245
6