Skip to content

Commit

Permalink
updating README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
myas92 committed Sep 28, 2021
1 parent 7c5c0ed commit 8194b60
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 15 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,52 @@ domainFinder({
postfix:"coin"
})
```
## Fourth Example ##
If you want to find domains for a word with lower than 4 length, you should set `prefix` or `postfix`,
There are diffrenete status for prefix and post fix
`statusPrefix=0` that means if you set the `prefix` is ignored.
`statusPrefix=1` that means if just check domain for words with prefix.
`statusPrefix=2` that means if just check domain for words with prefix and none prefix.
`statusPostfix` is like the `statusPostfix`
If you don't set status for `statusPostfix` or `statusPostfix` default value is 5 that means check all conditions
```
statusPrefix=0, ["a","b"] => ["a", "b"]
statusPrefix=1, ["a","b"] => ["ia", "ib"]
statusPrefix=2, ["a","b"] => ["a", "b"] and ["ia", "ib"]

statusPrefix=2, ["app"] => ["app", "apa"] => ["app", "apa"]
statusPrefix=3, ["app"] => ["app", "apa"] => ["iapp", "iapa"]
statusPrefix=4, ["app"] => ["app", "apa"] => ["app", "apa"] and ["iapp", "iapa"]
-----------------------------------------------------------------------------------------
statusPostfix=0, ["a","b"] => ["a", "b"]
statusPostfix=1, ["a","b"] => ["ai", "bi"]
statusPostfix=2, ["a","b"] => ["a", "b"] and ["ai", "bi"]

statusPostfix=2, ["app"] => ["app", "apa"] => ["app", "apa"]
statusPostfix=3, ["app"] => ["app", "apa"] => ["appi", "apai"]
statusPostfix=4, ["app"] => ["app", "apa"] => ["app", "apa"] and ["appi", "apai"];
-----------------------------------------------------------------------------------------

(prefix=i && statusPrefix=5) &&(postfix= x && statusPostfix=5),
["app"] => ["app", "apa"] => ["app", "apa"] and ["appx", "apax"]; and ["iapp","iapa"] and ["iappx", "iapax"]
```
```
const domainFinder = require('domain-finder');

domainFinder({
domainNames:["apple"],
tlds: ["com","net"],
prefix:"i",
postfix:"coin"
statusPrefix: 5,
statusPostfix: 5
})
```
22 changes: 7 additions & 15 deletions business-logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class BusinessLogic {
this.finderWords = new FinderWords();
}
async process({ domainNames, tlds, consoleLog, prefix, postfix, statusPrefix, statusPostfix }) {
let domains;
let initDomains;
if (domainNames.length == 1)
domains = await this.finderWords.find(domainNames[0])
initDomains = await this.finderWords.find(domainNames[0])
else {
domains = domainNames
initDomains = domainNames
}
let parsedDomain = this.setPostfixPrefixDomain({ domains, prefix, postfix, statusPrefix, statusPostfix })
let urls = await this.getUrlsFromGoogle({ domains, prefix, postfix, statusPrefix, statusPostfix })
let parsedDomain = this.setPostfixPrefixDomain({ domains: initDomains, prefix, postfix, statusPrefix, statusPostfix })
let urls = await this.getUrlsFromGoogle({ domains: parsedDomain, prefix, postfix, statusPrefix, statusPostfix })
let allParsedUrls = this.saveUrls(urls, tlds, consoleLog)
return allParsedUrls
}
Expand All @@ -33,7 +33,6 @@ class BusinessLogic {

})
}

if (prefix) {
if (statusPrefix == 0) {
domains.forEach(item => {
Expand Down Expand Up @@ -74,20 +73,15 @@ class BusinessLogic {
})
}
}


let uniqeDomain = [...new Set(result)]
console.log(uniqeDomain);
console.log(result);

return uniqeDomain
}
async getUrlsFromGoogle({ domains, prefix, postfix, statusPrefix, statusPostfix }) {
let defer = q.defer()
let googleUrls = []
async.eachOfSeries(domains, async (domain, index) => {
try {
if (domain.length < 4 && (prefix || postfix))
domain = `${prefix}${domain}${postfix}`.toLowerCase()

console.log(`${index + 1}:${domain.toLowerCase()}`);
const { error, result } = await GoogleWeb.run(domain);
if (error) {
Expand All @@ -97,8 +91,6 @@ class BusinessLogic {
let obj = { domainName: domain, urls: result }
googleUrls.push(obj)
}


} catch (error) {
console.log(error.message)
}
Expand Down

0 comments on commit 8194b60

Please sign in to comment.