Created
May 15, 2018 04:01
-
-
Save o0101/62c0b75d5a27e1020bba313fcd1e2588 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/hahajig
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
class HashTable { | |
constructor({ | |
ratio: ratio = 0.7, | |
hashFunction: hashFunction = HashTable.basicHash, | |
pairsList: pairsList = [] | |
} = {}) { | |
} | |
static basicHash( key ) { | |
const keyString = HashTable.anythingToString( key ); | |
const vals = []; | |
} | |
static anythingToString( a ) { | |
const type = Object.prototype.toString.call( a ); | |
let json = '[json:circular]'; | |
try { | |
json = JSON.stringify(a); | |
} catch(e) {}; | |
const str = a+''; | |
const numStr = a+0+''; | |
const numStrStrict = (a*1)+''; | |
const rep = `${type}:${json}:${str}:${numStr}:{numStrStrict}`; | |
return rep; | |
} | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">class HashTable { | |
constructor({ | |
ratio: ratio = 0.7, | |
hashFunction: hashFunction = HashTable.basicHash, | |
pairsList: pairsList = [] | |
} = {}) { | |
} | |
static basicHash( key ) { | |
const keyString = HashTable.anythingToString( key ); | |
const vals = []; | |
} | |
static anythingToString( a ) { | |
const type = Object.prototype.toString.call( a ); | |
let json = '[json:circular]'; | |
try { | |
json = JSON.stringify(a); | |
} catch(e) {}; | |
const str = a+''; | |
const numStr = a+0+''; | |
const numStrStrict = (a*1)+''; | |
const rep = `${type}:${json}:${str}:${numStr}:{numStrStrict}`; | |
return rep; | |
} | |
} | |
</script></body> | |
</html> |
This file contains hidden or 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
class HashTable { | |
constructor({ | |
ratio: ratio = 0.7, | |
hashFunction: hashFunction = HashTable.basicHash, | |
pairsList: pairsList = [] | |
} = {}) { | |
} | |
static basicHash( key ) { | |
const keyString = HashTable.anythingToString( key ); | |
const vals = []; | |
} | |
static anythingToString( a ) { | |
const type = Object.prototype.toString.call( a ); | |
let json = '[json:circular]'; | |
try { | |
json = JSON.stringify(a); | |
} catch(e) {}; | |
const str = a+''; | |
const numStr = a+0+''; | |
const numStrStrict = (a*1)+''; | |
const rep = `${type}:${json}:${str}:${numStr}:{numStrStrict}`; | |
return rep; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment