Skip to content

Instantly share code, notes, and snippets.

@o0101
Created May 15, 2018 04:01
Show Gist options
  • Save o0101/62c0b75d5a27e1020bba313fcd1e2588 to your computer and use it in GitHub Desktop.
Save o0101/62c0b75d5a27e1020bba313fcd1e2588 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/hahajig
<!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>
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