Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Raynos committed Sep 6, 2012
1 parent a1ed6bb commit 45bc33e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ Stream that updates attributes on elements
Creates a [delta-stream][1] which when written to updates attributes

``` js
var stream = AttributeStream(someElement)
var delta = Attribute(someElement)

stream.write([{
"anyAttribute": "anyValue"
}])
delta.set("anyAttribute", "anyValue")
```

## Installation
Expand Down
14 changes: 5 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
var forEach = require("iterators").forEachSync
, through = require("through")
, Delta = require("delta-stream")

module.exports = AttributeStream

function AttributeStream(elem) {
var stream = through(updateAttribute)
var delta = Delta()

return stream
delta.on("changes", setAttribute)

function updateAttribute(data) {
var changes = data[0]
return delta

forEach(changes, setAttribute)
}

function setAttribute(value, key) {
function setAttribute(key, value) {
elem.setAttribute(key, value)
}
}

0 comments on commit 45bc33e

Please sign in to comment.