-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from paul-hanneforth/dev
v3.0.7
- Loading branch information
Showing
46 changed files
with
2,318 additions
and
4,874 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ | |
}, | ||
"env": { | ||
"es6": true | ||
} | ||
}, | ||
"parser": "babel-eslint" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ node_modules | |
cookies.json | ||
gen-docs.cmd | ||
test.js | ||
dev.js | ||
dev.js | ||
session.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
const { SearchResult, User, UserDetails, Post, PostDetails } = require("./class.js"); | ||
|
||
class FollowingList { | ||
|
||
/** | ||
* @constructor | ||
* @param {User} user | ||
* @param {User[]} following | ||
* @property {User} user | ||
* @property {User[]} following | ||
*/ | ||
constructor(user, following) { | ||
this.user = user; | ||
this.following = following; | ||
} | ||
|
||
} | ||
class FollowerList { | ||
|
||
/** | ||
* @constructor | ||
* @param {User} user | ||
* @param {User[]} follower | ||
* @property {User} user | ||
* @property {User[]} follower | ||
*/ | ||
constructor(user, follower) { | ||
this.user = user; | ||
this.follower = follower; | ||
} | ||
|
||
} | ||
|
||
class Cache { | ||
|
||
/** | ||
* @constructor | ||
* @param {FollowingList[]} followingLists | ||
* @param {FollowerList[]} followerLists | ||
* @property {FollowingList[]} [ followingLists = [] ] | ||
* @property {FollowerList[]} [ followerLists = [] ] | ||
*/ | ||
constructor(followingLists, followerLists) { | ||
this.followingLists = followingLists ? followingLists : []; | ||
this.followerLists = followerLists ? followerLists : []; | ||
} | ||
|
||
/** | ||
* | ||
* @returns {Cache} empty cache | ||
*/ | ||
static empty() { | ||
return new Cache([], []); | ||
} | ||
|
||
/** | ||
* | ||
* @param {User} user | ||
* @param {User[]} following | ||
* @returns {Cache} | ||
*/ | ||
addFollowingList(user, following) { | ||
const newFollowingLists = this.followingLists.concat(new FollowingList(user, following)); | ||
const newCache = new Cache(newFollowingLists, this.followerLists); | ||
return newCache; | ||
} | ||
|
||
/** | ||
* | ||
* @param {User} user | ||
* @param {User[]} followers | ||
* @returns {Cache} | ||
*/ | ||
addFollowerList(user, followers) { | ||
const newFollowerLists = this.followerLists.concat(new FollowerList(user, followers)); | ||
return new Cache(this.followingLists, newFollowerLists); | ||
} | ||
|
||
/** | ||
* | ||
* @param {User} user | ||
* @returns {User[]} list of people who the specified user follows | ||
*/ | ||
findFollowingList(user) { | ||
const selectedFollowingList = this.followingLists.find(followingList => followingList.user.username === user.username); | ||
return selectedFollowingList ? selectedFollowingList.following : []; | ||
} | ||
|
||
/** | ||
* | ||
* @param {User} user | ||
* @returns {User[]} list of people who the specified user follows | ||
*/ | ||
findFollowerList(user) { | ||
const selectedFollowerList = this.followerLists.find(followerList => followerList.user.username === user.username); | ||
return selectedFollowerList ? selectedFollowerList.follower : []; | ||
} | ||
|
||
} | ||
|
||
module.exports = { Cache }; |
Oops, something went wrong.