fetch-inject
Advanced tools
Comparing version 1.7.2 to 1.8.0
@@ -28,3 +28,4 @@ /** | ||
* @param {Promise} [promise] A promise to await before attempting injection. | ||
* @throws {InvalidArgumentException} Invalid args and anything Fetch throws. | ||
* @throws {Promise<SyntaxError>} Rejects with error on invalid arguments. | ||
* @throws {SyntaxError} Via DOM upon attempting to parse unexpected tokens. | ||
* @returns {Promise<Object>[]} A promise which resolves to an `Array` of | ||
@@ -34,4 +35,4 @@ * Objects containing `Response` `Body` properties used by the module. | ||
const fetchInject = function (inputs, promise) { | ||
if (!(inputs && Array.isArray(inputs))) return Promise.reject(new Error('`inputs` must be an array')) | ||
if (promise && !(promise instanceof Promise)) return Promise.reject(new Error('`promise` must be a promise')) | ||
if (!(inputs && Array.isArray(inputs))) return Promise.reject(new SyntaxError('`inputs` must be an array')) | ||
if (promise && !(promise instanceof Promise)) return Promise.reject(new SyntaxError('`promise` must be a promise')) | ||
@@ -38,0 +39,0 @@ const resources = []; |
@@ -1,2 +0,2 @@ | ||
/*! Fetch Inject v1.7.2 | (c) 2017 Josh Habdas | @license ISC */ | ||
const head=function(e,t,n,o,r,c,i){c=t.createElement(n),i=t.getElementsByTagName(n)[0],c.appendChild(t.createTextNode(o.text)),c.onload=r(o),i?i.parentNode.insertBefore(c,i):t.head.appendChild(c)},fetchInject=function(e,t){if(!e||!Array.isArray(e))return Promise.reject(new Error("`inputs` must be an array"));if(t&&!(t instanceof Promise))return Promise.reject(new Error("`promise` must be a promise"));const n=[],o=t?[].concat(t):[],r=[];return e.forEach(e=>o.push(window.fetch(e).then(e=>[e.clone().text(),e.blob()]).then(e=>Promise.all(e).then(e=>{n.push({text:e[0],blob:e[1]})})))),Promise.all(o).then(()=>{n.forEach(e=>{r.push({then:t=>{e.blob.type.includes("text/css")?head(window,document,"style",e,t):head(window,document,"script",e,t)}})});return Promise.all(r)})};export default fetchInject; | ||
/*! Fetch Inject v1.8.0 | (c) 2017 Josh Habdas | @license ISC */ | ||
const head=function(e,t,n,o,r,c,i){c=t.createElement(n),i=t.getElementsByTagName(n)[0],c.appendChild(t.createTextNode(o.text)),c.onload=r(o),i?i.parentNode.insertBefore(c,i):t.head.appendChild(c)},fetchInject=function(e,t){if(!e||!Array.isArray(e))return Promise.reject(new SyntaxError("`inputs` must be an array"));if(t&&!(t instanceof Promise))return Promise.reject(new SyntaxError("`promise` must be a promise"));const n=[],o=t?[].concat(t):[],r=[];return e.forEach(e=>o.push(window.fetch(e).then(e=>[e.clone().text(),e.blob()]).then(e=>Promise.all(e).then(e=>{n.push({text:e[0],blob:e[1]})})))),Promise.all(o).then(()=>{n.forEach(e=>{r.push({then:t=>{e.blob.type.includes("text/css")?head(window,document,"style",e,t):head(window,document,"script",e,t)}})});return Promise.all(r)})};export default fetchInject; |
@@ -31,3 +31,4 @@ var fetchInject = (function () { | ||
* @param {Promise} [promise] A promise to await before attempting injection. | ||
* @throws {InvalidArgumentException} Invalid args and anything Fetch throws. | ||
* @throws {Promise<SyntaxError>} Rejects with error on invalid arguments. | ||
* @throws {SyntaxError} Via DOM upon attempting to parse unexpected tokens. | ||
* @returns {Promise<Object>[]} A promise which resolves to an `Array` of | ||
@@ -37,4 +38,4 @@ * Objects containing `Response` `Body` properties used by the module. | ||
const fetchInject = function (inputs, promise) { | ||
if (!(inputs && Array.isArray(inputs))) return Promise.reject(new Error('`inputs` must be an array')) | ||
if (promise && !(promise instanceof Promise)) return Promise.reject(new Error('`promise` must be a promise')) | ||
if (!(inputs && Array.isArray(inputs))) return Promise.reject(new SyntaxError('`inputs` must be an array')) | ||
if (promise && !(promise instanceof Promise)) return Promise.reject(new SyntaxError('`promise` must be a promise')) | ||
@@ -41,0 +42,0 @@ const resources = []; |
@@ -1,2 +0,2 @@ | ||
/*! Fetch Inject v1.7.2 | (c) 2017 Josh Habdas | @license ISC */ | ||
var fetchInject=function(){"use strict";const e=function(e,t,n,r,o,i,c){i=t.createElement(n),c=t.getElementsByTagName(n)[0],i.appendChild(t.createTextNode(r.text)),i.onload=o(r),c?c.parentNode.insertBefore(i,c):t.head.appendChild(i)};return function(t,n){if(!t||!Array.isArray(t))return Promise.reject(new Error("`inputs` must be an array"));if(n&&!(n instanceof Promise))return Promise.reject(new Error("`promise` must be a promise"));const r=[],o=n?[].concat(n):[],i=[];return t.forEach(e=>o.push(window.fetch(e).then(e=>[e.clone().text(),e.blob()]).then(e=>Promise.all(e).then(e=>{r.push({text:e[0],blob:e[1]})})))),Promise.all(o).then(()=>{r.forEach(t=>{i.push({then:n=>{t.blob.type.includes("text/css")?e(window,document,"style",t,n):e(window,document,"script",t,n)}})});return Promise.all(i)})}}(); | ||
/*! Fetch Inject v1.8.0 | (c) 2017 Josh Habdas | @license ISC */ | ||
var fetchInject=function(){"use strict";const e=function(e,t,n,r,o,i,c){i=t.createElement(n),c=t.getElementsByTagName(n)[0],i.appendChild(t.createTextNode(r.text)),i.onload=o(r),c?c.parentNode.insertBefore(i,c):t.head.appendChild(i)};return function(t,n){if(!t||!Array.isArray(t))return Promise.reject(new SyntaxError("`inputs` must be an array"));if(n&&!(n instanceof Promise))return Promise.reject(new SyntaxError("`promise` must be a promise"));const r=[],o=n?[].concat(n):[],i=[];return t.forEach(e=>o.push(window.fetch(e).then(e=>[e.clone().text(),e.blob()]).then(e=>Promise.all(e).then(e=>{r.push({text:e[0],blob:e[1]})})))),Promise.all(o).then(()=>{r.forEach(t=>{i.push({then:n=>{t.blob.type.includes("text/css")?e(window,document,"style",t,n):e(window,document,"script",t,n)}})});return Promise.all(i)})}}(); |
@@ -34,3 +34,4 @@ (function (global, factory) { | ||
* @param {Promise} [promise] A promise to await before attempting injection. | ||
* @throws {InvalidArgumentException} Invalid args and anything Fetch throws. | ||
* @throws {Promise<SyntaxError>} Rejects with error on invalid arguments. | ||
* @throws {SyntaxError} Via DOM upon attempting to parse unexpected tokens. | ||
* @returns {Promise<Object>[]} A promise which resolves to an `Array` of | ||
@@ -40,4 +41,4 @@ * Objects containing `Response` `Body` properties used by the module. | ||
const fetchInject = function (inputs, promise) { | ||
if (!(inputs && Array.isArray(inputs))) return Promise.reject(new Error('`inputs` must be an array')) | ||
if (promise && !(promise instanceof Promise)) return Promise.reject(new Error('`promise` must be a promise')) | ||
if (!(inputs && Array.isArray(inputs))) return Promise.reject(new SyntaxError('`inputs` must be an array')) | ||
if (promise && !(promise instanceof Promise)) return Promise.reject(new SyntaxError('`promise` must be a promise')) | ||
@@ -44,0 +45,0 @@ const resources = []; |
@@ -1,2 +0,2 @@ | ||
/*! Fetch Inject v1.7.2 | (c) 2017 Josh Habdas | @license ISC */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.fetchInject=t()}(this,function(){"use strict";const e=function(e,t,n,o,r,i,c){i=t.createElement(n),c=t.getElementsByTagName(n)[0],i.appendChild(t.createTextNode(o.text)),i.onload=r(o),c?c.parentNode.insertBefore(i,c):t.head.appendChild(i)};return function(t,n){if(!t||!Array.isArray(t))return Promise.reject(new Error("`inputs` must be an array"));if(n&&!(n instanceof Promise))return Promise.reject(new Error("`promise` must be a promise"));const o=[],r=n?[].concat(n):[],i=[];return t.forEach(e=>r.push(window.fetch(e).then(e=>[e.clone().text(),e.blob()]).then(e=>Promise.all(e).then(e=>{o.push({text:e[0],blob:e[1]})})))),Promise.all(r).then(()=>{o.forEach(t=>{i.push({then:n=>{t.blob.type.includes("text/css")?e(window,document,"style",t,n):e(window,document,"script",t,n)}})});return Promise.all(i)})}}); | ||
/*! Fetch Inject v1.8.0 | (c) 2017 Josh Habdas | @license ISC */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.fetchInject=t()}(this,function(){"use strict";const e=function(e,t,n,o,r,i,c){i=t.createElement(n),c=t.getElementsByTagName(n)[0],i.appendChild(t.createTextNode(o.text)),i.onload=r(o),c?c.parentNode.insertBefore(i,c):t.head.appendChild(i)};return function(t,n){if(!t||!Array.isArray(t))return Promise.reject(new SyntaxError("`inputs` must be an array"));if(n&&!(n instanceof Promise))return Promise.reject(new SyntaxError("`promise` must be a promise"));const o=[],r=n?[].concat(n):[],i=[];return t.forEach(e=>r.push(window.fetch(e).then(e=>[e.clone().text(),e.blob()]).then(e=>Promise.all(e).then(e=>{o.push({text:e[0],blob:e[1]})})))),Promise.all(r).then(()=>{o.forEach(t=>{i.push({then:n=>{t.blob.type.includes("text/css")?e(window,document,"style",t,n):e(window,document,"script",t,n)}})});return Promise.all(i)})}}); |
{ | ||
"name": "fetch-inject", | ||
"version": "1.7.2", | ||
"version": "1.8.0", | ||
"description": "Dynamically inline assets into the DOM using Fetch Injection.", | ||
@@ -36,3 +36,3 @@ "author": "Josh Habdas <josh@habd.as> (https://habd.as/)", | ||
"semantic-release": "^6.3.2", | ||
"standard": "^9.0.2", | ||
"standard": "^10.0.2", | ||
"uglify-es": "^3.0.12" | ||
@@ -39,0 +39,0 @@ }, |
@@ -12,3 +12,3 @@ <h1 align="center">Fetch Inject</h1> | ||
<a href="https://cdn.jsdelivr.net/npm/fetch-inject"> | ||
<img src="http://img.badgesize.io/https://cdn.jsdelivr.net/npm/fetch-inject?compression=gzip&style=flat-square" alt="Compressed size of UMD bundle"> | ||
<img src="http://img.badgesize.io/https://cdn.jsdelivr.net/npm/fetch-inject@latest/dist/fetch-inject.min.js?compression=gzip&style=flat-square" alt="Size of IIFE bundle with gzip compression"> | ||
</a> | ||
@@ -15,0 +15,0 @@ <a href="https://travis-ci.org/jhabdas/fetch-inject"> |
@@ -12,3 +12,4 @@ import { | ||
* @param {Promise} [promise] A promise to await before attempting injection. | ||
* @throws {InvalidArgumentException} Invalid args and anything Fetch throws. | ||
* @throws {Promise<SyntaxError>} Rejects with error on invalid arguments. | ||
* @throws {SyntaxError} Via DOM upon attempting to parse unexpected tokens. | ||
* @returns {Promise<Object>[]} A promise which resolves to an `Array` of | ||
@@ -18,4 +19,4 @@ * Objects containing `Response` `Body` properties used by the module. | ||
const fetchInject = function (inputs, promise) { | ||
if (!(inputs && Array.isArray(inputs))) return Promise.reject(new Error('`inputs` must be an array')) | ||
if (promise && !(promise instanceof Promise)) return Promise.reject(new Error('`promise` must be a promise')) | ||
if (!(inputs && Array.isArray(inputs))) return Promise.reject(new SyntaxError('`inputs` must be an array')) | ||
if (promise && !(promise instanceof Promise)) return Promise.reject(new SyntaxError('`promise` must be a promise')) | ||
@@ -22,0 +23,0 @@ const resources = [] |
386322
316