New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

skunkplatform-ads

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

skunkplatform-ads - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

TUTORIAL.txt

132

main.js

@@ -1,5 +0,8 @@

// Importing axios using require syntax
const axios = require('axios');
const semver = require("semver");
console.log(`SkunkAds
if (semver.gt(process.version, 'v18.0.0')) {
console.log(`Your Node.js v18 or greater is available.`);
console.log(`SkunkAds v1.0.3 (Node.js ${process.version})
- API:

@@ -9,2 +12,4 @@ SkunkAds for API has been Added by using ads.create().

CommonJS · Node.js
- Package Version:
1.0.3
- Example Usage:

@@ -19,26 +24,69 @@ // Use this Example

`);
class Client {
constructor() {
// No need for anything in the constructor unless you need to initialize properties
}
class Client {
constructor() {
// No need for anything in the constructor unless you need to initialize properties
async initialize() {
await this.loadAdsScript();
}
async init() {
await this.loadAdsScript();
}
async loadAdsScript() {
if (!this.isBrowserEnvironment()) return;
try {
const scriptData = await fetchAdScript();
appendScriptToDocument(scriptData);
} catch (error) {
handleError(error);
}
}
isBrowserEnvironment() {
if (typeof document === 'undefined') {
console.warn("`document` is Undefined. You are using an environment that doesn't support the DOM (e.g., Visual Studio Code) from Terminal. Read our documentation: https://skunkplatform.netlify.app/ads/docs");
return false;
}
return true;
}
}
async initialize() {
await this.loadAdsScript();
// Help function to provide a simple guide
async function help() {
console.log(`Help & Documentation:
1. Initialize ads with Client:
const adClient = new Client();
adClient.initialize();
2. Quick setup with adsInit:
adsInit();
3. Ensure the JavaScript is compatible with CDN, ES Module, and CommonJS.
4. Ensure the Package Version is compatible with 1.0.1 to 1.0.3 for CommonJS, ES Module: 1.0.2-ES
5. For more information, visit:
https://skunkplatform.netlify.app/ads/docs
`);
}
async loadAdsScript() {
if (!this.isBrowserEnvironment()) return;
// Initialize ads with a quick setup
async function adsInit() {
if (!isBrowserEnvironment()) return;
try {
const scriptData = await this.fetchAdScript();
this.appendScriptToDocument(scriptData);
const scriptData = await fetchAdScript();
appendScriptToDocument(scriptData);
} catch (error) {
this.handleError(error);
handleError(error);
}
}
isBrowserEnvironment() {
function isBrowserEnvironment() {
if (typeof document === 'undefined') {
console.log("`document` is Undefined. You are using an environment that doesn't support the DOM (e.g., Visual Studio Code). Read our documentation: https://skunkplatform.netlify.app/ads/docs");
console.warn("`document` is Undefined. You are using an environment that doesn't support the DOM.");
return false;

@@ -49,3 +97,3 @@ }

async fetchAdScript() {
async function fetchAdScript() {
const response = await axios.get("https://skunkplatform.netlify.app/api/ads.js");

@@ -55,3 +103,3 @@ return response.data;

appendScriptToDocument(data) {
function appendScriptToDocument(data) {
try {

@@ -63,56 +111,16 @@ const script = document.createElement("script");

} catch (error) {
this.handleError(error);
handleError(error);
}
}
handleError(error) {
function handleError(error) {
const today = new Date().toLocaleString();
console.error(`[${today}] Error:`, error);
}
}
async function adsInit() {
if (!isBrowserEnvironment()) return;
// Export the modules
module.exports = { Client, adsInit, help };
try {
const scriptData = await fetchAdScript();
appendScriptToDocument(scriptData);
} catch (error) {
handleError(error);
}
} else {
console.log(`Sorry, Your Node.js Version is too low. Please use v18 or higher to execute SkunkAds.`);
}
function isBrowserEnvironment() {
if (typeof document === 'undefined') {
console.log("`document` is Undefined. You are using an environment that doesn't support the DOM.");
return false;
}
return true;
}
async function fetchAdScript() {
const response = await axios.get("https://skunkplatform.netlify.app/api/ads.js");
return response.data;
}
function appendScriptToDocument(data) {
try {
const script = document.createElement("script");
script.type = "text/javascript";
script.innerHTML = data;
document.body.appendChild(script);
} catch (error) {
handleError(error);
}
}
function handleError(error) {
const today = new Date().toLocaleString();
console.error(`[${today}] Error:`, error);
}
// Export using CommonJS syntax
module.exports = {
Client,
adsInit
};
{
"name": "skunkplatform-ads",
"version": "1.0.2",
"version": "1.0.3",
"main": "main.js",

@@ -14,4 +14,5 @@ "scripts": {

"dependencies": {
"axios": "^1.7.8"
"axios": "^1.7.8",
"semver": "^7.6.3"
}
}

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

// preview.js
// Importing Client and adsInit from main.cjs
const { Client, adsInit } = require('./main'); // Adjust the path to where your script is located

@@ -26,2 +26,2 @@

previewAds();
previewAdsInit();
previewAdsInit();

@@ -11,10 +11,15 @@ # SkunkAds

```bash
npm i skunkplatform-ads@es-1.0.0 # For ES Module
npm i skunkplatform-ads@es-1.0.1 # For ES Module
```
#### Using in Node.js:
#### Using CommomJS:
```bash
npm i skunkplatform-ads@1.0.1 # For Node.js (Fixed for the Main File Package)
npm i skunkplatform-ads@1.0.3 # For CommomJS (Compatible with Node.js v18)
```
### To get more tips, follow the example:
```js
```
### For Client-Side CDN

@@ -27,2 +32,2 @@

</body>
```
```
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc