Skip to content

Commit 0f4b880

Browse files
committed
Improve code style
1 parent 2b26515 commit 0f4b880

2 files changed

Lines changed: 20 additions & 25 deletions

File tree

JavaScript/6-rest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ f1(1, 2, 3);
88

99
const f2 = (...args) => {
1010
args.forEach(arg => {
11-
console.log('Type: ' + typeof(arg));
12-
if (typeof(arg) === 'object') {
11+
console.log('Type: ' + typeof arg);
12+
if (typeof arg === 'object') {
1313
console.log('Value: ' + JSON.stringify(arg));
1414
} else {
1515
console.log('Value: ' + arg);

JavaScript/d-decompose.js

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ const merge = (
66
// Returns: array
77
) => {
88
const array = args[0];
9-
let i, ilen, j, jlen, arr, val;
10-
for (i = 1, ilen = args.length; i < ilen; i++) {
11-
arr = args[i];
12-
for (j = 0, jlen = arr.length; j < jlen; j++) {
13-
val = arr[j];
9+
for (let i = 1; i < args.length; i++) {
10+
const arr = args[i];
11+
for (let j = 0; j < arr.length; j++) {
12+
const val = arr[j];
1413
if (!array.includes(val)) array.push(val);
1514
}
1615
}
@@ -108,18 +107,16 @@ const introspect = (
108107
// Returns: hash of hash of record, { method, title, parameters }
109108
) => {
110109
const inventory = {};
111-
let name, iface, methods, method, fn, signature;
112-
for (name in namespace) {
113-
iface = namespace[name];
114-
methods = {};
110+
for (const name in namespace) {
111+
const iface = namespace[name];
112+
const methods = {};
115113
inventory[name] = methods;
116-
for (method in iface) {
117-
fn = iface[method];
118-
signature = parseSignature(fn);
119-
signature = Object.assign({
114+
for (const method in iface) {
115+
const fn = iface[method];
116+
const signature = parseSignature(fn);
117+
methods[method] = Object.assign({
120118
method: name + '.' + method
121119
}, signature);
122-
methods[method] = signature;
123120
}
124121
}
125122
return inventory;
@@ -131,14 +128,13 @@ const badIntrospect = (
131128
// Returns: hash of hash of record, { method, title, parameters }
132129
) => {
133130
const inventory = {};
134-
let name, iface, methods, method, fn, signature;
135-
for (name in namespace) {
136-
iface = namespace[name];
137-
methods = {};
131+
for (const name in namespace) {
132+
const iface = namespace[name];
133+
const methods = {};
138134
inventory[name] = methods;
139-
for (method in iface) {
140-
fn = iface[method];
141-
signature = {
135+
for (const method in iface) {
136+
const fn = iface[method];
137+
const signature = {
142138
title: '', description: '',
143139
parameters: [], comments: []
144140
};
@@ -182,10 +178,9 @@ const badIntrospect = (
182178
}
183179
}
184180
}
185-
signature = Object.assign({
181+
methods[method] = Object.assign({
186182
method: name + '.' + method
187183
}, signature);
188-
methods[method] = signature;
189184
}
190185
}
191186
return inventory;

0 commit comments

Comments
 (0)