Skip to content

ctrl-alt-deseat/ctrlpanel-find-accounts-for-hostname

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Find Accounts for Hostname

Find accounts that as closely as possible matches a hostname.

Installation

npm install --save @ctrlpanel/find-accounts-for-hostname

Usage

const findAccountsForHostname = require('@ctrlpanel/find-accounts-for-hostname')

const accounts = [
  { hostname: 'github.com', /* any other properties */ },
  { hostname: 'twitter.com', /* any other properties */ },
  { hostname: 'airbnb.com', /* any other properties */ },
  { hostname: 'facebook.com', /* any other properties */ },
  { hostname: 'google.com', /* any other properties */ }
]

console.log(findAccountsForHostname('facebook.com', accounts))
//=> [{ hostname: 'facebook.com', score: 1, /* any other properties */ }]

console.log(findAccountsForHostname('login.github.com', accounts))
//=> [{ hostname: 'github.com', score: 0.8, /* any other properties */ }]

console.log(findAccountsForHostname('travels.airbnb.com', accounts))
//=> [{ hostname: 'airbnb.com', score: 0.6, /* any other properties */ }]

console.log(findAccountsForHostname('twitter.se', accounts))
//=> [{ hostname: 'twitter.com', score: 0.4, /* any other properties */ }]

console.log(findAccountsForHostname('chat.google.se', accounts))
//=> [{ hostname: 'google.com', score: 0.2, /* any other properties */ }]

About

Find accounts that as closely as possible matches a hostname

Resources

Stars

Watchers

Forks

Packages

No packages published