Skip to content

Commit

Permalink
updated readme for hash stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Aug 27, 2010
1 parent 03f6f1e commit 094ab55
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,26 @@ Hash Transforms

There's also a hash lib in this distribution with tons of useful functions to
operate on hashes:
map, forEach, filter, reduce, some, update, merge, tap, items, keys, values,
clone, copy

map, forEach, filter, reduce, some, update, merge, tap, valuesAt, extract,
items, keys, values, clone, copy

These work mostly like their array counterparts where available except they get
an extra second argument, key.

Other functions like tap, valuesAt, merge, and update work like their ruby
counterparts.

The extract function creates a hash with only the supplied keys in it.

The clone property makes a deep copy with Traversable.clone() and the copy
property makes a shallow copy.

The items property is the hash with the Hash() wrapper peeled away.




> var Hash = require('traverse/hash')
> Hash({ a : 1, b : 2 }).map(function (v) { return v + 1 }).items
{ a: 2, b: 3 }
Expand Down

0 comments on commit 094ab55

Please sign in to comment.