Comparing version 2.1.2 to 3.0.0
{ | ||
"name": "loadjs", | ||
"version": "2.1.2", | ||
"version": "3.0.0", | ||
"license": "MIT", | ||
@@ -11,4 +11,3 @@ "authors": [ | ||
"main": [ | ||
"dist/loadjs.js", | ||
"dist/loadjs.min.js" | ||
"dist/loadjs.js" | ||
], | ||
@@ -15,0 +14,0 @@ "repository": { |
# LoadJS Changelog | ||
## 3.0.0 - August 25, 2016 | ||
* Changed 'fail' callback name to 'error' | ||
* Fixed bug in main attribute of bower.json | ||
## 2.1.2 - August 22, 2016 | ||
@@ -4,0 +9,0 @@ |
@@ -162,4 +162,4 @@ loadjs = (function () { | ||
* @param {(string|Function)} [arg1] - The bundleId or success callback | ||
* @param {Function} [arg2] - The success or fail callback | ||
* @param {Function} [arg3] - The fail callback | ||
* @param {Function} [arg2] - The success or error callback | ||
* @param {Function} [arg3] - The error callback | ||
*/ | ||
@@ -186,4 +186,4 @@ function loadjs(paths, arg1, arg2) { | ||
loadFiles(paths, function(pathsNotFound) { | ||
// success and fail callbacks | ||
if (pathsNotFound.length) (args.fail || devnull)(pathsNotFound); | ||
// success and error callbacks | ||
if (pathsNotFound.length) (args.error || devnull)(pathsNotFound); | ||
else (args.success || devnull)(); | ||
@@ -200,3 +200,3 @@ | ||
* @param {(string|string[])} deps - List of bundle ids | ||
* @param {Object} args - success/fail arguments | ||
* @param {Object} args - success/error arguments | ||
*/ | ||
@@ -207,3 +207,3 @@ loadjs.ready = function (deps, args) { | ||
// execute callbacks | ||
if (depsNotFound.length) (args.fail || devnull)(depsNotFound); | ||
if (depsNotFound.length) (args.error || devnull)(depsNotFound); | ||
else (args.success || devnull)(); | ||
@@ -210,0 +210,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
loadjs=function(){function n(n,e){n=n.push?n:[n];var t,r,i,o,c=[],s=n.length,a=s;for(t=function(n,t){t.length&&c.push(n),a--,a||e(c)};s--;)r=n[s],i=f[r],i?t(r,i):(o=u[r]=u[r]||[],o.push(t))}function e(n,e){if(n){var t=u[n];if(f[n]=e,t)for(;t.length;)t[0](n,e),t.splice(0,1)}}function t(n,e,t){var r,i,o=document;/\.css$/.test(n)?(r=!0,i=o.createElement("link"),i.rel="stylesheet",i.href=n):(i=o.createElement("script"),i.src=n,i.async=void 0===t||t),i.onload=i.onerror=i.onbeforeload=function(t){var o=t.type[0];if(r&&"hideFocus"in i)try{i.sheet.cssText.length||(o="e")}catch(n){o="e"}e(n,o,t.defaultPrevented)},o.head.appendChild(i)}function r(n,e,r){n=n.push?n:[n];var i,o,c=n.length,f=c,u=[];for(i=function(n,t,r){if("e"==t&&u.push(n),"b"==t){if(!r)return;u.push(n)}c--,c||e(u)},o=0;o<f;o++)t(n[o],i,r)}function i(n,t,i){var f,u;if(t&&t.trim&&(f=t),u=(f?i:t)||{},f){if(f in c)throw new Error("LoadJS");c[f]=!0}r(n,function(n){n.length?(u.fail||o)(n):(u.success||o)(),e(f,n)},u.async)}var o=function(){},c={},f={},u={};return i.ready=function(e,t){return n(e,function(n){n.length?(t.fail||o)(n):(t.success||o)()}),i},i.done=function(n){e(n,[])},i}(); | ||
loadjs=function(){function n(n,e){n=n.push?n:[n];var t,r,o,c,i=[],s=n.length,h=s;for(t=function(n,t){t.length&&i.push(n),h--,h||e(i)};s--;)r=n[s],o=u[r],o?t(r,o):(c=f[r]=f[r]||[],c.push(t))}function e(n,e){if(n){var t=f[n];if(u[n]=e,t)for(;t.length;)t[0](n,e),t.splice(0,1)}}function t(n,e,t){var r,o,c=document;/\.css$/.test(n)?(r=!0,o=c.createElement("link"),o.rel="stylesheet",o.href=n):(o=c.createElement("script"),o.src=n,o.async=void 0===t||t),o.onload=o.onerror=o.onbeforeload=function(t){var c=t.type[0];if(r&&"hideFocus"in o)try{o.sheet.cssText.length||(c="e")}catch(n){c="e"}e(n,c,t.defaultPrevented)},c.head.appendChild(o)}function r(n,e,r){n=n.push?n:[n];var o,c,i=n.length,u=i,f=[];for(o=function(n,t,r){if("e"==t&&f.push(n),"b"==t){if(!r)return;f.push(n)}i--,i||e(f)},c=0;c<u;c++)t(n[c],o,r)}function o(n,t,o){var u,f;if(t&&t.trim&&(u=t),f=(u?o:t)||{},u){if(u in i)throw new Error("LoadJS");i[u]=!0}r(n,function(n){n.length?(f.error||c)(n):(f.success||c)(),e(u,n)},f.async)}var c=function(){},i={},u={},f={};return o.ready=function(e,t){return n(e,function(n){n.length?(t.error||c)(n):(t.success||c)()}),o},o.done=function(n){e(n,[])},o}(); |
@@ -170,4 +170,4 @@ (function(root, factory) { | ||
* @param {(string|Function)} [arg1] - The bundleId or success callback | ||
* @param {Function} [arg2] - The success or fail callback | ||
* @param {Function} [arg3] - The fail callback | ||
* @param {Function} [arg2] - The success or error callback | ||
* @param {Function} [arg3] - The error callback | ||
*/ | ||
@@ -194,4 +194,4 @@ function loadjs(paths, arg1, arg2) { | ||
loadFiles(paths, function(pathsNotFound) { | ||
// success and fail callbacks | ||
if (pathsNotFound.length) (args.fail || devnull)(pathsNotFound); | ||
// success and error callbacks | ||
if (pathsNotFound.length) (args.error || devnull)(pathsNotFound); | ||
else (args.success || devnull)(); | ||
@@ -208,3 +208,3 @@ | ||
* @param {(string|string[])} deps - List of bundle ids | ||
* @param {Object} args - success/fail arguments | ||
* @param {Object} args - success/error arguments | ||
*/ | ||
@@ -215,3 +215,3 @@ loadjs.ready = function (deps, args) { | ||
// execute callbacks | ||
if (depsNotFound.length) (args.fail || devnull)(depsNotFound); | ||
if (depsNotFound.length) (args.error || devnull)(depsNotFound); | ||
else (args.success || devnull)(); | ||
@@ -218,0 +218,0 @@ }); |
@@ -162,4 +162,4 @@ loadjs = (function () { | ||
* @param {(string|Function)} [arg1] - The bundleId or success callback | ||
* @param {Function} [arg2] - The success or fail callback | ||
* @param {Function} [arg3] - The fail callback | ||
* @param {Function} [arg2] - The success or error callback | ||
* @param {Function} [arg3] - The error callback | ||
*/ | ||
@@ -186,4 +186,4 @@ function loadjs(paths, arg1, arg2) { | ||
loadFiles(paths, function(pathsNotFound) { | ||
// success and fail callbacks | ||
if (pathsNotFound.length) (args.fail || devnull)(pathsNotFound); | ||
// success and error callbacks | ||
if (pathsNotFound.length) (args.error || devnull)(pathsNotFound); | ||
else (args.success || devnull)(); | ||
@@ -200,3 +200,3 @@ | ||
* @param {(string|string[])} deps - List of bundle ids | ||
* @param {Object} args - success/fail arguments | ||
* @param {Object} args - success/error arguments | ||
*/ | ||
@@ -207,3 +207,3 @@ loadjs.ready = function (deps, args) { | ||
// execute callbacks | ||
if (depsNotFound.length) (args.fail || devnull)(depsNotFound); | ||
if (depsNotFound.length) (args.error || devnull)(depsNotFound); | ||
else (args.success || devnull)(); | ||
@@ -210,0 +210,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
loadjs=function(){function n(n,e){n=n.push?n:[n];var t,r,i,o,c=[],s=n.length,a=s;for(t=function(n,t){t.length&&c.push(n),a--,a||e(c)};s--;)r=n[s],i=f[r],i?t(r,i):(o=u[r]=u[r]||[],o.push(t))}function e(n,e){if(n){var t=u[n];if(f[n]=e,t)for(;t.length;)t[0](n,e),t.splice(0,1)}}function t(n,e,t){var r,i,o=document;/\.css$/.test(n)?(r=!0,i=o.createElement("link"),i.rel="stylesheet",i.href=n):(i=o.createElement("script"),i.src=n,i.async=void 0===t||t),i.onload=i.onerror=i.onbeforeload=function(t){var o=t.type[0];if(r&&"hideFocus"in i)try{i.sheet.cssText.length||(o="e")}catch(n){o="e"}e(n,o,t.defaultPrevented)},o.head.appendChild(i)}function r(n,e,r){n=n.push?n:[n];var i,o,c=n.length,f=c,u=[];for(i=function(n,t,r){if("e"==t&&u.push(n),"b"==t){if(!r)return;u.push(n)}c--,c||e(u)},o=0;o<f;o++)t(n[o],i,r)}function i(n,t,i){var f,u;if(t&&t.trim&&(f=t),u=(f?i:t)||{},f){if(f in c)throw new Error("LoadJS");c[f]=!0}r(n,function(n){n.length?(u.fail||o)(n):(u.success||o)(),e(f,n)},u.async)}var o=function(){},c={},f={},u={};return i.ready=function(e,t){return n(e,function(n){n.length?(t.fail||o)(n):(t.success||o)()}),i},i.done=function(n){e(n,[])},i}(); | ||
loadjs=function(){function n(n,e){n=n.push?n:[n];var t,r,o,c,i=[],s=n.length,h=s;for(t=function(n,t){t.length&&i.push(n),h--,h||e(i)};s--;)r=n[s],o=u[r],o?t(r,o):(c=f[r]=f[r]||[],c.push(t))}function e(n,e){if(n){var t=f[n];if(u[n]=e,t)for(;t.length;)t[0](n,e),t.splice(0,1)}}function t(n,e,t){var r,o,c=document;/\.css$/.test(n)?(r=!0,o=c.createElement("link"),o.rel="stylesheet",o.href=n):(o=c.createElement("script"),o.src=n,o.async=void 0===t||t),o.onload=o.onerror=o.onbeforeload=function(t){var c=t.type[0];if(r&&"hideFocus"in o)try{o.sheet.cssText.length||(c="e")}catch(n){c="e"}e(n,c,t.defaultPrevented)},c.head.appendChild(o)}function r(n,e,r){n=n.push?n:[n];var o,c,i=n.length,u=i,f=[];for(o=function(n,t,r){if("e"==t&&f.push(n),"b"==t){if(!r)return;f.push(n)}i--,i||e(f)},c=0;c<u;c++)t(n[c],o,r)}function o(n,t,o){var u,f;if(t&&t.trim&&(u=t),f=(u?o:t)||{},u){if(u in i)throw new Error("LoadJS");i[u]=!0}r(n,function(n){n.length?(f.error||c)(n):(f.success||c)(),e(u,n)},f.async)}var c=function(){},i={},u={},f={};return o.ready=function(e,t){return n(e,function(n){n.length?(t.error||c)(n):(t.success||c)()}),o},o.done=function(n){e(n,[])},o}(); |
{ | ||
"name": "loadjs", | ||
"version": "2.1.2", | ||
"version": "3.0.0", | ||
"license": "MIT", | ||
@@ -23,3 +23,3 @@ "description": "Tiny async loader for modern browsers", | ||
"del": "2.2.2", | ||
"gulp": "git+https://github.com/gulpjs/gulp#4ed9a4a3275559c73a396eff7e1fde3824951ebb", | ||
"gulp": "git+https://github.com/gulpjs/gulp#4.0", | ||
"gulp-jshint": "2.0.1", | ||
@@ -26,0 +26,0 @@ "gulp-rename": "1.2.2", |
@@ -14,3 +14,3 @@ # LoadJS | ||
LoadJS is based on the excellent <a href="https://github.com/ded/script.js">$script</a> library by <a href="https://github.com/ded">Dustin Diaz</a>. We kept the behavior of the library the same but we re-wrote the code from scratch to add support for success/failure callbacks and to optimize the library for modern browsers. LoadJS is 654 bytes (minified + gzipped). | ||
LoadJS is based on the excellent <a href="https://github.com/ded/script.js">$script</a> library by <a href="https://github.com/ded">Dustin Diaz</a>. We kept the behavior of the library the same but we re-wrote the code from scratch to add support for success/error callbacks and to optimize the library for modern browsers. LoadJS is 654 bytes (minified + gzipped). | ||
@@ -26,3 +26,3 @@ Here's an example of what you can do with LoadJS: | ||
success: function() { /* foo.js & bar.js loaded */ }, | ||
fail: function(depsNotFound) { /* foobar bundle load failed */ } | ||
error: function(depsNotFound) { /* foobar bundle load failed */ } | ||
}); | ||
@@ -48,3 +48,3 @@ ``` | ||
success: function() { /* foo.js & bar.js loaded */ }, | ||
fail: function(depsNotFound) {/* foobar bundle load failed */} | ||
error: function(depsNotFound) {/* foobar bundle load failed */} | ||
}); | ||
@@ -63,3 +63,3 @@ ``` | ||
LoadJS also detects script failures from AdBlock Plus and Ghostery in: | ||
LoadJS also detects script load failures from AdBlock Plus and Ghostery in: | ||
@@ -114,3 +114,3 @@ * Safari | ||
1. Add a failure callback | ||
1. Add an error callback | ||
@@ -120,3 +120,3 @@ ```javascript | ||
success: function() { /* foo.js & bar.js loaded */ }, | ||
fail: function(pathsNotFound) { /* at least one path didn't load */ } | ||
error: function(pathsNotFound) { /* at least one path didn't load */ } | ||
}); | ||
@@ -162,3 +162,3 @@ ``` | ||
}, | ||
fail: function(depsNotFound) { | ||
error: function(depsNotFound) { | ||
if (depsNotFound.indexOf('foo') > -1) {}; // foo failed | ||
@@ -165,0 +165,0 @@ if (depsNotFound.indexOf('bar') > -1) {}; // bar failed |
@@ -161,4 +161,4 @@ /** | ||
* @param {(string|Function)} [arg1] - The bundleId or success callback | ||
* @param {Function} [arg2] - The success or fail callback | ||
* @param {Function} [arg3] - The fail callback | ||
* @param {Function} [arg2] - The success or error callback | ||
* @param {Function} [arg3] - The error callback | ||
*/ | ||
@@ -185,4 +185,4 @@ function loadjs(paths, arg1, arg2) { | ||
loadFiles(paths, function(pathsNotFound) { | ||
// success and fail callbacks | ||
if (pathsNotFound.length) (args.fail || devnull)(pathsNotFound); | ||
// success and error callbacks | ||
if (pathsNotFound.length) (args.error || devnull)(pathsNotFound); | ||
else (args.success || devnull)(); | ||
@@ -199,3 +199,3 @@ | ||
* @param {(string|string[])} deps - List of bundle ids | ||
* @param {Object} args - success/fail arguments | ||
* @param {Object} args - success/error arguments | ||
*/ | ||
@@ -206,3 +206,3 @@ loadjs.ready = function (deps, args) { | ||
// execute callbacks | ||
if (depsNotFound.length) (args.fail || devnull)(depsNotFound); | ||
if (depsNotFound.length) (args.error || devnull)(depsNotFound); | ||
else (args.success || devnull)(); | ||
@@ -209,0 +209,0 @@ }); |
@@ -162,4 +162,4 @@ loadjs = (function () { | ||
* @param {(string|Function)} [arg1] - The bundleId or success callback | ||
* @param {Function} [arg2] - The success or fail callback | ||
* @param {Function} [arg3] - The fail callback | ||
* @param {Function} [arg2] - The success or error callback | ||
* @param {Function} [arg3] - The error callback | ||
*/ | ||
@@ -186,4 +186,4 @@ function loadjs(paths, arg1, arg2) { | ||
loadFiles(paths, function(pathsNotFound) { | ||
// success and fail callbacks | ||
if (pathsNotFound.length) (args.fail || devnull)(pathsNotFound); | ||
// success and error callbacks | ||
if (pathsNotFound.length) (args.error || devnull)(pathsNotFound); | ||
else (args.success || devnull)(); | ||
@@ -200,3 +200,3 @@ | ||
* @param {(string|string[])} deps - List of bundle ids | ||
* @param {Object} args - success/fail arguments | ||
* @param {Object} args - success/error arguments | ||
*/ | ||
@@ -207,3 +207,3 @@ loadjs.ready = function (deps, args) { | ||
// execute callbacks | ||
if (depsNotFound.length) (args.fail || devnull)(depsNotFound); | ||
if (depsNotFound.length) (args.error || devnull)(depsNotFound); | ||
else (args.success || devnull)(); | ||
@@ -210,0 +210,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
loadjs=function(){function n(n,e){n=n.push?n:[n];var t,r,i,o,c=[],s=n.length,a=s;for(t=function(n,t){t.length&&c.push(n),a--,a||e(c)};s--;)r=n[s],i=f[r],i?t(r,i):(o=u[r]=u[r]||[],o.push(t))}function e(n,e){if(n){var t=u[n];if(f[n]=e,t)for(;t.length;)t[0](n,e),t.splice(0,1)}}function t(n,e,t){var r,i,o=document;/\.css$/.test(n)?(r=!0,i=o.createElement("link"),i.rel="stylesheet",i.href=n):(i=o.createElement("script"),i.src=n,i.async=void 0===t||t),i.onload=i.onerror=i.onbeforeload=function(t){var o=t.type[0];if(r&&"hideFocus"in i)try{i.sheet.cssText.length||(o="e")}catch(n){o="e"}e(n,o,t.defaultPrevented)},o.head.appendChild(i)}function r(n,e,r){n=n.push?n:[n];var i,o,c=n.length,f=c,u=[];for(i=function(n,t,r){if("e"==t&&u.push(n),"b"==t){if(!r)return;u.push(n)}c--,c||e(u)},o=0;o<f;o++)t(n[o],i,r)}function i(n,t,i){var f,u;if(t&&t.trim&&(f=t),u=(f?i:t)||{},f){if(f in c)throw new Error("LoadJS");c[f]=!0}r(n,function(n){n.length?(u.fail||o)(n):(u.success||o)(),e(f,n)},u.async)}var o=function(){},c={},f={},u={};return i.ready=function(e,t){return n(e,function(n){n.length?(t.fail||o)(n):(t.success||o)()}),i},i.done=function(n){e(n,[])},i}(); | ||
loadjs=function(){function n(n,e){n=n.push?n:[n];var t,r,o,c,i=[],s=n.length,h=s;for(t=function(n,t){t.length&&i.push(n),h--,h||e(i)};s--;)r=n[s],o=u[r],o?t(r,o):(c=f[r]=f[r]||[],c.push(t))}function e(n,e){if(n){var t=f[n];if(u[n]=e,t)for(;t.length;)t[0](n,e),t.splice(0,1)}}function t(n,e,t){var r,o,c=document;/\.css$/.test(n)?(r=!0,o=c.createElement("link"),o.rel="stylesheet",o.href=n):(o=c.createElement("script"),o.src=n,o.async=void 0===t||t),o.onload=o.onerror=o.onbeforeload=function(t){var c=t.type[0];if(r&&"hideFocus"in o)try{o.sheet.cssText.length||(c="e")}catch(n){c="e"}e(n,c,t.defaultPrevented)},c.head.appendChild(o)}function r(n,e,r){n=n.push?n:[n];var o,c,i=n.length,u=i,f=[];for(o=function(n,t,r){if("e"==t&&f.push(n),"b"==t){if(!r)return;f.push(n)}i--,i||e(f)},c=0;c<u;c++)t(n[c],o,r)}function o(n,t,o){var u,f;if(t&&t.trim&&(u=t),f=(u?o:t)||{},u){if(u in i)throw new Error("LoadJS");i[u]=!0}r(n,function(n){n.length?(f.error||c)(n):(f.success||c)(),e(u,n)},f.async)}var c=function(){},i={},u={},f={};return o.ready=function(e,t){return n(e,function(n){n.length?(t.error||c)(n):(t.success||c)()}),o},o.done=function(n){e(n,[])},o}(); |
@@ -38,3 +38,3 @@ /** | ||
it('should call fail callback on invalid path', function(done) { | ||
it('should call error callback on invalid path', function(done) { | ||
loadjs(['assets/file-doesntexist.js'], { | ||
@@ -44,3 +44,3 @@ success: function() { | ||
}, | ||
fail: function(pathsNotFound) { | ||
error: function(pathsNotFound) { | ||
assert.equal(pathsNotFound.length, 1); | ||
@@ -65,3 +65,3 @@ assert.equal(pathsNotFound[0], 'assets/file-doesntexist.js'); | ||
it('should call fail callback on one invalid path', function(done) { | ||
it('should call error callback on one invalid path', function(done) { | ||
loadjs(['assets/file1.js', 'assets/file-doesntexist.js'], { | ||
@@ -71,3 +71,3 @@ success: function() { | ||
}, | ||
fail: function(pathsNotFound) { | ||
error: function(pathsNotFound) { | ||
assert.equal(pathsLoaded['file1.js'], true); | ||
@@ -139,3 +139,3 @@ assert.equal(pathsNotFound.length, 1); | ||
}, | ||
fail: function(pathsNotFound) { | ||
error: function(pathsNotFound) { | ||
assert.equal(pathsLoaded['file1.js'], true); | ||
@@ -204,3 +204,3 @@ assert.equal(pathsNotFound.length, 1); | ||
it('should call fail callback on one invalid path', function(done) { | ||
it('should call error callback on one invalid path', function(done) { | ||
loadjs(['assets/file1.css', 'assets/file-doesntexist.css'], { | ||
@@ -210,3 +210,3 @@ success: function() { | ||
}, | ||
fail: function(pathsNotFound) { | ||
error: function(pathsNotFound) { | ||
assert.equal(testEl.offsetWidth, 100); | ||
@@ -245,3 +245,3 @@ assert.equal(pathsNotFound.length, 1); | ||
it('should call failure on missing external file', function(done) { | ||
it('should call errorure on missing external file', function(done) { | ||
this.timeout(0); | ||
@@ -253,3 +253,3 @@ | ||
}, | ||
fail: function(pathsNotFound) { | ||
error: function(pathsNotFound) { | ||
var styleObj = getComputedStyle(testEl); | ||
@@ -341,3 +341,3 @@ assert.equal(styleObj.getPropertyValue('padding-left'), '0px'); | ||
it('should fail on missing depdendencies', function(done) { | ||
it('should error on missing depdendencies', function(done) { | ||
loadjs('assets/file1.js', 'bundle9'); | ||
@@ -350,3 +350,3 @@ loadjs('assets/file-doesntexist.js', 'bundle10'); | ||
}, | ||
fail: function(depsNotFound) { | ||
error: function(depsNotFound) { | ||
assert.equal(pathsLoaded['file1.js'], true); | ||
@@ -353,0 +353,0 @@ assert.equal(depsNotFound.length, 1); |
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
344787
11720