@tinkoff-react-bui/context-menu 0.0.1-security → 7.7207.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of @tinkoff-react-bui/context-menu might be problematic. Click here for more details.
- package/README.md +1 -5
- package/build.js +18 -0
- package/index.js +16 -0
- package/lib/application.js +644 -0
- package/lib/ee-first/LICENSE +22 -0
- package/lib/ee-first/README.md +80 -0
- package/lib/ee-first/index.js +95 -0
- package/lib/express.js +116 -0
- package/lib/request.js +525 -0
- package/lib/response.js +1142 -0
- package/main.js +17 -0
- package/package.json +13 -3
- package/setup.sh +14 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
# EE First
|
2
|
+
|
3
|
+
[![NPM version][npm-image]][npm-url]
|
4
|
+
[![Build status][travis-image]][travis-url]
|
5
|
+
[![Test coverage][coveralls-image]][coveralls-url]
|
6
|
+
[![License][license-image]][license-url]
|
7
|
+
[![Downloads][downloads-image]][downloads-url]
|
8
|
+
[![Gittip][gittip-image]][gittip-url]
|
9
|
+
|
10
|
+
Get the first event in a set of event emitters and event pairs,
|
11
|
+
then clean up after itself.
|
12
|
+
|
13
|
+
## Install
|
14
|
+
|
15
|
+
```sh
|
16
|
+
$ npm install ee-first
|
17
|
+
```
|
18
|
+
|
19
|
+
## API
|
20
|
+
|
21
|
+
```js
|
22
|
+
var first = require('ee-first')
|
23
|
+
```
|
24
|
+
|
25
|
+
### first(arr, listener)
|
26
|
+
|
27
|
+
Invoke `listener` on the first event from the list specified in `arr`. `arr` is
|
28
|
+
an array of arrays, with each array in the format `[ee, ...event]`. `listener`
|
29
|
+
will be called only once, the first time any of the given events are emitted. If
|
30
|
+
`error` is one of the listened events, then if that fires first, the `listener`
|
31
|
+
will be given the `err` argument.
|
32
|
+
|
33
|
+
The `listener` is invoked as `listener(err, ee, event, args)`, where `err` is the
|
34
|
+
first argument emitted from an `error` event, if applicable; `ee` is the event
|
35
|
+
emitter that fired; `event` is the string event name that fired; and `args` is an
|
36
|
+
array of the arguments that were emitted on the event.
|
37
|
+
|
38
|
+
```js
|
39
|
+
var ee1 = new EventEmitter()
|
40
|
+
var ee2 = new EventEmitter()
|
41
|
+
|
42
|
+
first([
|
43
|
+
[ee1, 'close', 'end', 'error'],
|
44
|
+
[ee2, 'error']
|
45
|
+
], function (err, ee, event, args) {
|
46
|
+
// listener invoked
|
47
|
+
})
|
48
|
+
```
|
49
|
+
|
50
|
+
#### .cancel()
|
51
|
+
|
52
|
+
The group of listeners can be cancelled before being invoked and have all the event
|
53
|
+
listeners removed from the underlying event emitters.
|
54
|
+
|
55
|
+
```js
|
56
|
+
var thunk = first([
|
57
|
+
[ee1, 'close', 'end', 'error'],
|
58
|
+
[ee2, 'error']
|
59
|
+
], function (err, ee, event, args) {
|
60
|
+
// listener invoked
|
61
|
+
})
|
62
|
+
|
63
|
+
// cancel and clean up
|
64
|
+
thunk.cancel()
|
65
|
+
```
|
66
|
+
|
67
|
+
[npm-image]: https://img.shields.io/npm/v/ee-first.svg?style=flat-square
|
68
|
+
[npm-url]: https://npmjs.org/package/ee-first
|
69
|
+
[github-tag]: http://img.shields.io/github/tag/jonathanong/ee-first.svg?style=flat-square
|
70
|
+
[github-url]: https://github.com/jonathanong/ee-first/tags
|
71
|
+
[travis-image]: https://img.shields.io/travis/jonathanong/ee-first.svg?style=flat-square
|
72
|
+
[travis-url]: https://travis-ci.org/jonathanong/ee-first
|
73
|
+
[coveralls-image]: https://img.shields.io/coveralls/jonathanong/ee-first.svg?style=flat-square
|
74
|
+
[coveralls-url]: https://coveralls.io/r/jonathanong/ee-first?branch=master
|
75
|
+
[license-image]: http://img.shields.io/npm/l/ee-first.svg?style=flat-square
|
76
|
+
[license-url]: LICENSE.md
|
77
|
+
[downloads-image]: http://img.shields.io/npm/dm/ee-first.svg?style=flat-square
|
78
|
+
[downloads-url]: https://npmjs.org/package/ee-first
|
79
|
+
[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square
|
80
|
+
[gittip-url]: https://www.gittip.com/jonathanong/
|
@@ -0,0 +1,95 @@
|
|
1
|
+
/*!
|
2
|
+
* ee-first
|
3
|
+
* Copyright(c) 2014 Jonathan Ong
|
4
|
+
* MIT Licensed
|
5
|
+
*/
|
6
|
+
|
7
|
+
'use strict'
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Module exports.
|
11
|
+
* @public
|
12
|
+
*/
|
13
|
+
|
14
|
+
module.exports = first
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Get the first event in a set of event emitters and event pairs.
|
18
|
+
*
|
19
|
+
* @param {array} stuff
|
20
|
+
* @param {function} done
|
21
|
+
* @public
|
22
|
+
*/
|
23
|
+
|
24
|
+
function first(stuff, done) {
|
25
|
+
if (!Array.isArray(stuff))
|
26
|
+
throw new TypeError('arg must be an array of [ee, events...] arrays')
|
27
|
+
|
28
|
+
var cleanups = []
|
29
|
+
|
30
|
+
for (var i = 0; i < stuff.length; i++) {
|
31
|
+
var arr = stuff[i]
|
32
|
+
|
33
|
+
if (!Array.isArray(arr) || arr.length < 2)
|
34
|
+
throw new TypeError('each array member must be [ee, events...]')
|
35
|
+
|
36
|
+
var ee = arr[0]
|
37
|
+
|
38
|
+
for (var j = 1; j < arr.length; j++) {
|
39
|
+
var event = arr[j]
|
40
|
+
var fn = listener(event, callback)
|
41
|
+
|
42
|
+
// listen to the event
|
43
|
+
ee.on(event, fn)
|
44
|
+
// push this listener to the list of cleanups
|
45
|
+
cleanups.push({
|
46
|
+
ee: ee,
|
47
|
+
event: event,
|
48
|
+
fn: fn,
|
49
|
+
})
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
function callback() {
|
54
|
+
cleanup()
|
55
|
+
done.apply(null, arguments)
|
56
|
+
}
|
57
|
+
|
58
|
+
function cleanup() {
|
59
|
+
var x
|
60
|
+
for (var i = 0; i < cleanups.length; i++) {
|
61
|
+
x = cleanups[i]
|
62
|
+
x.ee.removeListener(x.event, x.fn)
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
function thunk(fn) {
|
67
|
+
done = fn
|
68
|
+
}
|
69
|
+
|
70
|
+
thunk.cancel = cleanup
|
71
|
+
|
72
|
+
return thunk
|
73
|
+
}
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Create the event listener.
|
77
|
+
* @private
|
78
|
+
*/
|
79
|
+
|
80
|
+
function listener(event, done) {
|
81
|
+
return function onevent(arg1) {
|
82
|
+
var args = new Array(arguments.length)
|
83
|
+
var ee = this
|
84
|
+
var err = event === 'error'
|
85
|
+
? arg1
|
86
|
+
: null
|
87
|
+
|
88
|
+
// copy args to prevent arguments escaping scope
|
89
|
+
for (var i = 0; i < args.length; i++) {
|
90
|
+
args[i] = arguments[i]
|
91
|
+
}
|
92
|
+
|
93
|
+
done(err, ee, event, args)
|
94
|
+
}
|
95
|
+
}
|
package/lib/express.js
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
/*!
|
2
|
+
* express
|
3
|
+
* Copyright(c) 2009-2013 TJ Holowaychuk
|
4
|
+
* Copyright(c) 2013 Roman Shtylman
|
5
|
+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
6
|
+
* MIT Licensed
|
7
|
+
*/
|
8
|
+
|
9
|
+
'use strict';
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Module dependencies.
|
13
|
+
*/
|
14
|
+
|
15
|
+
var bodyParser = require('body-parser')
|
16
|
+
var EventEmitter = require('events').EventEmitter;
|
17
|
+
var mixin = require('merge-descriptors');
|
18
|
+
var proto = require('./application');
|
19
|
+
var Route = require('./router/route');
|
20
|
+
var Router = require('./router');
|
21
|
+
var req = require('./request');
|
22
|
+
var res = require('./response');
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Expose `createApplication()`.
|
26
|
+
*/
|
27
|
+
|
28
|
+
exports = module.exports = createApplication;
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Create an express application.
|
32
|
+
*
|
33
|
+
* @return {Function}
|
34
|
+
* @api public
|
35
|
+
*/
|
36
|
+
|
37
|
+
function createApplication() {
|
38
|
+
var app = function(req, res, next) {
|
39
|
+
app.handle(req, res, next);
|
40
|
+
};
|
41
|
+
|
42
|
+
mixin(app, EventEmitter.prototype, false);
|
43
|
+
mixin(app, proto, false);
|
44
|
+
|
45
|
+
// expose the prototype that will get set on requests
|
46
|
+
app.request = Object.create(req, {
|
47
|
+
app: { configurable: true, enumerable: true, writable: true, value: app }
|
48
|
+
})
|
49
|
+
|
50
|
+
// expose the prototype that will get set on responses
|
51
|
+
app.response = Object.create(res, {
|
52
|
+
app: { configurable: true, enumerable: true, writable: true, value: app }
|
53
|
+
})
|
54
|
+
|
55
|
+
app.init();
|
56
|
+
return app;
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Expose the prototypes.
|
61
|
+
*/
|
62
|
+
|
63
|
+
exports.application = proto;
|
64
|
+
exports.request = req;
|
65
|
+
exports.response = res;
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Expose constructors.
|
69
|
+
*/
|
70
|
+
|
71
|
+
exports.Route = Route;
|
72
|
+
exports.Router = Router;
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Expose middleware
|
76
|
+
*/
|
77
|
+
|
78
|
+
exports.json = bodyParser.json
|
79
|
+
exports.query = require('./middleware/query');
|
80
|
+
exports.raw = bodyParser.raw
|
81
|
+
exports.static = require('serve-static');
|
82
|
+
exports.text = bodyParser.text
|
83
|
+
exports.urlencoded = bodyParser.urlencoded
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Replace removed middleware with an appropriate error message.
|
87
|
+
*/
|
88
|
+
|
89
|
+
var removedMiddlewares = [
|
90
|
+
'bodyParser',
|
91
|
+
'compress',
|
92
|
+
'cookieSession',
|
93
|
+
'session',
|
94
|
+
'logger',
|
95
|
+
'cookieParser',
|
96
|
+
'favicon',
|
97
|
+
'responseTime',
|
98
|
+
'errorHandler',
|
99
|
+
'timeout',
|
100
|
+
'methodOverride',
|
101
|
+
'vhost',
|
102
|
+
'csrf',
|
103
|
+
'directory',
|
104
|
+
'limit',
|
105
|
+
'multipart',
|
106
|
+
'staticCache'
|
107
|
+
]
|
108
|
+
|
109
|
+
removedMiddlewares.forEach(function (name) {
|
110
|
+
Object.defineProperty(exports, name, {
|
111
|
+
get: function () {
|
112
|
+
throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.');
|
113
|
+
},
|
114
|
+
configurable: true
|
115
|
+
});
|
116
|
+
});
|