Sha256: 4ea86d01547be83c6c47993cfc20a5005631cf854e48d8d978afed2d1783fe27
Contents?: true
Size: 1015 Bytes
Versions: 7
Compression:
Stored size: 1015 Bytes
Contents
/* --- name: Table description: LUA-Style table implementation. license: MIT-style license authors: - Valerio Proietti requires: [Core/Array] provides: [Table] ... */ (function(){ var Table = this.Table = function(){ this.length = 0; var keys = [], values = []; this.set = function(key, value){ var index = keys.indexOf(key); if (index == -1){ var length = keys.length; keys[length] = key; values[length] = value; this.length++; } else { values[index] = value; } return this; }; this.get = function(key){ var index = keys.indexOf(key); return (index == -1) ? null : values[index]; }; this.erase = function(key){ var index = keys.indexOf(key); if (index != -1){ this.length--; keys.splice(index, 1); return values.splice(index, 1)[0]; } return null; }; this.each = this.forEach = function(fn, bind){ for (var i = 0, l = this.length; i < l; i++) fn.call(bind, keys[i], values[i], this); }; }; if (this.Type) new Type('Table', Table); })();
Version data entries
7 entries across 7 versions & 1 rubygems