Socket
Socket
Sign inDemoInstall

angularjs-lazyloading

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

dist/angularjs-lazyloading.min.js.map

3

dist/angularjs-lazyloading.min.js

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

"use strict";function LazyLoading($document,$q,$timeout,$log){function _resolve(){return $q(resolve=>{resolve()})}function _reject(err){return $q((resolve,reject)=>{reject(err)})}function _load(element){return $q((resolve,reject)=>{let done=false;element.onerror=(e=>{reject(e)});function onreadystatechange(e){$timeout(()=>{if(!done&&(!this.readyState||"loaded"===this.readyState||"complete"===this.readyState)){done=true;element.onload=null;element.onreadystatechange=null;resolve()}else{reject(e)}})}element.onload=onreadystatechange;element.onreadystatechange=onreadystatechange}).catch(err=>{if(this.logs){$log.error(err)}return $q((resolve,reject)=>{reject(err)})})}const _loadScriptsSynchronously=scripts=>{if(!scripts.length){return _resolve()}else{const script=scripts.shift();return this.script(script).then(()=>{return!scripts.length?_resolve():_loadScriptsSynchronously(scripts)})}};const _loadStylesSynchronously=styles=>{if(!styles.length){return _resolve()}else{const style=styles.shift();return this.style(style).then(()=>{return!styles.length?_resolve():_loadStylesSynchronously(styles)})}};this.scripts=[];this.styles=[];this.logs=false;this.script=(url=>{if("undefined"===typeof url){return _reject(new ReferenceError('Missing "url" parameter'))}else if("string"!==typeof url){return _reject(new ReferenceError('"url" parameter is not a string'))}else if(""===url.trim()){return _reject(new Error('"url" parameter is empty'))}else if(this.scripts.includes(url)){if(this.logs){$log.warn(url,"script already loaded")}return _resolve()}else{return $q((resolve,reject)=>{const script=$document[0].createElement("script");script.src=url;script.crossorigin="anonymous";script.type="text/javascript";script.async=true;$document[0].body.appendChild(script);_load(script).then(resolve).catch(reject)}).then(()=>{this.scripts.push(url);if(this.logs){$log.info(url,"script loaded")}return _resolve()})}});this.style=(url=>{if("undefined"===typeof url){return _reject(new ReferenceError('Missing "url" parameter'))}else if("string"!==typeof url){return _reject(new ReferenceError('"url" parameter is not a string'))}else if(""===url.trim()){return _reject(new Error('"url" parameter is empty'))}else if(this.styles.includes(url)){if(this.logs){$log.warn(url,"style already loaded")}return _resolve()}else{return $q((resolve,reject)=>{const style=$document[0].createElement("link");style.href=url;style.rel="stylesheet";style.async=true;$document[0].head.appendChild(style);_load(style).then(resolve).catch(reject)}).then(()=>{this.styles.push(url);if(this.logs){$log.info(url,"style loaded")}return _resolve()})}});this.group=(group=>{if("undefined"===typeof group){return _reject(new ReferenceError('Missing "group" parameter'))}else if("object"!==typeof group){return _reject(new ReferenceError('"group" parameter is not an object'))}else if("undefined"===typeof group.name){return _reject(new ReferenceError('Missing "group.name" parameter'))}else if("string"!==typeof group.name){return _reject(new ReferenceError('"group.name" parameter is not a string'))}else if(""===group.name.trim()){return _reject(new Error('"group.name" parameter is empty'))}else{if(this.logs){$log.info(group.name,"group loading...")}return _loadStylesSynchronously("object"===typeof group.styles&&group.styles instanceof Array?group.styles:[]).then(()=>{return _loadScriptsSynchronously("object"===typeof group.scripts&&group.scripts instanceof Array?group.scripts:[])}).then(()=>{if(this.logs){$log.info(group.name,"group loaded")}return _resolve()})}})}angular.module("ngLazyLoading",[]).service("$lazyLoading",["$document","$q","$timeout","$log",LazyLoading]);
"use strict";function LazyLoading($document,$q,$timeout,$log){function _resolve(){return $q(resolve=>{resolve()})}function _reject(err){return $q((resolve,reject)=>{reject(err)})}function _load(element){return $q((resolve,reject)=>{let done=false;element.onerror=(e=>{reject(e)});function onreadystatechange(e){$timeout(()=>{if(!done&&(!this.readyState||"loaded"===this.readyState||"complete"===this.readyState)){done=true;element.onload=null;element.onreadystatechange=null;resolve()}else{reject(e)}})}element.onload=onreadystatechange;element.onreadystatechange=onreadystatechange}).catch(err=>{if(this.logs){$log.error(err)}return $q((resolve,reject)=>{reject(err)})})}const _loadScriptsSynchronously=scripts=>{if(!scripts.length){return _resolve()}else{const script=scripts.shift();return this.script(script).then(()=>{return!scripts.length?_resolve():_loadScriptsSynchronously(scripts)})}};const _loadStylesSynchronously=styles=>{if(!styles.length){return _resolve()}else{const style=styles.shift();return this.style(style).then(()=>{return!styles.length?_resolve():_loadStylesSynchronously(styles)})}};this.scripts=[];this.styles=[];this.logs=false;this.script=(url=>{if("undefined"===typeof url){return _reject(new ReferenceError('Missing "url" parameter'))}else if("string"!==typeof url){return _reject(new ReferenceError('"url" parameter is not a string'))}else if(""===url.trim()){return _reject(new Error('"url" parameter is empty'))}else if(this.scripts.includes(url)){if(this.logs){$log.warn(url,"script already loaded")}return _resolve()}else{return $q((resolve,reject)=>{const script=$document[0].createElement("script");script.src=url;script.crossorigin="anonymous";script.type="text/javascript";script.async=true;$document[0].body.appendChild(script);_load(script).then(resolve).catch(reject)}).then(()=>{this.scripts.push(url);if(this.logs){$log.info(url,"script loaded")}return _resolve()})}});this.style=(url=>{if("undefined"===typeof url){return _reject(new ReferenceError('Missing "url" parameter'))}else if("string"!==typeof url){return _reject(new ReferenceError('"url" parameter is not a string'))}else if(""===url.trim()){return _reject(new Error('"url" parameter is empty'))}else if(this.styles.includes(url)){if(this.logs){$log.warn(url,"style already loaded")}return _resolve()}else{return $q((resolve,reject)=>{const style=$document[0].createElement("link");style.href=url;style.rel="stylesheet";style.async=true;$document[0].head.appendChild(style);_load(style).then(resolve).catch(reject)}).then(()=>{this.styles.push(url);if(this.logs){$log.info(url,"style loaded")}return _resolve()})}});this.group=(group=>{if("undefined"===typeof group){return _reject(new ReferenceError('Missing "group" parameter'))}else if("object"!==typeof group){return _reject(new ReferenceError('"group" parameter is not an object'))}else if("undefined"===typeof group.name){return _reject(new ReferenceError('Missing "group.name" parameter'))}else if("string"!==typeof group.name){return _reject(new ReferenceError('"group.name" parameter is not a string'))}else if(""===group.name.trim()){return _reject(new Error('"group.name" parameter is empty'))}else{if(this.logs){$log.info(group.name,"group loading...")}return _loadStylesSynchronously("object"===typeof group.styles&&group.styles instanceof Array?group.styles:[]).then(()=>{return _loadScriptsSynchronously("object"===typeof group.scripts&&group.scripts instanceof Array?group.scripts:[])}).then(()=>{if(this.logs){$log.info(group.name,"group loaded")}return _resolve()})}})}angular.module("ngLazyLoading",[]).service("$lazyLoading",["$document","$q","$timeout","$log",LazyLoading]);
//# sourceMappingURL=angularjs-lazyloading.min.js.map
{
"name": "angularjs-lazyloading",
"version": "1.2.0",
"version": "1.3.0",
"description": "A simple way to lazyload scripts & css with AngularJS",
"scripts": {
"compress": "terser ./lib/angularjs-lazyloading.js --output ./dist/angularjs-lazyloading.min.js",
"compress": "terser ./lib/angularjs-lazyloading.js --output ./dist/angularjs-lazyloading.min.js --source-map \"url='angularjs-lazyloading.min.js.map'\"",
"lint": "npx eslint ./lib/angularjs-lazyloading.js",

@@ -8,0 +8,0 @@ "check-updates": "npx check-version-modules",

@@ -17,3 +17,3 @@ # angularjs-lazyloading

app.directive("MyController", [ "$lazyLoading", "$q", ($lazyLoading, $q) => {
app.directive("MyController", [ "$lazyLoading", ($lazyLoading) => {

@@ -49,3 +49,3 @@ // private

app.directive("MyController", [ "$lazyLoading", "$q", ($lazyLoading, $q) => {
app.directive("MyController", [ "$lazyLoading", ($lazyLoading) => {

@@ -52,0 +52,0 @@ // private

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc