Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
remove changes files
  • Loading branch information
fntz committed Oct 2, 2012
commit 515f183986a4444f7ee4028432553f903095148a
64 changes: 0 additions & 64 deletions src/prototype/lang/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,67 +104,6 @@ var Hash = Class.create(Enumerable, (function() {
}
}

/**
* Hash#each_key(iterator[, context]) -> Hash
*
* Iterates over the keys in the hash.
*
* ##### Example
*
* var hash = $H({England: 'London', Poland: 'Warsaw'});
*
* h.each_key(function(country) {
* alert(country);
* });
* // Alerts: England
* // Alerts: Poland
*
**/
function each_key(iterator, context) {
this.keys().each(iterator, context);
}

/**
* Hash#each_value(iterator[, context]) -> Hash
*
* Iterates over the values in the hash.
*
* ##### Example
*
* var hash = $H({England: 'London', Poland: 'Warsaw'});
*
* h.each_value(function(capital) {
* alert(capital);
* });
* // Alerts: London
* // Alerts: Warsaw
**/
function each_value(iterator, context) {
this.values().each(iterator, context);
}

/**
* Hash#each_pair(iterator[, context]) -> Hash
*
* Iterates over the key/value pairs in the hash.
*
* ##### Example
*
* var hash = $H({England: 'London', Poland: 'Warsaw'});
*
* h.each_pair(function(country, capital) {
* alert(capital + "is the capital of " + country);
* });
* //Alerts: London is the capital of England
* //Alerts: Warsaw is the capital of Poland
*
**/
function each_pair(iterator, context) {
this.each(function(pair) {
iterator.call(context, pair.key, pair.value)
});
}

/**
* Hash#set(key, value) -> value
* - key (String): The key to use for this value.
Expand Down Expand Up @@ -449,9 +388,6 @@ var Hash = Class.create(Enumerable, (function() {
return {
initialize: initialize,
_each: _each,
each_key: each_key,
each_value: each_value,
each_pair: each_pair,
set: set,
get: get,
unset: unset,
Expand Down
30 changes: 0 additions & 30 deletions test/unit/hash_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,36 +191,6 @@ new Test.Unit.Runner({
result.push(i);
});
this.assertEnumEqual([0,1], result);
},

testIterationWithEachKey: function() {
var hash = $H({a:1, b:2, c:3});
var keys = [];
hash.each_key(function(key) {
keys.push(key);
});
this.assertEnumEqual(['a', 'b', 'c'], keys);
},

testIterationWithEachValue: function() {
var hash = $H({a:1, b:2, c:3});
var values = [];
hash.each_value(function(value) {
values.push(value);
});
this.assertEnumEqual([1, 2, 3], values);
},

testIterationWithEachPair: function() {
var hash = $H({a:1, b:2, c:3});
var keys = [];
var values = [];
hash.each_pair(function(key, value) {
keys.push(key);
values.push(value);
});
this.assertEnumEqual([1, 2, 3], values);
this.assertEnumEqual(['a', 'b', 'c'], keys);
}

});