Socket
Socket
Sign inDemoInstall

async-assets

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1-alpha.1 to 0.0.1-alpha.1.1

.idea/codeStyles/codeStyleConfig.xml

4

package.json
{
"name": "async-assets",
"version": "0.0.1-alpha.1",
"version": "0.0.1-alpha.1.1",
"description": "Async loading of css and javascript files",
"main": "index.js",
"main": "./src/index.js",
"scripts": {

@@ -7,0 +7,0 @@ "test": "echo \"Error: no test specified\" && exit 1"

![](https://azabroflovski.uz/logo-sm.png)
![Build](https://img.shields.io/badge/build-passing-brightgreen) ![Version](https://img.shields.io/badge/version-0.0.1-blue) ![License](https://img.shields.io/npm/l/async-assets?color=brightgreen) ![GitHub last commit](https://img.shields.io/github/last-commit/azabroflovski/async-assets)
![Build](https://img.shields.io/badge/build-passing-brightgreen) ![Version](https://img.shields.io/badge/version-0.0.1.alpha-blue) ![License](https://img.shields.io/npm/l/async-assets?color=brightgreen) ![GitHub last commit](https://img.shields.io/github/last-commit/azabroflovski/async-assets)

@@ -57,4 +57,14 @@ A simple, lightweight JavaScript API for asynchronous including assets.

```html
<script src="https://unpkg.com/async-assets/bundle.js"></script>
<script src="https://unpkg.com/async-assets/bundle.js"></script>
<!-- or -->
<script src="https://unpkg.com/async-assets/bundle.min.js"></script>
<script>
try {
const assets = await AsyncAssets('...')
// do something
} catch (err) {
console.log('Something wrong', err)
}
</script>
```

@@ -61,0 +71,0 @@

@@ -1,1 +0,61 @@

console.log('hello world');
class Asset {
/**
* Asset Class
* @param props {Object}
*/
constructor(props) {
const { type, url } = props
this.allowedTypes = [
'stylesheet',
'style',
'css',
'javascript',
'script',
'js',
]
this.asset = { type, url }
this.validate()
}
/**
* Get asset full url
* @return {string}
*/
get url() {
return this.asset.url
}
/**
* Set asset url
* @param value {string}
*/
set url(value) {
this.asset.url = value
}
/**
* Check for valid asset type
* @return {boolean}
*/
get isValid() {
return this.allowedTypes.includes(this.asset.type)
}
/**
* Validate is allowed type
* @return void
*/
validate() {
if (!this.isValid) {
throw 'Invalid asset type. List of allowed types: ' + this.allowedTypes.join(',')
}
}
}
module.exports = Asset
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