mirror of
https://github.com/S2-/gitlit
synced 2025-08-03 12:50:04 +02:00
packager
This commit is contained in:
6
app/node_modules/promise/.npmignore
generated
vendored
Normal file
6
app/node_modules/promise/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
components
|
||||
node_modules
|
||||
test
|
||||
.gitignore
|
||||
.travis.yml
|
||||
component.json
|
66
app/node_modules/promise/Readme.md
generated
vendored
Normal file
66
app/node_modules/promise/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
[](https://travis-ci.org/then/promise)
|
||||
<a href="http://promises-aplus.github.com/promises-spec"><img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png" align="right" /></a>
|
||||
# promise
|
||||
|
||||
This a bare bones [Promises/A+](http://promises-aplus.github.com/promises-spec/) implementation.
|
||||
|
||||
It is designed to get the basics spot on correct, so that you can build extended promise implementations on top of it.
|
||||
|
||||
## Installation
|
||||
|
||||
Client:
|
||||
|
||||
$ component install then/promise
|
||||
|
||||
Server:
|
||||
|
||||
$ npm install promise
|
||||
|
||||
## API
|
||||
|
||||
In the example below shows how you can load the promise library (in a way that works on both client and server). It then demonstrates creating a promise from scratch. You simply call `new Promise(fn)`. There is a complete specification for what is returned by this method in [Promises/A+](http://promises-aplus.github.com/promises-spec/). The resolver object has two methods `reject` and `fulfill` and their use is demonstrated here:
|
||||
|
||||
```javascript
|
||||
var Promise = require('promise');
|
||||
|
||||
var promise = new Promise(function (resolver) {
|
||||
get('http://www.google.com', function (err, res) {
|
||||
if (err) resolver.reject(err);
|
||||
else resolver.fulfill(res);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
## Extending Promises
|
||||
|
||||
There are two options for extending the promises created by this library.
|
||||
|
||||
### Inheritance
|
||||
|
||||
You can use inheritance if you want to create your own complete promise library with this as your basic starting point, perfect if you have lots of cool features you want to add. Here is an example of a promise library called `Awesome`, which is built on top of `Promise` correctly.
|
||||
|
||||
```javascript
|
||||
var Promise = require('promise');
|
||||
function Awesome(fn) {
|
||||
Promise.call(this, fn);
|
||||
}
|
||||
Awesome.prototype = Object.create(Promise.prototype);
|
||||
Awesome.prototype.constructor = Awesome;
|
||||
|
||||
//Awesome extension
|
||||
Awesome.prototype.spread = function (cb) {
|
||||
return this.then(function (arr) {
|
||||
return cb.apply(this, arr);
|
||||
})
|
||||
};
|
||||
```
|
||||
|
||||
N.B. if you fail to set the prototype and constructor properly or fail to do Promise.call, things can fail in really subtle ways.
|
||||
|
||||
### Extending the Prototype
|
||||
|
||||
In general, you should never extend the prototype of this promise implimenation because your extensions could easily conflict with someone elses extensions. However, this organisation will host a library of extensions which do not conflict with each other, so you can safely enable any of those. If you think of an extension that we don't provide and you want to write it, submit an issue on this repository and (if I agree) I'll set you up with a repository and give you permission to commit to it.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
98
app/node_modules/promise/index.js
generated
vendored
Normal file
98
app/node_modules/promise/index.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
var isPromise = require('is-promise')
|
||||
|
||||
var nextTick;
|
||||
if (typeof setImediate === 'function') nextTick = setImediate
|
||||
else if (typeof process === 'object' && process && process.nextTick) nextTick = process.nextTick
|
||||
else nextTick = function (cb) { setTimeout(cb, 0) }
|
||||
|
||||
var extensions = [];
|
||||
|
||||
module.exports = Promise
|
||||
function Promise(fn) {
|
||||
if (!(this instanceof Promise)) {
|
||||
return typeof fn === 'function' ? new Promise(fn) : defer()
|
||||
}
|
||||
var isResolved = false
|
||||
var isFulfilled = false
|
||||
var value
|
||||
var waiting = []
|
||||
var running = false
|
||||
|
||||
function next(skipTimeout) {
|
||||
if (waiting.length) {
|
||||
running = true
|
||||
waiting.shift()(skipTimeout || false)
|
||||
} else {
|
||||
running = false
|
||||
}
|
||||
}
|
||||
this.then = then;
|
||||
function then(cb, eb) {
|
||||
return new Promise(function (resolver) {
|
||||
function done(skipTimeout) {
|
||||
var callback = isFulfilled ? cb : eb
|
||||
if (typeof callback === 'function') {
|
||||
function timeoutDone() {
|
||||
var val;
|
||||
try {
|
||||
val = callback(value)
|
||||
} catch (ex) {
|
||||
resolver.reject(ex)
|
||||
return next()
|
||||
}
|
||||
resolver.fulfill(val);
|
||||
next(true);
|
||||
}
|
||||
if (skipTimeout) timeoutDone()
|
||||
else nextTick(timeoutDone)
|
||||
} else if (isFulfilled) {
|
||||
resolver.fulfill(value)
|
||||
next(skipTimeout)
|
||||
} else {
|
||||
resolver.reject(value)
|
||||
next(skipTimeout)
|
||||
}
|
||||
}
|
||||
waiting.push(done)
|
||||
if (isResolved && !running) next()
|
||||
});
|
||||
}
|
||||
|
||||
(function () {
|
||||
function fulfill(val) {
|
||||
if (isResolved) return
|
||||
if (isPromise(val)) val.then(fulfill, reject)
|
||||
else {
|
||||
isResolved = isFulfilled = true
|
||||
value = val
|
||||
next()
|
||||
}
|
||||
}
|
||||
function reject(err) {
|
||||
if (isResolved) return
|
||||
isResolved = true
|
||||
isFulfilled = false
|
||||
value = err
|
||||
next()
|
||||
}
|
||||
var resolver = {fulfill: fulfill, reject: reject};
|
||||
for (var i = 0; i < extensions.length; i++) {
|
||||
extensions[i](this, resolver);
|
||||
}
|
||||
if (typeof fn === 'function') {
|
||||
try {
|
||||
fn(resolver)
|
||||
} catch (ex) {
|
||||
resolver.reject(ex);
|
||||
}
|
||||
}
|
||||
}());
|
||||
}
|
||||
function defer() {
|
||||
var resolver
|
||||
var promise = new Promise(function (res) { resolver = res })
|
||||
return {resolver: resolver, promise: promise}
|
||||
}
|
||||
Promise.use = function (extension) {
|
||||
extensions.push(extension);
|
||||
};
|
52
app/node_modules/promise/package.json
generated
vendored
Normal file
52
app/node_modules/promise/package.json
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"_from": "promise@~1.3.0",
|
||||
"_id": "promise@1.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-5cyaTIJ45GZP/twBx9qEhCsEAXU=",
|
||||
"_location": "/promise",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "promise@~1.3.0",
|
||||
"name": "promise",
|
||||
"escapedName": "promise",
|
||||
"rawSpec": "~1.3.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~1.3.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/nodeify"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/promise/-/promise-1.3.0.tgz",
|
||||
"_shasum": "e5cc9a4c8278e4664ffedc01c7da84842b040175",
|
||||
"_spec": "promise@~1.3.0",
|
||||
"_where": "E:\\projects\\p\\gitlit\\app\\node_modules\\nodeify",
|
||||
"author": {
|
||||
"name": "ForbesLindesay"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/then/promise/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"is-promise": "~1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Bare bones Promises/A+ implementation",
|
||||
"devDependencies": {
|
||||
"promises-aplus-tests": "*"
|
||||
},
|
||||
"homepage": "https://github.com/then/promise#readme",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "promise",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/then/promise.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "promises-aplus-tests test/adapter-a.js"
|
||||
},
|
||||
"version": "1.3.0"
|
||||
}
|
Reference in New Issue
Block a user