adarsh-jadav-app 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/1.js +17 -0
- package/10.js +3 -0
- package/2.js +6 -0
- package/README.md +17 -0
- package/ad.js +14 -0
- package/ada.js +15 -0
- package/index.js +14 -0
- package/package.json +13 -0
package/1.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function fetchData(callback) {
|
|
2
|
+
setTimeout(() => {
|
|
3
|
+
callback('Data received');
|
|
4
|
+
}, 1000);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const fetchDataPromise = () => {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
setTimeout(() => resolve('Promise resolved'), 1000);
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
async function getData() {
|
|
14
|
+
const result = await fetchDataPromise();
|
|
15
|
+
console.log(result);
|
|
16
|
+
}
|
|
17
|
+
getData();
|
package/10.js
ADDED
package/2.js
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## What is this?
|
|
2
|
+
A random number generator
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
Run `npm i apps`
|
|
6
|
+
|
|
7
|
+
Use:
|
|
8
|
+
```
|
|
9
|
+
import rng from 'apps';
|
|
10
|
+
|
|
11
|
+
rng(5, 10);
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Parameters
|
|
15
|
+
The Random Number Generator accepts two parameters, min and max values.
|
|
16
|
+
|
|
17
|
+
By default, `min` is set to 0, and `max` is set to 100.
|
package/ad.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Variables (let, const, var)
|
|
2
|
+
let name = 'Node.js';
|
|
3
|
+
const version = 20;
|
|
4
|
+
|
|
5
|
+
// Function declaration
|
|
6
|
+
function greet(user) {
|
|
7
|
+
return `Hello, ${user}!`; // Template literal (ES6)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Arrow function (ES6+)
|
|
11
|
+
const add = (a, b) => a + b;
|
|
12
|
+
|
|
13
|
+
console.log(greet('Developer')); // Hello, Developer!
|
|
14
|
+
console.log(add(5, 3)); // 8
|
package/ada.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Object
|
|
2
|
+
const user = {
|
|
3
|
+
name: 'Alice',
|
|
4
|
+
age: 25,
|
|
5
|
+
greet() {
|
|
6
|
+
console.log(`Hi, I'm ${this.name}`);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// Array
|
|
11
|
+
const colors = ['red', 'green', 'blue'];
|
|
12
|
+
|
|
13
|
+
// Array methods (ES6+)
|
|
14
|
+
colors.forEach(color => console.log(color));
|
|
15
|
+
const lengths = colors.map(color => color.length);
|
package/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const http = require('node:http');
|
|
2
|
+
|
|
3
|
+
const hostname = '127.0.0.1';
|
|
4
|
+
const port = 3000;
|
|
5
|
+
|
|
6
|
+
const server = http.createServer((req, res) => {
|
|
7
|
+
res.statusCode = 200;
|
|
8
|
+
res.setHeader('Content-Type', 'text/plain');
|
|
9
|
+
res.end('Hello, World!\n');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
server.listen(port, hostname, () => {
|
|
13
|
+
console.log(`Server running at http://${hostname}:${port}/`);
|
|
14
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "adarsh-jadav-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Random Number Generator",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "JSM",
|
|
12
|
+
"type": "module"
|
|
13
|
+
}
|