1
0
mirror of https://github.com/S2-/gitlit synced 2025-08-03 12:50:04 +02:00
This commit is contained in:
s2
2018-05-18 17:26:33 +02:00
parent 0ea0853165
commit 2c5b23c10e
1125 changed files with 118732 additions and 1 deletions

16
app/node_modules/nodeify/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,16 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
pids
logs
results
npm-debug.log
node_modules

3
app/node_modules/nodeify/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,3 @@
language: node_js
node_js:
- 0.8

19
app/node_modules/nodeify/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2014 Forbes Lindesay
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

88
app/node_modules/nodeify/README.md generated vendored Normal file
View File

@@ -0,0 +1,88 @@
[![Build Status](https://img.shields.io/travis/then/nodeify/master.svg)](https://travis-ci.org/then/nodeify)
# Nodeify
Convert promised code to use node style callbacks. If no callback is provided it will just return the original promise.
## Installation
Server:
$ npm install nodeify
## Usage
### Functional
Call `nodeify` directly passing the `promise` and an optional `callback` as arguments. If a `callback` is provided it will be called as `callback(error, result)`. If `callback` is not a function, `promise` is returned.
```javascript
var nodeify = require('nodeify');
function myAsyncMethod(arg, callback) {
return nodeify(myPromiseMethod(arg), callback);
}
```
### Constructor / Method
The `nodeify.Promise` constructor returns a promise with a `.nodeify` method which behaves just like the functional version above except that the first argument is implicitly `this`.
```javascript
var Promise = require('nodeify').Promise;
function myAsyncMethod(arg, callback) {
return new Promise(function (resolver) {
//do async work
})
.nodeify(callback);
}
```
### Extend
#### Extend(promise)
Takes a promise and extends it to support the `.nodeify` method. It will still support the nodeify method after calls to `.then`.
```javascript
var Promise = require('promise');
var nodeify = require('nodeify');
function myAsyncMethod(arg, callback) {
return nodeify.extend(myPromiseMethod(arg))
.nodeify(callback);
}
```
#### Extend(PromiseConstructor)
Takes a PromiseConstructor and extends it to support the `.nodeify` method.
```javascript
var PromiseConstructor = require('promise-constructor-used-by-my-promise-method');
require('nodeify').extend(PromiseConstructor);
function myAsyncMethod(arg, callback) {
return myPromiseMethod(arg).nodeify(callback);
}
```
#### Extend()
Extends the default promise constructor (returned by calling `require('promise')`) and extends it to support `.nodeify`.
```javascript
require('nodeify').extend();
function myAsyncMethod(arg, callback) {
//assuming myPromiseMethod uses `promise` as its promise library
return myPromiseMethod(arg).nodeify(callback);
}
```
## Licence
MIT
![viewcount](https://viewcount.jepso.com/count/then/nodeify.png)

54
app/node_modules/nodeify/index.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
var Promise = require('promise');
var isPromise = require('is-promise');
var nextTick;
if (typeof setImmediate === 'function') nextTick = setImmediate
else if (typeof process === 'object' && process && process.nextTick) nextTick = process.nextTick
else nextTick = function (cb) { setTimeout(cb, 0) }
module.exports = nodeify;
function nodeify(promise, cb) {
if (typeof cb !== 'function') return promise;
return promise
.then(function (res) {
nextTick(function () {
cb(null, res);
});
}, function (err) {
nextTick(function () {
cb(err);
});
});
}
function nodeifyThis(cb) {
return nodeify(this, cb);
}
nodeify.extend = extend;
nodeify.Promise = NodeifyPromise;
function extend(prom) {
if (prom && isPromise(prom)) {
prom.nodeify = nodeifyThis;
var then = prom.then;
prom.then = function () {
return extend(then.apply(this, arguments));
};
return prom;
} else if (typeof prom === 'function') {
prom.prototype.nodeify = nodeifyThis;
} else {
Promise.prototype.nodeify = nodeifyThis;
}
}
function NodeifyPromise(fn) {
if (!(this instanceof NodeifyPromise)) {
return new NodeifyPromise(fn);
}
Promise.call(this, fn);
extend(this);
}
NodeifyPromise.prototype = Object.create(Promise.prototype);
NodeifyPromise.prototype.constructor = NodeifyPromise;

60
app/node_modules/nodeify/package.json generated vendored Normal file
View File

@@ -0,0 +1,60 @@
{
"_from": "nodeify@^1.0.1",
"_id": "nodeify@1.0.1",
"_inBundle": false,
"_integrity": "sha1-ZKtpp7268DzhB7TwM1yHwLnpGx0=",
"_location": "/nodeify",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "nodeify@^1.0.1",
"name": "nodeify",
"escapedName": "nodeify",
"rawSpec": "^1.0.1",
"saveSpec": null,
"fetchSpec": "^1.0.1"
},
"_requiredBy": [
"/electron-packager"
],
"_resolved": "https://registry.npmjs.org/nodeify/-/nodeify-1.0.1.tgz",
"_shasum": "64ab69a7bdbaf03ce107b4f0335c87c0b9e91b1d",
"_spec": "nodeify@^1.0.1",
"_where": "E:\\projects\\p\\gitlit\\app\\node_modules\\electron-packager",
"author": {
"name": "ForbesLindesay"
},
"bugs": {
"url": "https://github.com/then/nodeify/issues"
},
"bundleDependencies": false,
"dependencies": {
"is-promise": "~1.0.0",
"promise": "~1.3.0"
},
"deprecated": false,
"description": "Convert promised code to use node style callbacks",
"devDependencies": {
"mocha": "~1.8.1",
"mocha-as-promised": "~1.2.1"
},
"homepage": "https://github.com/then/nodeify#readme",
"keywords": [
"promise",
"then",
"nodeify",
"callback"
],
"license": "MIT",
"name": "nodeify",
"repository": {
"type": "git",
"url": "git+https://github.com/then/nodeify.git"
},
"scripts": {
"prepublish": "npm test",
"test": "mocha -R spec"
},
"version": "1.0.1"
}

141
app/node_modules/nodeify/test/index.js generated vendored Normal file
View File

@@ -0,0 +1,141 @@
require('mocha-as-promised')();
var assert = require('assert');
var Promise = require('promise');
var nodeify = require('../');
var A = {};
var B = {};
describe('nodeify(promise, callback)', function () {
describe('when callback is a function', function () {
it('still returns a promise which is always fulfilled with undefined', function () {
var pA = new Promise(function (res) { res.fulfill(A); });
var pB = new Promise(function (res) { res.reject(B); });
return nodeify(pA, function (err, res) {})
.then(function (res) {
assert(typeof res === 'undefined');
return nodeify(pB, function (err, res) {});
})
.then(function (res) {
assert(typeof res === 'undefined');
});
});
describe('when the promise is resolved', function () {
it('calls the callback with (null, result)', function (done) {
var p = new Promise(function (res) { res.fulfill(A); });
nodeify(p, function (err, res) {
if (err) return done(err);
assert(res === A);
done();
});
});
});
describe('when the promise is rejected', function () {
it('calls the callback with (error)', function (done) {
var p = new Promise(function (res) { res.reject(A); });
nodeify(p, function (err, res) {
assert(err === A);
assert(arguments.length === 1);
done();
});
});
});
});
describe('when callback is not a function', function () {
it('returns the original promise', function () {
assert(nodeify(A) === A);
assert(nodeify(A, null) === A);
assert(nodeify(A, B) === A);
});
});
});
describe('(new nodeify.Promise(fn)).nodeify(callback)', function () {
describe('when callback is a function', function () {
it('still returns a promise which is always fulfilled with undefined', function () {
var pA = new nodeify.Promise(function (res) { res.fulfill(A); });
var pB = new nodeify.Promise(function (res) { res.reject(B); });
return pA.nodeify(function (err, res) {})
.then(function (res) {
assert(typeof res === 'undefined');
return pB.nodeify(function (err, res) {});
})
.then(function (res) {
assert(typeof res === 'undefined');
});
});
describe('when the promise is resolved', function () {
it('calls the callback with (null, result)', function (done) {
var p = new nodeify.Promise(function (res) { res.fulfill(A); });
p.nodeify(function (err, res) {
if (err) return done(err);
assert(res === A);
done();
});
});
});
describe('when the promise is rejected', function () {
it('calls the callback with (error)', function (done) {
var p = new nodeify.Promise(function (res) { res.reject(A); });
p.nodeify(function (err, res) {
assert(err === A);
assert(arguments.length === 1);
done();
});
});
});
});
describe('when callback is not a function', function () {
it('returns the original promise', function () {
var p = new nodeify.Promise(function (res) { res.fulfill(A); });
assert(p.nodeify() === p);
assert(p.nodeify(null) === p);
assert(p.nodeify(B) === p);
});
});
describe('calls to then', function () {
it('maintain the nodeify method', function (done) {
(new nodeify.Promise(function (res) { res.fulfill(A); }))
.then(function () { return B; })
.then(function (res) {
assert(res === B);
return A;
})
.nodeify(function (err, res) {
if (err) return done(err);
assert(res === A);
done();
});
});
});
});
describe('nodeify.extend(promise)', function () {
it('adds the nodeify method to promise (including promises resulting from calling promise.then)', function (done) {
nodeify.extend(new Promise(function (res) { res.fulfill(A); }))
.then(function () { return B; })
.then(function (res) {
assert(res === B);
return A;
})
.nodeify(function (err, res) {
if (err) return done(err);
assert(res === A);
done();
});
});
});
describe('nodeify.extend(PromiseConstructor)', function () {
function PromiseConstructor() {};
it('adds the nodeify method to PromiseConstructor.prototype', function () {
nodeify.extend(PromiseConstructor)
assert(typeof PromiseConstructor.prototype.nodeify === 'function');
});
});
describe('nodeify.extend()', function () {
it('adds the nodeify method on to all promises inheriting from Promise', function () {
nodeify.extend()
assert(typeof Promise.prototype.nodeify === 'function');
});
});