by
21
8
2,906
7
Top 1% !
Popular
Famous
Nice
Useful
Easy-to-find
Refined
Pattern
Popularity: 4930th place
Architecturex86_64
Extensionjs
LanguageJavascript
LicenseMIT_X11
OSWindows
Windows VersionWindows8

... it's   KliKQ.js    &  its meh family brah......

Functional and flexible Collection or group - type data-structure. Itsupports gets, sets, sorts, all kindz of shit. Try it just once and the Government says your as gewd as hooked for life!
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/183670/----it-s---KliKQ-js-------its-meh-family?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
var KliKQ = (function () { function KliKQ() { this.mehArry = []; this.dahMap = {}; this.length = 0; } KliKQ.prototype.keyRoster = function () { var kz = []; this.eachIn(function (val, k) { kz.push(k); }); return kz; }; KliKQ.prototype.keyAssign = function (k, obj) { if (obj === 'undefined') { this.keyRemove(k); } else if (!this.dahMap.hasOwnProperty(k)) { this.dahMap[k] = this.mehArry.length; this.mehArry.push({ value: obj, key: k }); this.length++; } else { this.mehArry[this.dahMap[k]].value = obj; } }; KliKQ.prototype.keyPull = function (k) { if (this.dahMap.hasOwnProperty(k)) { return this.mehArry[this.dahMap[k]].value; } return undefined; }; KliKQ.prototype.idxGet = function (idx) { if (this.length <= idx) { return undefined; } return this.mehArry[idx].value; }; KliKQ.prototype.keyRemove = function (k) { if (this.dahMap.hasOwnProperty(k)) { var idx = this.dahMap[k], nam = ""; delete this.dahMap[k]; for (nam in this.dahMap) { if (this.dahMap.hasOwnProperty(nam) && this.dahMap[nam] >= idx) { this.dahMap[nam]--; } } this.mehArry.splice(idx, 1); this.length--; } }; KliKQ.prototype.eachIn = function (cback, slf) { var i = 0, ary = this.mehArry, len = ary.length; if (!slf) { slf = this; } while (i < len) { if (ary[i].value !== 'undefined') { cback.call(slf, ary[i].value, i, ary[i].key, this); } i++; } }; function kmprItems(dis, dat) { return (dis == dat) ? 0 : (dis < dat) ? -1 : 1; }; KliKQ.prototype.keySort = function (xprsn) { var i = 0, ary = this.mehArry, len = ary.length; if (!xprsn) { xprsn = kmprItems; } this.mehArry.sort(function (dis, dat) { return xprsn(dis.key, dat.key); }); while (i < len) { this.dahMap[ary[i].key] = i; i++; } }; return KliKQ; }());
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus