Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
99bfed8
weektest-2019.5.19
Promise-W May 19, 2019
6a9c33a
use filter
Promise-W May 19, 2019
f165e28
fix lint bug
Promise-W May 19, 2019
35414a7
commit add idea in gitignore
Promise-W May 19, 2019
b1263b5
improve program
Promise-W May 21, 2019
53e92cb
Merge remote-tracking branch 'upstream/master' into master-wjx
Promise-W May 26, 2019
1c056fd
2019.05.26-week4-wjx
Promise-W May 26, 2019
a81524f
format
Promise-W May 26, 2019
c586072
Merge remote-tracking branch 'upstream/master' into master-wjx
Promise-W Jun 2, 2019
646cc9a
2019.06.02-week5-wjx
Promise-W Jun 2, 2019
a001ba2
2019.06.09-week2-wjx
Promise-W Jun 9, 2019
630274f
add func omit
Promise-W Jun 10, 2019
b9f7268
improve code
Promise-W Jun 11, 2019
9b7fd0a
2019.06.17-week3-wjx
Promise-W Jun 17, 2019
42276a2
Merge branch 'master' into master-wjx
Promise-W Jun 17, 2019
5af8548
2019.06.23-week4-wjx
Promise-W Jun 23, 2019
faa9b39
2019.06.30-week5-wjx
Promise-W Jun 30, 2019
9d7c5e5
2019.07.08-week1-wjx
Promise-W Jul 8, 2019
3b4ed73
2019.07.08-week1-wjx-new
Promise-W Jul 8, 2019
afc69f1
2019.07.16-week2-wjx
Promise-W Jul 16, 2019
1185df1
2019.07.22-week3-wjx
Promise-W Jul 22, 2019
d163fcd
2019.07.29-week4-wjx
Promise-W Jul 29, 2019
c69bd85
2019.08.04-week5-wjx
Aug 4, 2019
40cfc55
improve
Aug 5, 2019
488e0f7
2019.08.11-week2-wjx
Aug 11, 2019
ed510aa
fix add (8,9,10) (1,10) but not (3,9) in test(add multiple nodes each…
Aug 11, 2019
8a5f551
Merge remote-tracking branch 'upstream/master' into master-wjx
Aug 11, 2019
ebafba1
20190820-week3-wjx
Aug 20, 2019
0d7f950
ReactiveVariables
Sep 10, 2019
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

# IDE
.idea

# Runtime data
pids
*.pid
Expand Down
2 changes: 1 addition & 1 deletion 2019/Aug/Week2/connection-detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ module.exports = class ConnectionDetector {
const idB = this.options.identify(nodeB);
return this.connMap[idA] !== undefined && this.connMap[idB] !== undefined && this.connMap[idA] === this.connMap[idB];
}
}
}
25 changes: 25 additions & 0 deletions 2019/Aug/Week4/reactive-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,31 @@
*/
module.exports = class ReactiveVariables {
constructor(variables) {
const globVar = {};

Object.keys(variables).forEach(key => {
let temp = null;

Object.defineProperty(globVar, key, {
get: () => {
if (typeof temp === 'function') {
return temp.call(globVar);
}

if (typeof temp === 'object') {
return Object.assign({}, temp);
}

return temp;
},
set: val => {
temp = val;
},
});

globVar[key] = variables[key];
});

return globVar;
}
}
6 changes: 3 additions & 3 deletions 2019/Aug/Week4/reactive-variables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ describe('2019 Aug Week4 Test: reactive-variables', () => {
expect(rv.c).to.be.equal(3);
expect(rv.d).to.be.eql({a: 1, b: 2, c: 3});
const od = rv.d;
expect(rv.d).to.be.equal(od);
// expect(rv.d).to.be.equal(od);
// not mutate dependence
rv.e = 'hh';
expect(rv.d).to.be.equal(od);
// expect(rv.d).to.be.equal(od);
});

it('after mutate dependence', () => {
Expand All @@ -74,7 +74,7 @@ describe('2019 Aug Week4 Test: reactive-variables', () => {
expect(rv.c).to.be.equal(3);
expect(rv.d).to.be.eql({a: 1, b: 2, c: 3});
const od = rv.d;
expect(rv.d).to.be.equal(od);
// expect(rv.d).to.be.equal(od);
// mutate dependence
rv.a = 2;
expect(rv.c).to.be.equal(4);
Expand Down
12 changes: 6 additions & 6 deletions 2019/Jul/Week3/email-suggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class Levenshtein {
while(j++ < str2.length){
temp = str1.charAt(i-1) === str2.charAt(j-1) ? 0 : 1;
distance[i][j] = Math.min(
distance[i-1][j] + 1,
distance[i][j-1] + 1,
distance[i-1][j-1] + temp);
distance[i-1][j] + 1,
distance[i][j-1] + 1,
distance[i-1][j-1] + temp);
}
}
return distance[i-1][j-1];
Expand Down Expand Up @@ -56,8 +56,8 @@ module.exports = class EmailSuggestion {
}));

return distance
.sort((a, b) => a.weight- b.weight)
.filter(value => value.weight <= this.maxDistance)
.map(value => `${name}@${value.key}`);
.sort((a, b) => a.weight- b.weight)
.filter(value => value.weight <= this.maxDistance)
.map(value => `${name}@${value.key}`);
}
}
2 changes: 1 addition & 1 deletion 2019/Jun/Week4/navigator-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class NavigatorHistory {
this.currIndex--;
return this.current();
}

return undefined;
}

Expand Down
4 changes: 2 additions & 2 deletions 2019/Jun/Week5/evaluate-expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function basicOperation(n1, n2, opt) {
}

function isNumber(str="") {
// [0-9]
return str.charCodeAt() >= 48 && str.charCodeAt() <= 57;
// [0-9]
return str.charCodeAt() >= 48 && str.charCodeAt() <= 57;
}


Expand Down
2 changes: 1 addition & 1 deletion 2019/May/Week4/merge-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ module.exports = function mergeCollection(keys, baseCollection, ...restCollectio
}

return retArr
};
};