-
-
Notifications
You must be signed in to change notification settings - Fork 5
if‐follow‐package Usages
Farhan Reza edited this page Feb 11, 2024
·
1 revision
Welcome to the if-follow-package wiki👋
//const ifFollow = require('@farhan7reza7/if-follow-package'); //or
const ifFollow = require('if-follow-package'); // can use any
const yourUsername = 'username'; // replace with your username
const yourToken = 'access-token' // replace with your access token
const followController = ifFollow(yourUsername, yourToken);
const notFollowingBackList = followController.whoNotFollowingBack();
const followingBackList = followController.whoFollowingBack();
const isFollowingBackMessage = followController.isFollowingBack('username');
followController.unfollowNotFollowingBack('username');
followController.unfollowAllNotFollowingBack();
const isFollowerMessage = followController.isFollower('username');
const isFollowingMessage = followController.isFollowing('username');
const totalFollowersMessage = followController.totalFollowers();
const totalFollowingsMessage = followController.totalFollowings();
// Test case: user is a follower
const result1 = followController.isFollower('farhan7reza7');
result1.then((result) => {
console.log(result); // Output: "Yes, farhan7reza7 follows you!"
});
// Test case: user is not a follower
const result2 = followController.isFollower('diff-ymd-package');
result2.then((result) => {
console.log(result); // Output: "No, diff-ymd-package does not follow you!"
});
// Test case: user is followed
const result3 = followController.isFollowing('farhan7reza7');
result3.then((result) => {
console.log(result); // Output: "Yes, you follow farhan7reza7!"
});
// Test case: user is not followed
const result4 = followController.isFollowing('anaseem80');
result4.then((result) => {
console.log(result); // Output: "No, you do not follow anaseem80!"
});
const result5 = followController.totalFollowers();
result5.then((result) => {
console.log(result); // Output: "Your total Followers: 1657"
});
const result6 = followController.totalFollowings();
result6.then((result) => {
console.log(result); // Output: "Your total Followings: 1067`
});
const result7 = followController.whoNotFollowingBack();
result7.then((result) => {
console.log(result); // Output: ["diff-ymd-package", "Open-Sourced-Org", "username4", "usernameN"]
});
const result8 = followController.whoFollowingBack();
result8.then((result) => {
console.log(result); // Output: ["farhan7reza7", "username2", "username3", "usernameN"]
});
// Test case: user is following back
const result9 = followController.isFollowingBack('farhan7reza7');
result9.then((result) => {
console.log(result); // Output: "Yes, farhan7reza7 following back!"
});
// Test case: user is not following back
const result10 = followController.isFollowingBack('diff-ymd-package');
result10.then((result) => {
console.log(result); // Output: "No, diff-ymd-package does not following back!"
});
// Test case: unfollow a user who is not following back
const result11 = followController.unfollowNotFollowingBack('diff-ymd-package');
//Console Output: "Unfollowed: diff-ymd-package"
// not needed to console, because internally log message, just only call
result11.then((result) => {
console.log(result); // Output: "undefined"
});
// Test case: unfollow all users who are not following back
const result12 = followController.unfollowAllNotFollowingBack();
/* Console Output: "Unfollowed: Open-Sourced-Org"
"Unfollowed: username2"
"Unfollowed: username3"
"Unfollowed: usernameN"*/
// not return anything, and internally log message, just only call
result12.then((result) => {
console.log(result); // Output: "undefined"
});