Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
'use strict';

// モジュールとして取得
const axios = require('axios');

// HTTPレスポンスを受け取った際に無名関数を渡す
axios.get('http://www.google.com').then(res => {
console.log(res.data);
});
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"axios": "^0.22.0"
}
}
3 changes: 3 additions & 0 deletions sum-app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';
const s = require('sum');
console.log(s.add([1, 2, 3, 4]));
9 changes: 9 additions & 0 deletions sum-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "sum-app",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"sum": "../sum"
}
}
6 changes: 6 additions & 0 deletions sum-app/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


sum@../sum:
version "1.0.0"
17 changes: 17 additions & 0 deletions sum/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

/**
* 数値の配列を受け取って、その要素の合計を返す関数
* @param {Number} numbers 数値の配列
* @returns 要素の合計
*/
function add(numbers) {
let result = 0;
for (const num of numbers){
result = result + num;
}
return result;
}

// 使えるようにしたい関数やオブジェクトを代入する
module.exports = { add };
6 changes: 6 additions & 0 deletions sum/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "sum",
"version": "1.0.0",
"main": "index.js",
"license": "MIT"
}
15 changes: 15 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


axios@^0.22.0:
version "0.22.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.22.0.tgz#bf702c41fb50fbca4539589d839a077117b79b25"
integrity sha512-Z0U3uhqQeg1oNcihswf4ZD57O3NrR1+ZXhxaROaWpDmsDTx7T2HNBV2ulBtie2hwJptu8UvgnJoK+BIqdzh/1w==
dependencies:
follow-redirects "^1.14.4"

follow-redirects@^1.14.4:
version "1.14.4"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379"
integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==