part-2---npm 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.index.js ADDED
@@ -0,0 +1 @@
1
+ console.info("Hello world");
package/2.write.js ADDED
@@ -0,0 +1,5 @@
1
+ import fs from "fs";
2
+
3
+ export const writeToFile = (file, content) => {
4
+ fs.writeFileSync(file, content);
5
+ };
package/3.index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { writeToFile } from "./2.write.js";
2
+
3
+ writeToFile("hello.log", "Hello world");
package/4.export.js ADDED
@@ -0,0 +1,3 @@
1
+ import { writeToFile } from "./2.write.js";
2
+
3
+ writeToFile("hello.log", "Hai Everyone :)");
@@ -0,0 +1,6 @@
1
+ import _ from "lodash";
2
+
3
+ const source = "hai everyone :)";
4
+ const target = _.capitalize(source);
5
+
6
+ console.info(target);
@@ -0,0 +1,3 @@
1
+ import moment from "moment";
2
+
3
+ console.info(moment().format());
package/7.hello.js ADDED
@@ -0,0 +1,6 @@
1
+ import { sayHello, sum } from "npm-library-elhamabdussalam";
2
+
3
+ console.info(sayHello("world"));
4
+
5
+ const numbers = [10, 10, 20, 60];
6
+ console.info(sum(numbers));
package/8.number.js ADDED
@@ -0,0 +1,17 @@
1
+ import { first } from "lodash";
2
+
3
+ export const min = (first, second) => {
4
+ if (first < second) {
5
+ return first;
6
+ } else {
7
+ return second;
8
+ }
9
+ };
10
+
11
+ export const max = (first, second) => {
12
+ if (first > second) {
13
+ return first;
14
+ } else {
15
+ return second;
16
+ }
17
+ };
@@ -0,0 +1,11 @@
1
+ export const sayHello = (name) => {
2
+ return `Hello ${name}`;
3
+ };
4
+
5
+ export const sum = (numbers) => {
6
+ let total = 0;
7
+ for (const value of numbers) {
8
+ total += value;
9
+ }
10
+ return total;
11
+ };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "npm-library-elhamabdussalam",
3
+ "version": "1.0.0",
4
+ "description": "Belajar NodeJS NPM Library",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "author": "M Elham Abdussalam",
11
+ "license": "ISC"
12
+ }
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "part-2---npm",
3
+ "version": "1.0.0",
4
+ "main": "1.index.js",
5
+ "scripts": {
6
+ "run": "node 1.index.js",
7
+ "prestart": "echo 'Before Application Start'",
8
+ "start": "node 1.index.js",
9
+ "poststart": "echo 'After Application Start'",
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "exports": {
13
+ ".": "./1.index.js",
14
+ "./number": "./8.number.js"
15
+ },
16
+ "author": "",
17
+ "license": "ISC",
18
+ "description": "",
19
+ "type": "module",
20
+ "dependencies": {
21
+ "lodash": "^4.17.23",
22
+ "npm-library-elhamabdussalam": "^1.0.0"
23
+ },
24
+ "devDependencies": {
25
+ "moment": "^2.30.1"
26
+ }
27
+ }