mirror of
https://github.com/github/semantic.git
synced 2024-12-19 04:41:47 +03:00
17 lines
377 B
JavaScript
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;
|
|
}
|