Skip to content

Commit

Permalink
updated: doc and first stable release
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Jul 19, 2016
1 parent a26ffb4 commit c5dc101
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ Thanks to [this pull request](https://github.com/GianlucaGuarini/allora/pull/3)
const myWindow = allora(window)
const timer = myWindow.setTimeout(3000)
timer.then(_ => console.log('time over'))
clearTimeout(timer)
// the valueOf call should be not needed here
// but if you are on node, you will need it https://github.com/nodejs/node/issues/7792
clearTimeout(timer.valueOf())
```

## "allora" meaning
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function isOnCallback (str) {
* @param { String } prop - property we are trying to get from the parent object
* @returns { Proxy }
*/
function makePromisable (parent, prop) {
function allora (parent, prop) {
return new Proxy(prop ? parent[prop] : parent, {
get: (target, property) => {
// no function no need for promises in return
Expand All @@ -23,7 +23,7 @@ function makePromisable (parent, prop) {
return target[property]
} else {
// make proxy also the nested object properties
return makePromisable(target, property)
return allora(target, property)
}
},
// this is cool to make promiseable event emitters
Expand All @@ -45,4 +45,4 @@ function makePromisable (parent, prop) {
})
}

module.exports = exports.default = (object) => makePromisable(object)
module.exports = exports.default = (object) => allora(object)

0 comments on commit c5dc101

Please sign in to comment.