@slashmark/sm-random 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/README.md +0 -0
- package/bin/index.js +23 -0
- package/package.json +10 -0
package/README.md
ADDED
|
File without changes
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const args = process.argv.slice(2);
|
|
4
|
+
const type = args[0];
|
|
5
|
+
|
|
6
|
+
if (!type) {
|
|
7
|
+
console.log("Usage:");
|
|
8
|
+
console.log(" sm-random number");
|
|
9
|
+
console.log(" sm-random email");
|
|
10
|
+
console.log(" sm-random name");
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (type === "number") {
|
|
15
|
+
console.log(Math.floor(Math.random() * 10000));
|
|
16
|
+
} else if (type === "email") {
|
|
17
|
+
console.log(`user${Math.floor(Math.random() * 10000)}@mail.com`);
|
|
18
|
+
} else if (type === "name") {
|
|
19
|
+
const names = ["Arjun", "Rahul", "Priya", "Sneha", "Kiran"];
|
|
20
|
+
console.log(names[Math.floor(Math.random() * names.length)]);
|
|
21
|
+
} else {
|
|
22
|
+
console.log("❌ Invalid type");
|
|
23
|
+
}
|