Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4d75362
Showing
6 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
components | ||
build | ||
node_modules | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"asi": true, | ||
"laxcomma": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
# lazy-promise | ||
|
||
A bare-bones lazily-evaluated Promises/A+ implementation. | ||
|
||
## Installation | ||
|
||
$ npm install lazy-promise | ||
|
||
or | ||
|
||
$ component install nathan7/lazy-promise | ||
|
||
## API | ||
|
||
### new Promise(function(resolve, reject)) | ||
|
||
Create a new lazy promise with the given function. | ||
|
||
## License | ||
|
||
MIT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "lazy-promise", | ||
"repo": "nathan7/lazy-promise", | ||
"description": "A bare-bones lazily-evaluated Promises/A+ implementation.", | ||
"version": "1.0.0", | ||
"keywords": [ | ||
"lazy", | ||
"promise" | ||
], | ||
"dependencies": { | ||
"then/promise": "*" | ||
}, | ||
"development": {}, | ||
"license": "MIT", | ||
"scripts": [ | ||
"index.js" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = LazyPromise | ||
function LazyPromise(fn) { | ||
if (!(this instanceof LazyPromise)) | ||
return new LazyPromise(fn) | ||
if (typeof fn !== 'function') | ||
throw new TypeError('fn is not a function') | ||
|
||
var promise = null | ||
this.then = function(onResolved, onRejected) { | ||
;(promise = promise || new Promise(fn)).then(onResolved, onRejected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "lazy-promise", | ||
"version": "1.0.0", | ||
"description": "A bare-bones lazily-evaluated Promises/A+ implementation.", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/nathan7/lazy-promise.git" | ||
}, | ||
"keywords": [ | ||
"lazy", | ||
"promise" | ||
], | ||
"author": "Nathan Zadoks", | ||
"license": "MIT", | ||
"dependencies": { | ||
"promise": "~2.0.0" | ||
} | ||
} |