Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
edef1c committed Apr 4, 2013
0 parents commit 4d75362
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
components
build
node_modules
npm-debug.log
4 changes: 4 additions & 0 deletions .jshintrc
@@ -0,0 +1,4 @@
{
"asi": true,
"laxcomma": true
}
23 changes: 23 additions & 0 deletions README.md
@@ -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

18 changes: 18 additions & 0 deletions component.json
@@ -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"
]
}
12 changes: 12 additions & 0 deletions index.js
@@ -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)
}
}
19 changes: 19 additions & 0 deletions package.json
@@ -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"
}
}

0 comments on commit 4d75362

Please sign in to comment.