1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 18:23:44 +03:00
semantic/prototype/UI/dictionary.js
2015-10-27 11:09:48 -04:00

17 lines
377 B
JavaScript

function Dictionary(object) {
this.values = {};
for (key in object) {
this.values[key] = object[key];
}
return this;
}
// forall a b. Dictionary String a -> (a -> b) -> Dictionary String b
Dictionary.prototype.map = function(transform) {
var copy = new Dictionary();
for (key in this.values) {
copy.values[key] = transform(this.values[key], key);
}
return copy;
}