simple-load-script
Advanced tools
Comparing version 2.0.0-beta.0 to 2.0.0-beta.1
@@ -1,1 +0,1 @@ | ||
"use strict";const e={url:"",attrs:{},inBody:!1,insertInto:null,removeScript:!1};module.exports=function r(o){return Array.isArray(o)?Promise.all(o.map(r)):new Promise(((r,t)=>{if(!("object"==typeof o&&o.url||"string"==typeof o))return console.log({config:o}),void t(new Error("Object with url or url string needed"));const n=Object.assign({},e,"string"==typeof o?{url:o}:o),{url:i,attrs:s,inBody:c,insertInto:l,removeScript:d}=n,u=document.createElement("script"),a=l?document.querySelector(l):c?document.body:document.head;if(s&&"object"==typeof s)for(const e of Object.keys(s))u.setAttribute(e,s[e]);console.log({config:o,configProcessed:n}),null!=a?(u.addEventListener("load",(()=>{d&&a.removeChild(u),r(d?void 0:u)})),u.addEventListener("error",(e=>{console.log(e),d&&a.removeChild(u),t(new Error("Loading script"))})),u.src=i,a.appendChild(u)):t(new Error("No DOM element to append script"))}))}; | ||
"use strict";const e={url:"",attrs:{},inBody:!1,insertInto:null,removeScript:!1};module.exports=function r(o){return Array.isArray(o)?Promise.all(o.map(r)):new Promise(((r,t)=>{if(!("object"==typeof o&&o.url||"string"==typeof o))return console.log({config:o}),void t(new Error("Object with url or url string needed"));const n=Object.assign({},e,"string"==typeof o?{url:o}:o),{url:i,attrs:s,inBody:c,insertInto:l,removeScript:d}=n,u=document.createElement("script"),a=l?document.querySelector(l):c?document.body:document.head;if(s&&"object"==typeof s)for(const e of Object.keys(s))u.setAttribute(e,s[e]);console.log({config:o,configProcessed:n}),null!=a?(u.addEventListener("load",(()=>{d&&a.removeChild(u),r(d?void 0:u)})),u.addEventListener("error",(e=>{console.log(e),d&&a.removeChild(u),t(new Error("Loading script error"))})),u.src=i,a.appendChild(u)):t(new Error("No DOM element to append script"))}))}; |
@@ -1,1 +0,1 @@ | ||
const e={url:"",attrs:{},inBody:!1,insertInto:null,removeScript:!1};function r(o){return Array.isArray(o)?Promise.all(o.map(r)):new Promise(((r,t)=>{if(!("object"==typeof o&&o.url||"string"==typeof o))return console.log({config:o}),void t(new Error("Object with url or url string needed"));const n=Object.assign({},e,"string"==typeof o?{url:o}:o),{url:i,attrs:s,inBody:c,insertInto:l,removeScript:d}=n,u=document.createElement("script"),a=l?document.querySelector(l):c?document.body:document.head;if(s&&"object"==typeof s)for(const e of Object.keys(s))u.setAttribute(e,s[e]);console.log({config:o,configProcessed:n}),null!=a?(u.addEventListener("load",(()=>{d&&a.removeChild(u),r(d?void 0:u)})),u.addEventListener("error",(e=>{console.log(e),d&&a.removeChild(u),t(new Error("Loading script"))})),u.src=i,a.appendChild(u)):t(new Error("No DOM element to append script"))}))}export{r as default}; | ||
const e={url:"",attrs:{},inBody:!1,insertInto:null,removeScript:!1};function r(o){return Array.isArray(o)?Promise.all(o.map(r)):new Promise(((r,t)=>{if(!("object"==typeof o&&o.url||"string"==typeof o))return console.log({config:o}),void t(new Error("Object with url or url string needed"));const n=Object.assign({},e,"string"==typeof o?{url:o}:o),{url:i,attrs:s,inBody:c,insertInto:l,removeScript:d}=n,u=document.createElement("script"),a=l?document.querySelector(l):c?document.body:document.head;if(s&&"object"==typeof s)for(const e of Object.keys(s))u.setAttribute(e,s[e]);console.log({config:o,configProcessed:n}),null!=a?(u.addEventListener("load",(()=>{d&&a.removeChild(u),r(d?void 0:u)})),u.addEventListener("error",(e=>{console.log(e),d&&a.removeChild(u),t(new Error("Loading script error"))})),u.src=i,a.appendChild(u)):t(new Error("No DOM element to append script"))}))}export{r as default}; |
@@ -1,1 +0,1 @@ | ||
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e="undefined"!=typeof globalThis?globalThis:e||self).simpleLoadScript=o()}(this,(function(){"use strict";const e={url:"",attrs:{},inBody:!1,insertInto:null,removeScript:!1};return function o(t){return Array.isArray(t)?Promise.all(t.map(o)):new Promise(((o,r)=>{if(!("object"==typeof t&&t.url||"string"==typeof t))return console.log({config:t}),void r(new Error("Object with url or url string needed"));const n=Object.assign({},e,"string"==typeof t?{url:t}:t),{url:i,attrs:s,inBody:d,insertInto:c,removeScript:l}=n,u=document.createElement("script"),f=c?document.querySelector(c):d?document.body:document.head;if(s&&"object"==typeof s)for(const e of Object.keys(s))u.setAttribute(e,s[e]);console.log({config:t,configProcessed:n}),null!=f?(u.addEventListener("load",(()=>{l&&f.removeChild(u),o(l?void 0:u)})),u.addEventListener("error",(e=>{console.log(e),l&&f.removeChild(u),r(new Error("Loading script"))})),u.src=i,f.appendChild(u)):r(new Error("No DOM element to append script"))}))}})); | ||
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e="undefined"!=typeof globalThis?globalThis:e||self).simpleLoadScript=o()}(this,(function(){"use strict";const e={url:"",attrs:{},inBody:!1,insertInto:null,removeScript:!1};return function o(t){return Array.isArray(t)?Promise.all(t.map(o)):new Promise(((o,r)=>{if(!("object"==typeof t&&t.url||"string"==typeof t))return console.log({config:t}),void r(new Error("Object with url or url string needed"));const n=Object.assign({},e,"string"==typeof t?{url:t}:t),{url:i,attrs:s,inBody:d,insertInto:c,removeScript:l}=n,u=document.createElement("script"),f=c?document.querySelector(c):d?document.body:document.head;if(s&&"object"==typeof s)for(const e of Object.keys(s))u.setAttribute(e,s[e]);console.log({config:t,configProcessed:n}),null!=f?(u.addEventListener("load",(()=>{l&&f.removeChild(u),o(l?void 0:u)})),u.addEventListener("error",(e=>{console.log(e),l&&f.removeChild(u),r(new Error("Loading script error"))})),u.src=i,f.appendChild(u)):r(new Error("No DOM element to append script"))}))}})); |
{ | ||
"name": "simple-load-script", | ||
"version": "2.0.0-beta.0", | ||
"version": "2.0.0-beta.1", | ||
"description": "Very simple promise based script and JSONP", | ||
@@ -18,5 +18,5 @@ "repository": "tomek-f/simple-load-script", | ||
"vite:build-and-preview": "vite build && vite preview", | ||
"test:run": "vite build && vitest run", | ||
"test:ui": "vite build && vitest --ui", | ||
"test:watch": "vite build && vitest", | ||
"test:run": "vite build && vitest run --reporter=verbose", | ||
"test:ui": "vite build && vitest --reporter=verbose --ui", | ||
"test:watch": "vite build && vitest --reporter=verbose", | ||
"format-check": "prettier --check ./**/*.ts", | ||
@@ -23,0 +23,0 @@ "format-write": "prettier --write ./**/*.ts", |
@@ -5,8 +5,2 @@ # simple-load-script | ||
## Installation | ||
```bash | ||
npm install --save simple-load-script | ||
``` | ||
## Import | ||
@@ -13,0 +7,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9860
0
156