1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 01:42:43 +03:00
semantic/prototype/UI/dictionary.js

17 lines
377 B
JavaScript
Raw Normal View History

2015-10-27 18:09:48 +03:00
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;
}