mirror of
https://github.com/thewesker/bug-em.git
synced 2025-12-23 05:21:05 -05:00
DMs
This commit is contained in:
3
node_modules/twit/.npmignore
generated
vendored
Normal file
3
node_modules/twit/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
config*.js
|
||||
test.js
|
||||
647
node_modules/twit/README.md
generated
vendored
Normal file
647
node_modules/twit/README.md
generated
vendored
Normal file
@@ -0,0 +1,647 @@
|
||||
#twit
|
||||
|
||||
Twitter API Client for node
|
||||
|
||||
Supports both the **REST** and **Streaming** API.
|
||||
|
||||
#Installing
|
||||
|
||||
```
|
||||
npm install twit
|
||||
```
|
||||
|
||||
##Usage:
|
||||
|
||||
```javascript
|
||||
var Twit = require('twit')
|
||||
|
||||
var T = new Twit({
|
||||
consumer_key: '...',
|
||||
consumer_secret: '...',
|
||||
access_token: '...',
|
||||
access_token_secret: '...',
|
||||
timeout_ms: 60*1000, // optional HTTP request timeout to apply to all requests.
|
||||
})
|
||||
|
||||
//
|
||||
// tweet 'hello world!'
|
||||
//
|
||||
T.post('statuses/update', { status: 'hello world!' }, function(err, data, response) {
|
||||
console.log(data)
|
||||
})
|
||||
|
||||
//
|
||||
// search twitter for all tweets containing the word 'banana' since July 11, 2011
|
||||
//
|
||||
T.get('search/tweets', { q: 'banana since:2011-07-11', count: 100 }, function(err, data, response) {
|
||||
console.log(data)
|
||||
})
|
||||
|
||||
//
|
||||
// get the list of user id's that follow @tolga_tezel
|
||||
//
|
||||
T.get('followers/ids', { screen_name: 'tolga_tezel' }, function (err, data, response) {
|
||||
console.log(data)
|
||||
})
|
||||
|
||||
//
|
||||
// Twit has promise support; you can use the callback API,
|
||||
// promise API, or both at the same time.
|
||||
//
|
||||
T.get('account/verify_credentials', { skip_status: true })
|
||||
.catch(function (err) {
|
||||
console.log('caught error', err.stack)
|
||||
})
|
||||
.then(function (result) {
|
||||
// `result` is an Object with keys "data" and "resp".
|
||||
// `data` and `resp` are the same objects as the ones passed
|
||||
// to the callback.
|
||||
// See https://github.com/ttezel/twit#tgetpath-params-callback
|
||||
// for details.
|
||||
|
||||
console.log('data', result.data);
|
||||
})
|
||||
|
||||
//
|
||||
// retweet a tweet with id '343360866131001345'
|
||||
//
|
||||
T.post('statuses/retweet/:id', { id: '343360866131001345' }, function (err, data, response) {
|
||||
console.log(data)
|
||||
})
|
||||
|
||||
//
|
||||
// destroy a tweet with id '343360866131001345'
|
||||
//
|
||||
T.post('statuses/destroy/:id', { id: '343360866131001345' }, function (err, data, response) {
|
||||
console.log(data)
|
||||
})
|
||||
|
||||
//
|
||||
// get `funny` twitter users
|
||||
//
|
||||
T.get('users/suggestions/:slug', { slug: 'funny' }, function (err, data, response) {
|
||||
console.log(data)
|
||||
})
|
||||
|
||||
//
|
||||
// post a tweet with media
|
||||
//
|
||||
var b64content = fs.readFileSync('/path/to/img', { encoding: 'base64' })
|
||||
|
||||
// first we must post the media to Twitter
|
||||
T.post('media/upload', { media_data: b64content }, function (err, data, response) {
|
||||
// now we can assign alt text to the media, for use by screen readers and
|
||||
// other text-based presentations and interpreters
|
||||
var mediaIdStr = data.media_id_string
|
||||
var altText = "Small flowers in a planter on a sunny balcony, blossoming."
|
||||
var meta_params = { media_id: mediaIdStr, alt_text: { text: altText } }
|
||||
|
||||
T.post('media/metadata/create', meta_params, function (err, data, response) {
|
||||
if (!err) {
|
||||
// now we can reference the media and post a tweet (media will attach to the tweet)
|
||||
var params = { status: 'loving life #nofilter', media_ids: [mediaIdStr] }
|
||||
|
||||
T.post('statuses/update', params, function (err, data, response) {
|
||||
console.log(data)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
//
|
||||
// post media via the chunked media upload API.
|
||||
// You can then use POST statuses/update to post a tweet with the media attached as in the example above using `media_id_string`.
|
||||
// Note: You can also do this yourself manually using T.post() calls if you want more fine-grained
|
||||
// control over the streaming. Example: https://github.com/ttezel/twit/blob/master/tests/rest_chunked_upload.js#L20
|
||||
//
|
||||
var filePath = '/absolute/path/to/file.mp4'
|
||||
T.postMediaChunked({ file_path: filePath }, function (err, data, response) {
|
||||
console.log(data)
|
||||
})
|
||||
|
||||
//
|
||||
// stream a sample of public statuses
|
||||
//
|
||||
var stream = T.stream('statuses/sample')
|
||||
|
||||
stream.on('tweet', function (tweet) {
|
||||
console.log(tweet)
|
||||
})
|
||||
|
||||
//
|
||||
// filter the twitter public stream by the word 'mango'.
|
||||
//
|
||||
var stream = T.stream('statuses/filter', { track: 'mango' })
|
||||
|
||||
stream.on('tweet', function (tweet) {
|
||||
console.log(tweet)
|
||||
})
|
||||
|
||||
//
|
||||
// filter the public stream by the latitude/longitude bounded box of San Francisco
|
||||
//
|
||||
var sanFrancisco = [ '-122.75', '36.8', '-121.75', '37.8' ]
|
||||
|
||||
var stream = T.stream('statuses/filter', { locations: sanFrancisco })
|
||||
|
||||
stream.on('tweet', function (tweet) {
|
||||
console.log(tweet)
|
||||
})
|
||||
|
||||
//
|
||||
// filter the public stream by english tweets containing `#apple`
|
||||
//
|
||||
var stream = T.stream('statuses/filter', { track: '#apple', language: 'en' })
|
||||
|
||||
stream.on('tweet', function (tweet) {
|
||||
console.log(tweet)
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
# twit API:
|
||||
|
||||
##`var T = new Twit(config)`
|
||||
|
||||
Create a `Twit` instance that can be used to make requests to Twitter's APIs.
|
||||
|
||||
If authenticating with user context, `config` should be an object of the form:
|
||||
```
|
||||
{
|
||||
consumer_key: '...'
|
||||
, consumer_secret: '...'
|
||||
, access_token: '...'
|
||||
, access_token_secret: '...'
|
||||
}
|
||||
```
|
||||
|
||||
If authenticating with application context, `config` should be an object of the form:
|
||||
```
|
||||
{
|
||||
consumer_key: '...'
|
||||
, consumer_secret: '...'
|
||||
, app_only_auth: true
|
||||
}
|
||||
```
|
||||
Note that Application-only auth will not allow you to perform requests to API endpoints requiring
|
||||
a user context, such as posting tweets. However, the endpoints available can have a higher rate limit.
|
||||
|
||||
##`T.get(path, [params], callback)`
|
||||
GET any of the REST API endpoints.
|
||||
|
||||
**path**
|
||||
|
||||
The endpoint to hit. When specifying `path` values, omit the **'.json'** at the end (i.e. use **'search/tweets'** instead of **'search/tweets.json'**).
|
||||
|
||||
**params**
|
||||
|
||||
(Optional) parameters for the request.
|
||||
|
||||
**callback**
|
||||
|
||||
`function (err, data, response)`
|
||||
|
||||
- `data` is the parsed data received from Twitter.
|
||||
- `response` is the [http.IncomingMessage](http://nodejs.org/api/http.html#http_http_incomingmessage) received from Twitter.
|
||||
|
||||
##`T.post(path, [params], callback)`
|
||||
|
||||
POST any of the REST API endpoints. Same usage as `T.get()`.
|
||||
|
||||
##`T.postMediaChunked(params, callback)`
|
||||
|
||||
Helper function to post media via the POST media/upload (chunked) API. `params` is an object containing a `file_path` key. `file_path` is the absolute path to the file you want to upload.
|
||||
|
||||
```js
|
||||
var filePath = '/absolute/path/to/file.mp4'
|
||||
T.postMediaChunked({ file_path: filePath }, function (err, data, response) {
|
||||
console.log(data)
|
||||
})
|
||||
```
|
||||
|
||||
You can also use the POST media/upload API via T.post() calls if you want more fine-grained control over the streaming; [see here for an example](https://github.com/ttezel/twit/blob/master/tests/rest_chunked_upload.js#L20).
|
||||
|
||||
##`T.getAuth()`
|
||||
Get the client's authentication tokens.
|
||||
|
||||
##`T.setAuth(tokens)`
|
||||
Update the client's authentication tokens.
|
||||
|
||||
##`T.stream(path, [params])`
|
||||
Use this with the Streaming API.
|
||||
|
||||
**path**
|
||||
|
||||
Streaming endpoint to hit. One of:
|
||||
|
||||
- **'statuses/filter'**
|
||||
- **'statuses/sample'**
|
||||
- **'statuses/firehose'**
|
||||
- **'user'**
|
||||
- **'site'**
|
||||
|
||||
For a description of each Streaming endpoint, see the [Twitter API docs](https://dev.twitter.com/streaming/overview).
|
||||
|
||||
**params**
|
||||
|
||||
(Optional) parameters for the request. Any Arrays passed in `params` get converted to comma-separated strings, allowing you to do requests like:
|
||||
|
||||
```javascript
|
||||
//
|
||||
// I only want to see tweets about my favorite fruits
|
||||
//
|
||||
|
||||
// same result as doing { track: 'bananas,oranges,strawberries' }
|
||||
var stream = T.stream('statuses/filter', { track: ['bananas', 'oranges', 'strawberries'] })
|
||||
|
||||
stream.on('tweet', function (tweet) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
# Using the Streaming API
|
||||
|
||||
`T.stream(path, [params])` keeps the connection alive, and returns an `EventEmitter`.
|
||||
|
||||
The following events are emitted:
|
||||
|
||||
##event: 'message'
|
||||
|
||||
Emitted each time an object is received in the stream. This is a catch-all event that can be used to process any data received in the stream, rather than using the more specific events documented below.
|
||||
New in version 2.1.0.
|
||||
|
||||
```javascript
|
||||
stream.on('message', function (msg) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'tweet'
|
||||
|
||||
Emitted each time a status (tweet) comes into the stream.
|
||||
|
||||
```javascript
|
||||
stream.on('tweet', function (tweet) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'delete'
|
||||
|
||||
Emitted each time a status (tweet) deletion message comes into the stream.
|
||||
|
||||
```javascript
|
||||
stream.on('delete', function (deleteMessage) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'limit'
|
||||
|
||||
Emitted each time a limitation message comes into the stream.
|
||||
|
||||
```javascript
|
||||
stream.on('limit', function (limitMessage) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'scrub_geo'
|
||||
|
||||
Emitted each time a location deletion message comes into the stream.
|
||||
|
||||
```javascript
|
||||
stream.on('scrub_geo', function (scrubGeoMessage) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'disconnect'
|
||||
|
||||
Emitted when a disconnect message comes from Twitter. This occurs if you have multiple streams connected to Twitter's API. Upon receiving a disconnect message from Twitter, `Twit` will close the connection and emit this event with the message details received from twitter.
|
||||
|
||||
```javascript
|
||||
stream.on('disconnect', function (disconnectMessage) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'connect'
|
||||
|
||||
Emitted when a connection attempt is made to Twitter. The http `request` object is emitted.
|
||||
|
||||
```javascript
|
||||
stream.on('connect', function (request) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'connected'
|
||||
|
||||
Emitted when the response is received from Twitter. The http `response` object is emitted.
|
||||
|
||||
```javascript
|
||||
stream.on('connected', function (response) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'reconnect'
|
||||
|
||||
Emitted when a reconnection attempt to Twitter is scheduled. If Twitter is having problems or we get rate limited, we schedule a reconnect according to Twitter's [reconnection guidelines](https://dev.twitter.com/streaming/overview/connecting). The last http `request` and `response` objects are emitted, along with the time (in milliseconds) left before the reconnect occurs.
|
||||
|
||||
```javascript
|
||||
stream.on('reconnect', function (request, response, connectInterval) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'warning'
|
||||
|
||||
This message is appropriate for clients using high-bandwidth connections, like the firehose. If your connection is falling behind, Twitter will queue messages for you, until your queue fills up, at which point they will disconnect you.
|
||||
|
||||
```javascript
|
||||
stream.on('warning', function (warning) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'status_withheld'
|
||||
|
||||
Emitted when Twitter sends back a `status_withheld` message in the stream. This means that a tweet was withheld in certain countries.
|
||||
|
||||
```javascript
|
||||
stream.on('status_withheld', function (withheldMsg) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'user_withheld'
|
||||
|
||||
Emitted when Twitter sends back a `user_withheld` message in the stream. This means that a Twitter user was withheld in certain countries.
|
||||
|
||||
```javascript
|
||||
stream.on('user_withheld', function (withheldMsg) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'friends'
|
||||
|
||||
Emitted when Twitter sends the ["friends" preamble](https://dev.twitter.com/streaming/overview/messages-types#user_stream_messsages) when connecting to a user stream. This message contains a list of the user's friends, represented as an array of user ids. If the [stringify_friend_ids](https://dev.twitter.com/streaming/overview/request-parameters#stringify_friend_id) parameter is set, the friends
|
||||
list preamble will be returned as Strings (instead of Numbers).
|
||||
|
||||
```javascript
|
||||
var stream = T.stream('user', { stringify_friend_ids: true })
|
||||
stream.on('friends', function (friendsMsg) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'direct_message'
|
||||
|
||||
Emitted when a direct message is sent to the user. Unfortunately, Twitter has not documented this event for user streams.
|
||||
|
||||
```javascript
|
||||
stream.on('direct_message', function (directMsg) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'user_event'
|
||||
|
||||
Emitted when Twitter sends back a [User stream event](https://dev.twitter.com/streaming/overview/messages-types#Events_event).
|
||||
See the Twitter docs for more information on each event's structure.
|
||||
|
||||
```javascript
|
||||
stream.on('user_event', function (eventMsg) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
In addition, the following user stream events are provided for you to listen on:
|
||||
|
||||
* `blocked`
|
||||
* `unblocked`
|
||||
* `favorite`
|
||||
* `unfavorite`
|
||||
* `follow`
|
||||
* `unfollow`
|
||||
* `user_update`
|
||||
* `list_created`
|
||||
* `list_destroyed`
|
||||
* `list_updated`
|
||||
* `list_member_added`
|
||||
* `list_member_removed`
|
||||
* `list_user_subscribed`
|
||||
* `list_user_unsubscribed`
|
||||
* `quoted_tweet`
|
||||
* `retweeted_retweet`
|
||||
* `favorited_retweet`
|
||||
* `unknown_user_event` (for an event that doesn't match any of the above)
|
||||
|
||||
###Example:
|
||||
|
||||
```javascript
|
||||
stream.on('favorite', function (event) {
|
||||
//...
|
||||
})
|
||||
```
|
||||
|
||||
##event: 'error'
|
||||
|
||||
Emitted when an API request or response error occurs.
|
||||
An `Error` object is emitted, with properties:
|
||||
|
||||
```js
|
||||
{
|
||||
message: '...', // error message
|
||||
statusCode: '...', // statusCode from Twitter
|
||||
code: '...', // error code from Twitter
|
||||
twitterReply: '...', // raw response data from Twitter
|
||||
allErrors: '...' // array of errors returned from Twitter
|
||||
}
|
||||
```
|
||||
|
||||
##stream.stop()
|
||||
|
||||
Call this function on the stream to stop streaming (closes the connection with Twitter).
|
||||
|
||||
##stream.start()
|
||||
|
||||
Call this function to restart the stream after you called `.stop()` on it.
|
||||
Note: there is no need to call `.start()` to begin streaming. `Twit.stream` calls `.start()` for you.
|
||||
|
||||
-------
|
||||
|
||||
#What do I have access to?
|
||||
|
||||
Anything in the Twitter API:
|
||||
|
||||
* REST API Endpoints: https://dev.twitter.com/rest/public
|
||||
* Public stream endpoints: https://dev.twitter.com/streaming/public
|
||||
* User stream endpoints: https://dev.twitter.com/streaming/userstreams
|
||||
* Site stream endpoints: https://dev.twitter.com/streaming/sitestreams
|
||||
|
||||
-------
|
||||
|
||||
Go here to create an app and get OAuth credentials (if you haven't already): https://dev.twitter.com/apps/new
|
||||
|
||||
#Advanced
|
||||
|
||||
You may specify an array of trusted certificate fingerprints if you want to only trust a specific set of certificates.
|
||||
When an HTTP response is received, it is verified that the certificate was signed, and the peer certificate's fingerprint must be one of the values you specified. By default, the node.js trusted "root" CAs will be used.
|
||||
|
||||
eg.
|
||||
```js
|
||||
var twit = new Twit({
|
||||
consumer_key: '...',
|
||||
consumer_secret: '...',
|
||||
access_token: '...',
|
||||
access_token_secret: '...',
|
||||
trusted_cert_fingerprints: [
|
||||
'66:EA:47:62:D9:B1:4F:1A:AE:89:5F:68:BA:6B:8E:BB:F8:1D:BF:8E',
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
#Contributing
|
||||
|
||||
- Make your changes
|
||||
- Make sure your code matches the style of the code around it
|
||||
- Add tests that cover your feature/bugfix
|
||||
- Run tests
|
||||
- Submit a pull request
|
||||
|
||||
#How do I run the tests?
|
||||
|
||||
Create two files: `config1.js` and `config2.js` at the root of the `twit` folder. They should contain two different sets of oauth credentials for twit to use (two accounts are needed for testing interactions). They should both look something like this:
|
||||
|
||||
```
|
||||
module.exports = {
|
||||
consumer_key: '...'
|
||||
, consumer_secret: '...'
|
||||
, access_token: '...'
|
||||
, access_token_secret: '...'
|
||||
}
|
||||
```
|
||||
|
||||
Then run the tests:
|
||||
|
||||
```
|
||||
npm test
|
||||
```
|
||||
|
||||
You can also run the example:
|
||||
|
||||
```
|
||||
node examples/rtd2.js
|
||||
```
|
||||
|
||||

|
||||
|
||||
The example is a twitter bot named [RTD2](https://twitter.com/#!/iRTD2) written using `twit`. RTD2 tweets about **github** and curates its social graph.
|
||||
|
||||
-------
|
||||
|
||||
[FAQ](https://github.com/ttezel/twit/wiki/FAQ)
|
||||
|
||||
-------
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) by Tolga Tezel <tolgatezel11@gmail.com>
|
||||
|
||||
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.
|
||||
|
||||
## Changelog
|
||||
|
||||
###2.2.2
|
||||
* Emit `parser-error` instead of `error` event if Twitter sends back
|
||||
an uncompressed HTTP response body.
|
||||
|
||||
###2.2.1
|
||||
* Add promise support to Twit REST API calls.
|
||||
|
||||
###2.2.0
|
||||
* Allow omission of `new` keyword; `var t = Twit(config)` works, and `var t = new Twit(config)` works too.
|
||||
* Allow setting an array of trusted certificate fingerprints via `config.trusted_cert_fingerprints`.
|
||||
* Automatically adjust timestamp for OAuth'ed HTTP requests
|
||||
by recording the timestamp from Twitter HTTP responses, computing our local time offset, and applying the offset in the next HTTP request to Twitter.
|
||||
|
||||
###2.1.7
|
||||
* Add `mime` as a dependency.
|
||||
|
||||
###2.1.6
|
||||
* Emit `friends` event for `friends_str` message received when a user stream is requested with `stringify_friend_ids=true`.
|
||||
* Handle receiving "Exceeded connection limit for user" message from Twitter while streaming. Emit `error` event for this case.
|
||||
* Emit `retweeted_retweet` and `favorited_retweet` user events.
|
||||
* Add MIT license to package.json (about time!)
|
||||
|
||||
###2.1.5
|
||||
* Support config-based request timeout.
|
||||
|
||||
###2.1.4
|
||||
* Support POST media/upload (chunked) and add `T.postMediaChunked()` to make it easy.
|
||||
|
||||
###2.1.3
|
||||
* Fix bug in constructing HTTP requests for `account/update_profile_image` and `account/update_profile_background_image` paths.
|
||||
|
||||
###2.1.2
|
||||
* Enable gzip on network traffic
|
||||
* Add `quoted_tweet` event
|
||||
|
||||
###2.1.1
|
||||
* Strict-mode fixes (Twit can now be run with strict mode)
|
||||
* Fix handling of disconect message from Twitter
|
||||
* If Twitter returns a non-JSON-parseable fragment during streaming, emit 'parser-error' instead of 'error' (to discard fragments like "Internal Server Error")
|
||||
|
||||
###2.1.0
|
||||
* Add `message` event.
|
||||
|
||||
###2.0.0
|
||||
* Implement Application-only auth
|
||||
* Remove oauth module as a dependency
|
||||
|
||||
###1.1.20
|
||||
* Implement support for POST /media/upload
|
||||
* Reconnect logic fix for streaming; add stall abort/reconnect timeout on first connection attempt.
|
||||
|
||||
###1.1.14
|
||||
* Emit `connected` event upon receiving the response from twitter
|
||||
|
||||
###1.0.0
|
||||
* now to stop and start the stream, use `stream.stop()` and `stream.start()` instead of emitting the `start` and `stop` events
|
||||
* If twitter sends a `disconnect` message, closes the stream and emits `disconnect` with the disconnect message received from twitter
|
||||
|
||||
###0.2.0
|
||||
* Updated `twit` for usage with v1.1 of the Twitter API.
|
||||
|
||||
###0.1.5
|
||||
|
||||
* **BREAKING CHANGE** to `twit.stream()`. Does not take a callback anymore. It returns
|
||||
immediately with the `EventEmitter` that you can listen on. The `Usage` section in
|
||||
the Readme.md has been updated. Read it.
|
||||
|
||||
|
||||
###0.1.4
|
||||
|
||||
* `twit.stream()` has signature `function (path, params, callback)`
|
||||
127
node_modules/twit/examples/bot.js
generated
vendored
Normal file
127
node_modules/twit/examples/bot.js
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
//
|
||||
// Bot
|
||||
// class for performing various twitter actions
|
||||
//
|
||||
var Twit = require('../lib/twitter');
|
||||
|
||||
var Bot = module.exports = function(config) {
|
||||
this.twit = new Twit(config);
|
||||
};
|
||||
|
||||
//
|
||||
// post a tweet
|
||||
//
|
||||
Bot.prototype.tweet = function (status, callback) {
|
||||
if(typeof status !== 'string') {
|
||||
return callback(new Error('tweet must be of type String'));
|
||||
} else if(status.length > 140) {
|
||||
return callback(new Error('tweet is too long: ' + status.length));
|
||||
}
|
||||
this.twit.post('statuses/update', { status: status }, callback);
|
||||
};
|
||||
|
||||
Bot.prototype.searchFollow = function (params, callback) {
|
||||
var self = this;
|
||||
|
||||
self.twit.get('search/tweets', params, function (err, reply) {
|
||||
if(err) return callback(err);
|
||||
|
||||
var tweets = reply.statuses;
|
||||
var rTweet = randIndex(tweets)
|
||||
if(typeof rTweet != 'undefined')
|
||||
{
|
||||
var target = rTweet.user.id_str;
|
||||
|
||||
self.twit.post('friendships/create', { id: target }, callback);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//
|
||||
// retweet
|
||||
//
|
||||
Bot.prototype.retweet = function (params, callback) {
|
||||
var self = this;
|
||||
|
||||
self.twit.get('search/tweets', params, function (err, reply) {
|
||||
if(err) return callback(err);
|
||||
|
||||
var tweets = reply.statuses;
|
||||
var randomTweet = randIndex(tweets);
|
||||
if(typeof randomTweet != 'undefined')
|
||||
self.twit.post('statuses/retweet/:id', { id: randomTweet.id_str }, callback);
|
||||
});
|
||||
};
|
||||
|
||||
//
|
||||
// favorite a tweet
|
||||
//
|
||||
Bot.prototype.favorite = function (params, callback) {
|
||||
var self = this;
|
||||
|
||||
self.twit.get('search/tweets', params, function (err, reply) {
|
||||
if(err) return callback(err);
|
||||
|
||||
var tweets = reply.statuses;
|
||||
var randomTweet = randIndex(tweets);
|
||||
if(typeof randomTweet != 'undefined')
|
||||
self.twit.post('favorites/create', { id: randomTweet.id_str }, callback);
|
||||
});
|
||||
};
|
||||
|
||||
//
|
||||
// choose a random friend of one of your followers, and follow that user
|
||||
//
|
||||
Bot.prototype.mingle = function (callback) {
|
||||
var self = this;
|
||||
|
||||
this.twit.get('followers/ids', function(err, reply) {
|
||||
if(err) { return callback(err); }
|
||||
|
||||
var followers = reply.ids
|
||||
, randFollower = randIndex(followers);
|
||||
|
||||
self.twit.get('friends/ids', { user_id: randFollower }, function(err, reply) {
|
||||
if(err) { return callback(err); }
|
||||
|
||||
var friends = reply.ids
|
||||
, target = randIndex(friends);
|
||||
|
||||
self.twit.post('friendships/create', { id: target }, callback);
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
//
|
||||
// prune your followers list; unfollow a friend that hasn't followed you back
|
||||
//
|
||||
Bot.prototype.prune = function (callback) {
|
||||
var self = this;
|
||||
|
||||
this.twit.get('followers/ids', function(err, reply) {
|
||||
if(err) return callback(err);
|
||||
|
||||
var followers = reply.ids;
|
||||
|
||||
self.twit.get('friends/ids', function(err, reply) {
|
||||
if(err) return callback(err);
|
||||
|
||||
var friends = reply.ids
|
||||
, pruned = false;
|
||||
|
||||
while(!pruned) {
|
||||
var target = randIndex(friends);
|
||||
|
||||
if(!~followers.indexOf(target)) {
|
||||
pruned = true;
|
||||
self.twit.post('friendships/destroy', { id: target }, callback);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function randIndex (arr) {
|
||||
var index = Math.floor(arr.length*Math.random());
|
||||
return arr[index];
|
||||
};
|
||||
77
node_modules/twit/examples/rtd2.js
generated
vendored
Normal file
77
node_modules/twit/examples/rtd2.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// RTD2 - Twitter bot that tweets about the most popular github.com news
|
||||
// Also makes new friends and prunes its followings.
|
||||
//
|
||||
var Bot = require('./bot')
|
||||
, config1 = require('../config1');
|
||||
|
||||
var bot = new Bot(config1);
|
||||
|
||||
console.log('RTD2: Running.');
|
||||
|
||||
//get date string for today's date (e.g. '2011-01-01')
|
||||
function datestring () {
|
||||
var d = new Date(Date.now() - 5*60*60*1000); //est timezone
|
||||
return d.getUTCFullYear() + '-'
|
||||
+ (d.getUTCMonth() + 1) + '-'
|
||||
+ d.getDate();
|
||||
};
|
||||
|
||||
setInterval(function() {
|
||||
bot.twit.get('followers/ids', function(err, reply) {
|
||||
if(err) return handleError(err)
|
||||
console.log('\n# followers:' + reply.ids.length.toString());
|
||||
});
|
||||
var rand = Math.random();
|
||||
|
||||
if(rand <= 0.10) { // tweet popular github tweet
|
||||
var params = {
|
||||
q: 'github.com/'
|
||||
, since: datestring()
|
||||
, result_type: 'mixed'
|
||||
};
|
||||
bot.twit.get('search/tweets', params, function (err, reply) {
|
||||
if(err) return handleError(err);
|
||||
|
||||
var max = 0, popular;
|
||||
|
||||
var tweets = reply.statuses
|
||||
, i = tweets.length;
|
||||
|
||||
while(i--) {
|
||||
var tweet = tweets[i]
|
||||
, popularity = tweet.retweet_count;
|
||||
|
||||
if(popularity > max) {
|
||||
max = popularity;
|
||||
popular = tweet.text;
|
||||
}
|
||||
}
|
||||
|
||||
bot.tweet(popular, function (err, reply) {
|
||||
if(err) return handleError(err);
|
||||
|
||||
console.log('\nTweet: ' + (reply ? reply.text : reply));
|
||||
})
|
||||
});
|
||||
} else if(rand <= 0.55) { // make a friend
|
||||
bot.mingle(function(err, reply) {
|
||||
if(err) return handleError(err);
|
||||
|
||||
var name = reply.screen_name;
|
||||
console.log('\nMingle: followed @' + name);
|
||||
});
|
||||
} else { // prune a friend
|
||||
bot.prune(function(err, reply) {
|
||||
if(err) return handleError(err);
|
||||
|
||||
var name = reply.screen_name
|
||||
console.log('\nPrune: unfollowed @'+ name);
|
||||
});
|
||||
}
|
||||
}, 40000);
|
||||
|
||||
function handleError(err) {
|
||||
console.error('response status:', err.statusCode);
|
||||
console.error('data:', err.data);
|
||||
}
|
||||
11
node_modules/twit/lib/endpoints.js
generated
vendored
Normal file
11
node_modules/twit/lib/endpoints.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Twitter Endpoints
|
||||
module.exports = {
|
||||
API_HOST : 'https://api.twitter.com/'
|
||||
, REST_ROOT : 'https://api.twitter.com/1.1/'
|
||||
, PUB_STREAM : 'https://stream.twitter.com/1.1/'
|
||||
, USER_STREAM : 'https://userstream.twitter.com/1.1/'
|
||||
, SITE_STREAM : 'https://sitestream.twitter.com/1.1/'
|
||||
, MEDIA_UPLOAD : 'https://upload.twitter.com/1.1/'
|
||||
, OA_REQ : 'https://api.twitter.com/oauth/request_token'
|
||||
, OA_ACCESS : 'https://api.twitter.com/oauth/access_token'
|
||||
}
|
||||
143
node_modules/twit/lib/file_uploader.js
generated
vendored
Normal file
143
node_modules/twit/lib/file_uploader.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
var mime = require('mime');
|
||||
var util = require('util');
|
||||
|
||||
var MAX_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
||||
var MAX_FILE_CHUNK_BYTES = 5 * 1024 * 1024;
|
||||
|
||||
/**
|
||||
* FileUploader class used to upload a file to twitter via the /media/upload (chunked) API.
|
||||
* Usage:
|
||||
* var fu = new FileUploader({ file_path: '/foo/bar/baz.mp4' }, twit);
|
||||
* fu.upload(function (err, bodyObj, resp) {
|
||||
* console.log(err, bodyObj);
|
||||
* })
|
||||
*
|
||||
* @param {Object} params Object of the form { file_path: String }.
|
||||
* @param {Twit(object)} twit Twit instance.
|
||||
*/
|
||||
var FileUploader = function (params, twit) {
|
||||
assert(params)
|
||||
assert(params.file_path, 'Must specify `file_path` to upload a file. Got: ' + params.file_path + '.')
|
||||
var self = this;
|
||||
self._file_path = params.file_path;
|
||||
self._twit = twit;
|
||||
self._isUploading = false;
|
||||
self._isFileStreamEnded = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a file to Twitter via the /media/upload (chunked) API.
|
||||
*
|
||||
* @param {Function} cb function (err, data, resp)
|
||||
*/
|
||||
FileUploader.prototype.upload = function (cb) {
|
||||
var self = this;
|
||||
|
||||
// Send INIT command with file info and get back a media_id_string we can use to APPEND chunks to it.
|
||||
self._initMedia(function (err, bodyObj, resp) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
} else {
|
||||
var mediaTmpId = bodyObj.media_id_string;
|
||||
var chunkNumber = 0;
|
||||
var mediaFile = fs.createReadStream(self._file_path, { highWatermark: MAX_FILE_CHUNK_BYTES });
|
||||
|
||||
mediaFile.on('data', function (chunk) {
|
||||
// Pause our file stream from emitting `data` events until the upload of this chunk completes.
|
||||
// Any data that becomes available will remain in the internal buffer.
|
||||
mediaFile.pause();
|
||||
self._isUploading = true;
|
||||
|
||||
self._appendMedia(mediaTmpId, chunk.toString('base64'), chunkNumber, function (err, bodyObj, resp) {
|
||||
self._isUploading = false;
|
||||
if (err) {
|
||||
cb(err);
|
||||
} else {
|
||||
if (self._isUploadComplete()) {
|
||||
// We've hit the end of our stream; send FINALIZE command.
|
||||
self._finalizeMedia(mediaTmpId, cb);
|
||||
} else {
|
||||
// Tell our file stream to start emitting `data` events again.
|
||||
chunkNumber++;
|
||||
mediaFile.resume();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
mediaFile.on('end', function () {
|
||||
// Mark our file streaming complete, and if done, send FINALIZE command.
|
||||
self._isFileStreamEnded = true;
|
||||
if (self._isUploadComplete()) {
|
||||
self._finalizeMedia(mediaTmpId, cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
FileUploader.prototype._isUploadComplete = function () {
|
||||
return !this._isUploading && this._isFileStreamEnded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send FINALIZE command for media object with id `media_id`.
|
||||
*
|
||||
* @param {String} media_id
|
||||
* @param {Function} cb
|
||||
*/
|
||||
FileUploader.prototype._finalizeMedia = function(media_id, cb) {
|
||||
var self = this;
|
||||
self._twit.post('media/upload', {
|
||||
command: 'FINALIZE',
|
||||
media_id: media_id
|
||||
}, cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send APPEND command for media object with id `media_id`.
|
||||
* Append the chunk to the media object, then resume streaming our mediaFile.
|
||||
*
|
||||
* @param {String} media_id media_id_string received from Twitter after sending INIT comand.
|
||||
* @param {String} chunk_part Base64-encoded String chunk of the media file.
|
||||
* @param {Number} segment_index Index of the segment.
|
||||
* @param {Function} cb
|
||||
*/
|
||||
FileUploader.prototype._appendMedia = function(media_id_string, chunk_part, segment_index, cb) {
|
||||
var self = this;
|
||||
self._twit.post('media/upload', {
|
||||
command: 'APPEND',
|
||||
media_id: media_id_string.toString(),
|
||||
segment_index: segment_index,
|
||||
media: chunk_part,
|
||||
}, cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send INIT command for our underlying media object.
|
||||
*
|
||||
* @param {Function} cb
|
||||
*/
|
||||
FileUploader.prototype._initMedia = function (cb) {
|
||||
var self = this;
|
||||
var mediaType = mime.lookup(self._file_path);
|
||||
var mediaFileSizeBytes = fs.statSync(self._file_path).size;
|
||||
|
||||
// Check the file size - it should not go over 15MB for video.
|
||||
// See https://dev.twitter.com/rest/reference/post/media/upload-chunked
|
||||
if (mediaFileSizeBytes < MAX_FILE_SIZE_BYTES) {
|
||||
self._twit.post('media/upload', {
|
||||
'command': 'INIT',
|
||||
'media_type': mediaType,
|
||||
'total_bytes': mediaFileSizeBytes
|
||||
}, cb);
|
||||
} else {
|
||||
var errMsg = util.format('This file is too large. Max size is %dB. Got: %dB.', MAX_FILE_SIZE_BYTES, mediaFileSizeBytes);
|
||||
cb(new Error(errMsg));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = FileUploader
|
||||
128
node_modules/twit/lib/helpers.js
generated
vendored
Normal file
128
node_modules/twit/lib/helpers.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
var querystring = require('querystring');
|
||||
var request = require('request');
|
||||
|
||||
var endpoints = require('./endpoints');
|
||||
|
||||
/**
|
||||
* Encodes object as a querystring, to be used as the suffix of request URLs.
|
||||
* @param {Object} obj
|
||||
* @return {String}
|
||||
*/
|
||||
exports.makeQueryString = function (obj) {
|
||||
var qs = querystring.stringify(obj)
|
||||
qs = qs.replace(/\!/g, "%21")
|
||||
.replace(/\'/g, "%27")
|
||||
.replace(/\(/g, "%28")
|
||||
.replace(/\)/g, "%29")
|
||||
.replace(/\*/g, "%2A");
|
||||
return qs
|
||||
}
|
||||
|
||||
/**
|
||||
* For each `/:param` fragment in path, move the value in params
|
||||
* at that key to path. If the key is not found in params, throw.
|
||||
* Modifies both params and path values.
|
||||
*
|
||||
* @param {Objet} params Object used to build path.
|
||||
* @param {String} path String to transform.
|
||||
* @return {Undefined}
|
||||
*
|
||||
*/
|
||||
exports.moveParamsIntoPath = function (params, path) {
|
||||
var rgxParam = /\/:(\w+)/g
|
||||
var missingParamErr = null
|
||||
|
||||
path = path.replace(rgxParam, function (hit) {
|
||||
var paramName = hit.slice(2)
|
||||
var suppliedVal = params[paramName]
|
||||
if (!suppliedVal) {
|
||||
throw new Error('Twit: Params object is missing a required parameter for this request: `'+paramName+'`')
|
||||
}
|
||||
var retVal = '/' + suppliedVal
|
||||
delete params[paramName]
|
||||
return retVal
|
||||
})
|
||||
return path
|
||||
}
|
||||
|
||||
/**
|
||||
* When Twitter returns a response that looks like an error response,
|
||||
* use this function to attach the error info in the response body to `err`.
|
||||
*
|
||||
* @param {Error} err Error instance to which body info will be attached
|
||||
* @param {Object} body JSON object that is the deserialized HTTP response body received from Twitter
|
||||
* @return {Undefined}
|
||||
*/
|
||||
exports.attachBodyInfoToError = function (err, body) {
|
||||
err.twitterReply = body;
|
||||
if (!body) {
|
||||
return
|
||||
}
|
||||
if (body.error) {
|
||||
// the body itself is an error object
|
||||
err.message = body.error
|
||||
err.allErrors = err.allErrors.concat([body])
|
||||
} else if (body.errors && body.errors.length) {
|
||||
// body contains multiple error objects
|
||||
err.message = body.errors[0].message;
|
||||
err.code = body.errors[0].code;
|
||||
err.allErrors = err.allErrors.concat(body.errors)
|
||||
}
|
||||
}
|
||||
|
||||
exports.makeTwitError = function (message) {
|
||||
var err = new Error()
|
||||
if (message) {
|
||||
err.message = message
|
||||
}
|
||||
err.code = null
|
||||
err.allErrors = []
|
||||
err.twitterReply = null
|
||||
return err
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a bearer token for OAuth2
|
||||
* @param {String} consumer_key
|
||||
* @param {String} consumer_secret
|
||||
* @param {Function} cb
|
||||
*
|
||||
* Calls `cb` with Error, String
|
||||
*
|
||||
* Error (if it exists) is guaranteed to be Twit error-formatted.
|
||||
* String (if it exists) is the bearer token received from Twitter.
|
||||
*/
|
||||
exports.getBearerToken = function (consumer_key, consumer_secret, cb) {
|
||||
// use OAuth 2 for app-only auth (Twitter requires this)
|
||||
// get a bearer token using our app's credentials
|
||||
var b64Credentials = new Buffer(consumer_key + ':' + consumer_secret).toString('base64');
|
||||
request.post({
|
||||
url: endpoints.API_HOST + '/oauth2/token',
|
||||
headers: {
|
||||
'Authorization': 'Basic ' + b64Credentials,
|
||||
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
},
|
||||
body: 'grant_type=client_credentials',
|
||||
json: true,
|
||||
}, function (err, res, body) {
|
||||
if (err) {
|
||||
var error = exports.makeTwitError(err.toString());
|
||||
exports.attachBodyInfoToError(error, body);
|
||||
return cb(error, body, res);
|
||||
}
|
||||
|
||||
if ( !body ) {
|
||||
var error = exports.makeTwitError('Not valid reply from Twitter upon obtaining bearer token');
|
||||
exports.attachBodyInfoToError(error, body);
|
||||
return cb(error, body, res);
|
||||
}
|
||||
|
||||
if (body.token_type !== 'bearer') {
|
||||
var error = exports.makeTwitError('Unexpected reply from Twitter upon obtaining bearer token');
|
||||
exports.attachBodyInfoToError(error, body);
|
||||
return cb(error, body, res);
|
||||
}
|
||||
|
||||
return cb(err, body.access_token);
|
||||
})
|
||||
}
|
||||
56
node_modules/twit/lib/parser.js
generated
vendored
Normal file
56
node_modules/twit/lib/parser.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// Parser - for Twitter Streaming API
|
||||
//
|
||||
var util = require('util')
|
||||
, EventEmitter = require('events').EventEmitter;
|
||||
|
||||
var Parser = module.exports = function () {
|
||||
this.message = ''
|
||||
|
||||
EventEmitter.call(this);
|
||||
};
|
||||
|
||||
util.inherits(Parser, EventEmitter);
|
||||
|
||||
Parser.prototype.parse = function (chunk) {
|
||||
this.message += chunk;
|
||||
chunk = this.message;
|
||||
|
||||
var size = chunk.length
|
||||
, start = 0
|
||||
, offset = 0
|
||||
, curr
|
||||
, next;
|
||||
|
||||
while (offset < size) {
|
||||
curr = chunk[offset];
|
||||
next = chunk[offset + 1];
|
||||
|
||||
if (curr === '\r' && next === '\n') {
|
||||
var piece = chunk.slice(start, offset);
|
||||
start = offset += 2;
|
||||
|
||||
if (!piece.length) { continue; } //empty object
|
||||
|
||||
if (piece === 'Exceeded connection limit for user') {
|
||||
this.emit('connection-limit-exceeded',
|
||||
new Error('Twitter says: ' + piece + '. Only instantiate one stream per set of credentials.'));
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
var msg = JSON.parse(piece)
|
||||
} catch (err) {
|
||||
this.emit('error', new Error('Error parsing twitter reply: `'+piece+'`, error message `'+err+'`'));
|
||||
} finally {
|
||||
if (msg)
|
||||
this.emit('element', msg)
|
||||
|
||||
continue
|
||||
}
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
|
||||
this.message = chunk.slice(start, size);
|
||||
};
|
||||
2
node_modules/twit/lib/settings.js
generated
vendored
Normal file
2
node_modules/twit/lib/settings.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// set of status codes where we don't attempt reconnecting to Twitter
|
||||
exports.STATUS_CODES_TO_ABORT_ON = [ 400, 401, 403, 404, 406, 410, 422 ];
|
||||
358
node_modules/twit/lib/streaming-api-connection.js
generated
vendored
Normal file
358
node_modules/twit/lib/streaming-api-connection.js
generated
vendored
Normal file
@@ -0,0 +1,358 @@
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util');
|
||||
|
||||
var helpers = require('./helpers')
|
||||
var Parser = require('./parser');
|
||||
var request = require('request');
|
||||
var zlib = require('zlib');
|
||||
|
||||
var STATUS_CODES_TO_ABORT_ON = require('./settings').STATUS_CODES_TO_ABORT_ON
|
||||
|
||||
var StreamingAPIConnection = function (reqOpts, twitOptions) {
|
||||
this.reqOpts = reqOpts
|
||||
this.twitOptions = twitOptions
|
||||
this._twitter_time_minus_local_time_ms = 0
|
||||
EventEmitter.call(this)
|
||||
}
|
||||
|
||||
util.inherits(StreamingAPIConnection, EventEmitter)
|
||||
|
||||
/**
|
||||
* Resets the connection.
|
||||
* - clears request, response, parser
|
||||
* - removes scheduled reconnect handle (if one was scheduled)
|
||||
* - stops the stall abort timeout handle (if one was scheduled)
|
||||
*/
|
||||
StreamingAPIConnection.prototype._resetConnection = function () {
|
||||
if (this.request) {
|
||||
// clear our reference to the `request` instance
|
||||
this.request.removeAllListeners();
|
||||
this.request.destroy();
|
||||
}
|
||||
|
||||
if (this.response) {
|
||||
// clear our reference to the http.IncomingMessage instance
|
||||
this.response.removeAllListeners();
|
||||
this.response.destroy();
|
||||
}
|
||||
|
||||
if (this.parser) {
|
||||
this.parser.removeAllListeners()
|
||||
}
|
||||
|
||||
// ensure a scheduled reconnect does not occur (if one was scheduled)
|
||||
// this can happen if we get a close event before .stop() is called
|
||||
clearTimeout(this._scheduledReconnect)
|
||||
delete this._scheduledReconnect
|
||||
|
||||
// clear our stall abort timeout
|
||||
this._stopStallAbortTimeout()
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the parameters used in determining the next reconnect time
|
||||
*/
|
||||
StreamingAPIConnection.prototype._resetRetryParams = function () {
|
||||
// delay for next reconnection attempt
|
||||
this._connectInterval = 0
|
||||
// flag indicating whether we used a 0-delay reconnect
|
||||
this._usedFirstReconnect = false
|
||||
}
|
||||
|
||||
StreamingAPIConnection.prototype._startPersistentConnection = function () {
|
||||
var self = this;
|
||||
self._resetConnection();
|
||||
self._setupParser();
|
||||
self._resetStallAbortTimeout();
|
||||
self._setOauthTimestamp();
|
||||
self.request = request.post(this.reqOpts);
|
||||
self.emit('connect', self.request);
|
||||
self.request.on('response', function (response) {
|
||||
self._updateOauthTimestampOffsetFromResponse(response)
|
||||
// reset our reconnection attempt flag so next attempt goes through with 0 delay
|
||||
// if we get a transport-level error
|
||||
self._usedFirstReconnect = false;
|
||||
// start a stall abort timeout handle
|
||||
self._resetStallAbortTimeout();
|
||||
self.response = response
|
||||
if (STATUS_CODES_TO_ABORT_ON.indexOf(self.response.statusCode) !== -1) {
|
||||
// We got a status code telling us we should abort the connection.
|
||||
// Read the body from the response and return an error to the user.
|
||||
var body = '';
|
||||
var compressedBody = '';
|
||||
|
||||
self.response.on('data', function (chunk) {
|
||||
compressedBody += chunk.toString('utf8');
|
||||
})
|
||||
|
||||
var gunzip = zlib.createGunzip();
|
||||
self.response.pipe(gunzip);
|
||||
gunzip.on('data', function (chunk) {
|
||||
body += chunk.toString('utf8')
|
||||
})
|
||||
|
||||
gunzip.on('end', function () {
|
||||
try {
|
||||
body = JSON.parse(body)
|
||||
} catch (jsonDecodeError) {
|
||||
// Twitter may send an HTML body
|
||||
// if non-JSON text was returned, we'll just attach it to the error as-is
|
||||
}
|
||||
// surface the error to the user
|
||||
var error = helpers.makeTwitError('Bad Twitter streaming request: ' + self.response.statusCode)
|
||||
error.statusCode = response ? response.statusCode: null;
|
||||
helpers.attachBodyInfoToError(error, body)
|
||||
self.emit('error', error);
|
||||
// stop the stream explicitly so we don't reconnect
|
||||
self.stop()
|
||||
body = null;
|
||||
});
|
||||
gunzip.on('error', function (err) {
|
||||
// If Twitter sends us back an uncompressed HTTP response, gzip will error out.
|
||||
// Handle this by emitting an error with the uncompressed response body.
|
||||
var errMsg = 'Gzip error: ' + err.message;
|
||||
var twitErr = helpers.makeTwitError(errMsg);
|
||||
twitErr.statusCode = self.response.statusCode;
|
||||
helpers.attachBodyInfoToError(twitErr, compressedBody);
|
||||
self.emit('parser-error', twitErr);
|
||||
});
|
||||
} else if (self.response.statusCode === 420) {
|
||||
// close the connection forcibly so a reconnect is scheduled by `self.onClose()`
|
||||
self._scheduleReconnect();
|
||||
} else {
|
||||
// We got an OK status code - the response should be valid.
|
||||
// Read the body from the response and return to the user.
|
||||
var gunzip = zlib.createGunzip();
|
||||
self.response.pipe(gunzip);
|
||||
|
||||
//pass all response data to parser
|
||||
gunzip.on('data', function (chunk) {
|
||||
self._connectInterval = 0
|
||||
// stop stall timer, and start a new one
|
||||
self._resetStallAbortTimeout();
|
||||
self.parser.parse(chunk.toString('utf8'));
|
||||
});
|
||||
|
||||
gunzip.on('close', self._onClose.bind(self))
|
||||
gunzip.on('error', function (err) {
|
||||
self.emit('error', err);
|
||||
})
|
||||
self.response.on('error', function (err) {
|
||||
// expose response errors on twit instance
|
||||
self.emit('error', err);
|
||||
})
|
||||
|
||||
// connected without an error response from Twitter, emit `connected` event
|
||||
// this must be emitted after all its event handlers are bound
|
||||
// so the reference to `self.response` is not interfered-with by the user until it is emitted
|
||||
self.emit('connected', self.response);
|
||||
}
|
||||
});
|
||||
self.request.on('close', self._onClose.bind(self));
|
||||
self.request.on('error', function (err) { self._scheduleReconnect.bind(self) });
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle when the request or response closes.
|
||||
* Schedule a reconnect according to Twitter's reconnect guidelines
|
||||
*
|
||||
*/
|
||||
StreamingAPIConnection.prototype._onClose = function () {
|
||||
var self = this;
|
||||
self._stopStallAbortTimeout();
|
||||
if (self._scheduledReconnect) {
|
||||
// if we already have a reconnect scheduled, don't schedule another one.
|
||||
// this race condition can happen if the http.ClientRequest and http.IncomingMessage both emit `close`
|
||||
return
|
||||
}
|
||||
|
||||
self._scheduleReconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Kick off the http request, and persist the connection
|
||||
*
|
||||
*/
|
||||
StreamingAPIConnection.prototype.start = function () {
|
||||
this._resetRetryParams();
|
||||
this._startPersistentConnection();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abort the http request, stop scheduled reconnect (if one was scheduled) and clear state
|
||||
*
|
||||
*/
|
||||
StreamingAPIConnection.prototype.stop = function () {
|
||||
// clear connection variables and timeout handles
|
||||
this._resetConnection();
|
||||
this._resetRetryParams();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop and restart the stall abort timer (called when new data is received)
|
||||
*
|
||||
* If we go 90s without receiving data from twitter, we abort the request & reconnect.
|
||||
*/
|
||||
StreamingAPIConnection.prototype._resetStallAbortTimeout = function () {
|
||||
var self = this;
|
||||
// stop the previous stall abort timer
|
||||
self._stopStallAbortTimeout();
|
||||
//start a new 90s timeout to trigger a close & reconnect if no data received
|
||||
self._stallAbortTimeout = setTimeout(function () {
|
||||
self._scheduleReconnect()
|
||||
}, 90000);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop stall timeout
|
||||
*
|
||||
*/
|
||||
StreamingAPIConnection.prototype._stopStallAbortTimeout = function () {
|
||||
clearTimeout(this._stallAbortTimeout);
|
||||
// mark the timer as `null` so it is clear via introspection that the timeout is not scheduled
|
||||
delete this._stallAbortTimeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the next time a reconnect should occur (based on the last HTTP response received)
|
||||
* and starts a timeout handle to begin reconnecting after `self._connectInterval` passes.
|
||||
*
|
||||
* @return {Undefined}
|
||||
*/
|
||||
StreamingAPIConnection.prototype._scheduleReconnect = function () {
|
||||
var self = this;
|
||||
if (self.response && self.response.statusCode === 420) {
|
||||
// we are being rate limited
|
||||
// start with a 1 minute wait and double each attempt
|
||||
if (!self._connectInterval) {
|
||||
self._connectInterval = 60000;
|
||||
} else {
|
||||
self._connectInterval *= 2;
|
||||
}
|
||||
} else if (self.response && String(self.response.statusCode).charAt(0) === '5') {
|
||||
// twitter 5xx errors
|
||||
// start with a 5s wait, double each attempt up to 320s
|
||||
if (!self._connectInterval) {
|
||||
self._connectInterval = 5000;
|
||||
} else if (self._connectInterval < 320000) {
|
||||
self._connectInterval *= 2;
|
||||
} else {
|
||||
self._connectInterval = 320000;
|
||||
}
|
||||
} else {
|
||||
// we did not get an HTTP response from our last connection attempt.
|
||||
// DNS/TCP error, or a stall in the stream (and stall timer closed the connection)
|
||||
if (!self._usedFirstReconnect) {
|
||||
// first reconnection attempt on a valid connection should occur immediately
|
||||
self._connectInterval = 0;
|
||||
self._usedFirstReconnect = true;
|
||||
} else if (self._connectInterval < 16000) {
|
||||
// linearly increase delay by 250ms up to 16s
|
||||
self._connectInterval += 250;
|
||||
} else {
|
||||
// cap out reconnect interval at 16s
|
||||
self._connectInterval = 16000;
|
||||
}
|
||||
}
|
||||
|
||||
// schedule the reconnect
|
||||
self._scheduledReconnect = setTimeout(function () {
|
||||
self._startPersistentConnection();
|
||||
}, self._connectInterval);
|
||||
self.emit('reconnect', self.request, self.response, self._connectInterval);
|
||||
}
|
||||
|
||||
StreamingAPIConnection.prototype._setupParser = function () {
|
||||
var self = this
|
||||
self.parser = new Parser()
|
||||
|
||||
// handle twitter objects as they come in - emit the generic `message` event
|
||||
// along with the specific event corresponding to the message
|
||||
self.parser.on('element', function (msg) {
|
||||
self.emit('message', msg)
|
||||
|
||||
if (msg.delete) { self.emit('delete', msg) }
|
||||
else if (msg.disconnect) { self._handleDisconnect(msg) }
|
||||
else if (msg.limit) { self.emit('limit', msg) }
|
||||
else if (msg.scrub_geo) { self.emit('scrub_geo', msg) }
|
||||
else if (msg.warning) { self.emit('warning', msg) }
|
||||
else if (msg.status_withheld) { self.emit('status_withheld', msg) }
|
||||
else if (msg.user_withheld) { self.emit('user_withheld', msg) }
|
||||
else if (msg.friends || msg.friends_str) { self.emit('friends', msg) }
|
||||
else if (msg.direct_message) { self.emit('direct_message', msg) }
|
||||
else if (msg.event) {
|
||||
self.emit('user_event', msg)
|
||||
// reference: https://dev.twitter.com/docs/streaming-apis/messages#User_stream_messages
|
||||
var ev = msg.event
|
||||
|
||||
if (ev === 'blocked') { self.emit('blocked', msg) }
|
||||
else if (ev === 'unblocked') { self.emit('unblocked', msg) }
|
||||
else if (ev === 'favorite') { self.emit('favorite', msg) }
|
||||
else if (ev === 'unfavorite') { self.emit('unfavorite', msg) }
|
||||
else if (ev === 'follow') { self.emit('follow', msg) }
|
||||
else if (ev === 'unfollow') { self.emit('unfollow', msg) }
|
||||
else if (ev === 'user_update') { self.emit('user_update', msg) }
|
||||
else if (ev === 'list_created') { self.emit('list_created', msg) }
|
||||
else if (ev === 'list_destroyed') { self.emit('list_destroyed', msg) }
|
||||
else if (ev === 'list_updated') { self.emit('list_updated', msg) }
|
||||
else if (ev === 'list_member_added') { self.emit('list_member_added', msg) }
|
||||
else if (ev === 'list_member_removed') { self.emit('list_member_removed', msg) }
|
||||
else if (ev === 'list_user_subscribed') { self.emit('list_user_subscribed', msg) }
|
||||
else if (ev === 'list_user_unsubscribed') { self.emit('list_user_unsubscribed', msg) }
|
||||
else if (ev === 'quoted_tweet') { self.emit('quoted_tweet', msg) }
|
||||
else if (ev === 'favorited_retweet') { self.emit('favorited_retweet', msg) }
|
||||
else if (ev === 'retweeted_retweet') { self.emit('retweeted_retweet', msg) }
|
||||
else { self.emit('unknown_user_event', msg) }
|
||||
} else { self.emit('tweet', msg) }
|
||||
})
|
||||
|
||||
self.parser.on('error', function (err) {
|
||||
self.emit('parser-error', err)
|
||||
});
|
||||
self.parser.on('connection-limit-exceeded', function (err) {
|
||||
self.emit('error', err);
|
||||
})
|
||||
}
|
||||
|
||||
StreamingAPIConnection.prototype._handleDisconnect = function (twitterMsg) {
|
||||
this.emit('disconnect', twitterMsg);
|
||||
this.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call whenever an http request is about to be made to update
|
||||
* our local timestamp (used for Oauth) to be Twitter's server time.
|
||||
*
|
||||
*/
|
||||
StreamingAPIConnection.prototype._setOauthTimestamp = function () {
|
||||
var self = this;
|
||||
if (self.reqOpts.oauth) {
|
||||
var oauth_ts = Date.now() + self._twitter_time_minus_local_time_ms;
|
||||
self.reqOpts.oauth.timestamp = Math.floor(oauth_ts/1000).toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call whenever an http response is received from Twitter,
|
||||
* to set our local timestamp offset from Twitter's server time.
|
||||
* This is used to set the Oauth timestamp for our next http request
|
||||
* to Twitter (by calling _setOauthTimestamp).
|
||||
*
|
||||
* @param {http.IncomingResponse} resp http response received from Twitter.
|
||||
*/
|
||||
StreamingAPIConnection.prototype._updateOauthTimestampOffsetFromResponse = function (resp) {
|
||||
if (resp && resp.headers && resp.headers.date &&
|
||||
new Date(resp.headers.date).toString() !== 'Invalid Date'
|
||||
) {
|
||||
var twitterTimeMs = new Date(resp.headers.date).getTime()
|
||||
this._twitter_time_minus_local_time_ms = twitterTimeMs - Date.now();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StreamingAPIConnection
|
||||
485
node_modules/twit/lib/twitter.js
generated
vendored
Normal file
485
node_modules/twit/lib/twitter.js
generated
vendored
Normal file
@@ -0,0 +1,485 @@
|
||||
//
|
||||
// Twitter API Wrapper
|
||||
//
|
||||
var assert = require('assert');
|
||||
var Promise = require('bluebird');
|
||||
var request = require('request');
|
||||
var util = require('util');
|
||||
var endpoints = require('./endpoints');
|
||||
var FileUploader = require('./file_uploader');
|
||||
var helpers = require('./helpers');
|
||||
var StreamingAPIConnection = require('./streaming-api-connection');
|
||||
var STATUS_CODES_TO_ABORT_ON = require('./settings').STATUS_CODES_TO_ABORT_ON;
|
||||
|
||||
// config values required for app-only auth
|
||||
var required_for_app_auth = [
|
||||
'consumer_key',
|
||||
'consumer_secret'
|
||||
];
|
||||
|
||||
// config values required for user auth (superset of app-only auth)
|
||||
var required_for_user_auth = required_for_app_auth.concat([
|
||||
'access_token',
|
||||
'access_token_secret'
|
||||
]);
|
||||
|
||||
var FORMDATA_PATHS = [
|
||||
'media/upload',
|
||||
'account/update_profile_image',
|
||||
'account/update_profile_background_image',
|
||||
];
|
||||
|
||||
var JSONPAYLOAD_PATHS = [
|
||||
'media/metadata/create'
|
||||
]
|
||||
|
||||
//
|
||||
// Twitter
|
||||
//
|
||||
var Twitter = function (config) {
|
||||
if (!(this instanceof Twitter)) {
|
||||
return new Twitter(config);
|
||||
}
|
||||
|
||||
var self = this
|
||||
var credentials = {
|
||||
consumer_key : config.consumer_key,
|
||||
consumer_secret : config.consumer_secret,
|
||||
// access_token and access_token_secret only required for user auth
|
||||
access_token : config.access_token,
|
||||
access_token_secret : config.access_token_secret,
|
||||
// flag indicating whether requests should be made with application-only auth
|
||||
app_only_auth : config.app_only_auth,
|
||||
}
|
||||
|
||||
this._validateConfigOrThrow(config);
|
||||
this.config = config;
|
||||
this._twitter_time_minus_local_time_ms = 0;
|
||||
}
|
||||
|
||||
Twitter.prototype.get = function (path, params, callback) {
|
||||
return this.request('GET', path, params, callback)
|
||||
}
|
||||
|
||||
Twitter.prototype.post = function (path, params, callback) {
|
||||
return this.request('POST', path, params, callback)
|
||||
}
|
||||
|
||||
Twitter.prototype.request = function (method, path, params, callback) {
|
||||
var self = this;
|
||||
assert(method == 'GET' || method == 'POST');
|
||||
// if no `params` is specified but a callback is, use default params
|
||||
if (typeof params === 'function') {
|
||||
callback = params
|
||||
params = {}
|
||||
}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
var _returnErrorToUser = function (err) {
|
||||
if (callback && typeof callback === 'function') {
|
||||
callback(err, null, null);
|
||||
}
|
||||
reject(err);
|
||||
}
|
||||
|
||||
self._buildReqOpts(method, path, params, false, function (err, reqOpts) {
|
||||
if (err) {
|
||||
_returnErrorToUser(err);
|
||||
return
|
||||
}
|
||||
|
||||
var twitOptions = (params && params.twit_options) || {};
|
||||
|
||||
process.nextTick(function () {
|
||||
// ensure all HTTP i/o occurs after the user has a chance to bind their event handlers
|
||||
self._doRestApiRequest(reqOpts, twitOptions, method, function (err, parsedBody, resp) {
|
||||
self._updateClockOffsetFromResponse(resp);
|
||||
|
||||
if (self.config.trusted_cert_fingerprints) {
|
||||
if (!resp.socket.authorized) {
|
||||
// The peer certificate was not signed by one of the authorized CA's.
|
||||
var authErrMsg = resp.socket.authorizationError.toString();
|
||||
var err = helpers.makeTwitError('The peer certificate was not signed; ' + authErrMsg);
|
||||
_returnErrorToUser(err);
|
||||
return;
|
||||
}
|
||||
var fingerprint = resp.socket.getPeerCertificate().fingerprint;
|
||||
var trustedFingerprints = self.config.trusted_cert_fingerprints;
|
||||
if (trustedFingerprints.indexOf(fingerprint) === -1) {
|
||||
var errMsg = util.format('Certificate untrusted. Trusted fingerprints are: %s. Got fingerprint: %s.',
|
||||
trustedFingerprints.join(','), fingerprint);
|
||||
var err = new Error(errMsg);
|
||||
_returnErrorToUser(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (callback && typeof callback === 'function') {
|
||||
callback(err, parsedBody, resp);
|
||||
}
|
||||
|
||||
resolve({ data: parsedBody, resp: resp });
|
||||
return;
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads a file to Twitter via the POST media/upload (chunked) API.
|
||||
* Use this as an easier alternative to doing the INIT/APPEND/FINALIZE commands yourself.
|
||||
* Returns the response from the FINALIZE command, or if an error occurs along the way,
|
||||
* the first argument to `cb` will be populated with a non-null Error.
|
||||
*
|
||||
*
|
||||
* `params` is an Object of the form:
|
||||
* {
|
||||
* file_path: String // Absolute path of file to be uploaded.
|
||||
* }
|
||||
*
|
||||
* @param {Object} params options object (described above).
|
||||
* @param {cb} cb callback of the form: function (err, bodyObj, resp)
|
||||
*/
|
||||
Twitter.prototype.postMediaChunked = function (params, cb) {
|
||||
var self = this;
|
||||
try {
|
||||
var fileUploader = new FileUploader(params, self);
|
||||
} catch(err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
fileUploader.upload(cb);
|
||||
}
|
||||
|
||||
Twitter.prototype._updateClockOffsetFromResponse = function (resp) {
|
||||
var self = this;
|
||||
if (resp && resp.headers && resp.headers.date &&
|
||||
new Date(resp.headers.date).toString() !== 'Invalid Date'
|
||||
) {
|
||||
var twitterTimeMs = new Date(resp.headers.date).getTime()
|
||||
self._twitter_time_minus_local_time_ms = twitterTimeMs - Date.now();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds and returns an options object ready to pass to `request()`
|
||||
* @param {String} method "GET" or "POST"
|
||||
* @param {String} path REST API resource uri (eg. "statuses/destroy/:id")
|
||||
* @param {Object} params user's params object
|
||||
* @param {Boolean} isStreaming Flag indicating if it's a request to the Streaming API (different endpoint)
|
||||
* @returns {Undefined}
|
||||
*
|
||||
* Calls `callback` with Error, Object where Object is an options object ready to pass to `request()`.
|
||||
*
|
||||
* Returns error raised (if any) by `helpers.moveParamsIntoPath()`
|
||||
*/
|
||||
Twitter.prototype._buildReqOpts = function (method, path, params, isStreaming, callback) {
|
||||
var self = this
|
||||
if (!params) {
|
||||
params = {}
|
||||
}
|
||||
// clone `params` object so we can modify it without modifying the user's reference
|
||||
var paramsClone = JSON.parse(JSON.stringify(params))
|
||||
// convert any arrays in `paramsClone` to comma-seperated strings
|
||||
var finalParams = this.normalizeParams(paramsClone)
|
||||
delete finalParams.twit_options
|
||||
|
||||
// the options object passed to `request` used to perform the HTTP request
|
||||
var reqOpts = {
|
||||
headers: {
|
||||
'Accept': '*/*',
|
||||
'User-Agent': 'twit-client'
|
||||
},
|
||||
gzip: true,
|
||||
encoding: null,
|
||||
}
|
||||
|
||||
if (typeof self.config.timeout_ms !== 'undefined') {
|
||||
reqOpts.timeout = self.config.timeout_ms;
|
||||
}
|
||||
|
||||
try {
|
||||
// finalize the `path` value by building it using user-supplied params
|
||||
path = helpers.moveParamsIntoPath(finalParams, path)
|
||||
} catch (e) {
|
||||
callback(e, null, null)
|
||||
return
|
||||
}
|
||||
|
||||
if (isStreaming) {
|
||||
// This is a Streaming API request.
|
||||
|
||||
var stream_endpoint_map = {
|
||||
user: endpoints.USER_STREAM,
|
||||
site: endpoints.SITE_STREAM
|
||||
}
|
||||
var endpoint = stream_endpoint_map[path] || endpoints.PUB_STREAM
|
||||
reqOpts.url = endpoint + path + '.json'
|
||||
} else {
|
||||
// This is a REST API request.
|
||||
|
||||
if (path.indexOf('media/') !== -1) {
|
||||
// For media/upload, use a different endpoint.
|
||||
reqOpts.url = endpoints.MEDIA_UPLOAD + path + '.json';
|
||||
} else {
|
||||
reqOpts.url = endpoints.REST_ROOT + path + '.json';
|
||||
}
|
||||
|
||||
if (FORMDATA_PATHS.indexOf(path) !== -1) {
|
||||
reqOpts.headers['Content-type'] = 'multipart/form-data';
|
||||
reqOpts.form = finalParams;
|
||||
// set finalParams to empty object so we don't append a query string
|
||||
// of the params
|
||||
finalParams = {};
|
||||
} else if (JSONPAYLOAD_PATHS.indexOf(path) !== -1) {
|
||||
reqOpts.headers['Content-type'] = 'application/json';
|
||||
reqOpts.json = true;
|
||||
reqOpts.body = finalParams;
|
||||
// as above, to avoid appending query string for body params
|
||||
finalParams = {};
|
||||
} else {
|
||||
reqOpts.headers['Content-type'] = 'application/json';
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(finalParams).length) {
|
||||
// not all of the user's parameters were used to build the request path
|
||||
// add them as a query string
|
||||
var qs = helpers.makeQueryString(finalParams)
|
||||
reqOpts.url += '?' + qs
|
||||
}
|
||||
|
||||
if (!self.config.app_only_auth) {
|
||||
// with user auth, we can just pass an oauth object to requests
|
||||
// to have the request signed
|
||||
var oauth_ts = Date.now() + self._twitter_time_minus_local_time_ms;
|
||||
|
||||
reqOpts.oauth = {
|
||||
consumer_key: self.config.consumer_key,
|
||||
consumer_secret: self.config.consumer_secret,
|
||||
token: self.config.access_token,
|
||||
token_secret: self.config.access_token_secret,
|
||||
timestamp: Math.floor(oauth_ts/1000).toString(),
|
||||
}
|
||||
|
||||
callback(null, reqOpts);
|
||||
return;
|
||||
} else {
|
||||
// we're using app-only auth, so we need to ensure we have a bearer token
|
||||
// Once we have a bearer token, add the Authorization header and return the fully qualified `reqOpts`.
|
||||
self._getBearerToken(function (err, bearerToken) {
|
||||
if (err) {
|
||||
callback(err, null)
|
||||
return
|
||||
}
|
||||
|
||||
reqOpts.headers['Authorization'] = 'Bearer ' + bearerToken;
|
||||
callback(null, reqOpts)
|
||||
return
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make HTTP request to Twitter REST API.
|
||||
* @param {Object} reqOpts options object passed to `request()`
|
||||
* @param {Object} twitOptions
|
||||
* @param {String} method "GET" or "POST"
|
||||
* @param {Function} callback user's callback
|
||||
* @return {Undefined}
|
||||
*/
|
||||
Twitter.prototype._doRestApiRequest = function (reqOpts, twitOptions, method, callback) {
|
||||
var request_method = request[method.toLowerCase()];
|
||||
var req = request_method(reqOpts);
|
||||
|
||||
var body = '';
|
||||
var response = null;
|
||||
|
||||
var onRequestComplete = function () {
|
||||
if (body !== '') {
|
||||
try {
|
||||
body = JSON.parse(body)
|
||||
} catch (jsonDecodeError) {
|
||||
// there was no transport-level error, but a JSON object could not be decoded from the request body
|
||||
// surface this to the caller
|
||||
var err = helpers.makeTwitError('JSON decode error: Twitter HTTP response body was not valid JSON')
|
||||
err.statusCode = response ? response.statusCode: null;
|
||||
err.allErrors.concat({error: jsonDecodeError.toString()})
|
||||
callback(err, body, response);
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof body === 'object' && (body.error || body.errors)) {
|
||||
// we got a Twitter API-level error response
|
||||
// place the errors in the HTTP response body into the Error object and pass control to caller
|
||||
var err = helpers.makeTwitError('Twitter API Error')
|
||||
err.statusCode = response ? response.statusCode: null;
|
||||
helpers.attachBodyInfoToError(err, body);
|
||||
callback(err, body, response);
|
||||
return
|
||||
}
|
||||
|
||||
// success case - no errors in HTTP response body
|
||||
callback(err, body, response)
|
||||
}
|
||||
|
||||
req.on('response', function (res) {
|
||||
response = res
|
||||
// read data from `request` object which contains the decompressed HTTP response body,
|
||||
// `response` is the unmodified http.IncomingMessage object which may contain compressed data
|
||||
req.on('data', function (chunk) {
|
||||
body += chunk.toString('utf8')
|
||||
})
|
||||
// we're done reading the response
|
||||
req.on('end', function () {
|
||||
onRequestComplete()
|
||||
})
|
||||
})
|
||||
|
||||
req.on('error', function (err) {
|
||||
// transport-level error occurred - likely a socket error
|
||||
if (twitOptions.retry &&
|
||||
STATUS_CODES_TO_ABORT_ON.indexOf(err.statusCode) !== -1
|
||||
) {
|
||||
// retry the request since retries were specified and we got a status code we should retry on
|
||||
self.request(method, path, params, callback);
|
||||
return;
|
||||
} else {
|
||||
// pass the transport-level error to the caller
|
||||
err.statusCode = null
|
||||
err.code = null
|
||||
err.allErrors = [];
|
||||
helpers.attachBodyInfoToError(err, body)
|
||||
callback(err, body, response);
|
||||
return;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates/starts a connection object that stays connected to Twitter's servers
|
||||
* using Twitter's rules.
|
||||
*
|
||||
* @param {String} path Resource path to connect to (eg. "statuses/sample")
|
||||
* @param {Object} params user's params object
|
||||
* @return {StreamingAPIConnection} [description]
|
||||
*/
|
||||
Twitter.prototype.stream = function (path, params) {
|
||||
var self = this;
|
||||
var twitOptions = (params && params.twit_options) || {};
|
||||
|
||||
var streamingConnection = new StreamingAPIConnection()
|
||||
self._buildReqOpts('POST', path, params, true, function (err, reqOpts) {
|
||||
if (err) {
|
||||
// we can get an error if we fail to obtain a bearer token or construct reqOpts
|
||||
// surface this on the streamingConnection instance (where a user may register their error handler)
|
||||
streamingConnection.emit('error', err)
|
||||
return
|
||||
}
|
||||
// set the properties required to start the connection
|
||||
streamingConnection.reqOpts = reqOpts
|
||||
streamingConnection.twitOptions = twitOptions
|
||||
|
||||
process.nextTick(function () {
|
||||
streamingConnection.start()
|
||||
})
|
||||
})
|
||||
|
||||
return streamingConnection
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets bearer token from cached reference on `self`, or fetches a new one and sets it on `self`.
|
||||
*
|
||||
* @param {Function} callback Function to invoke with (Error, bearerToken)
|
||||
* @return {Undefined}
|
||||
*/
|
||||
Twitter.prototype._getBearerToken = function (callback) {
|
||||
var self = this;
|
||||
if (self._bearerToken) {
|
||||
return callback(null, self._bearerToken)
|
||||
}
|
||||
|
||||
helpers.getBearerToken(self.config.consumer_key, self.config.consumer_secret,
|
||||
function (err, bearerToken) {
|
||||
if (err) {
|
||||
// return the fully-qualified Twit Error object to caller
|
||||
callback(err, null);
|
||||
return;
|
||||
}
|
||||
self._bearerToken = bearerToken;
|
||||
callback(null, self._bearerToken);
|
||||
return;
|
||||
})
|
||||
}
|
||||
|
||||
Twitter.prototype.normalizeParams = function (params) {
|
||||
var normalized = params
|
||||
if (params && typeof params === 'object') {
|
||||
Object.keys(params).forEach(function (key) {
|
||||
var value = params[key]
|
||||
// replace any arrays in `params` with comma-separated string
|
||||
if (Array.isArray(value))
|
||||
normalized[key] = value.join(',')
|
||||
})
|
||||
} else if (!params) {
|
||||
normalized = {}
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
|
||||
Twitter.prototype.setAuth = function (auth) {
|
||||
var self = this
|
||||
var configKeys = [
|
||||
'consumer_key',
|
||||
'consumer_secret',
|
||||
'access_token',
|
||||
'access_token_secret'
|
||||
];
|
||||
|
||||
// update config
|
||||
configKeys.forEach(function (k) {
|
||||
if (auth[k]) {
|
||||
self.config[k] = auth[k]
|
||||
}
|
||||
})
|
||||
this._validateConfigOrThrow(self.config);
|
||||
}
|
||||
|
||||
Twitter.prototype.getAuth = function () {
|
||||
return this.config
|
||||
}
|
||||
|
||||
//
|
||||
// Check that the required auth credentials are present in `config`.
|
||||
// @param {Object} config Object containing credentials for REST API auth
|
||||
//
|
||||
Twitter.prototype._validateConfigOrThrow = function (config) {
|
||||
//check config for proper format
|
||||
if (typeof config !== 'object') {
|
||||
throw new TypeError('config must be object, got ' + typeof config)
|
||||
}
|
||||
|
||||
if (typeof config.timeout_ms !== 'undefined' && isNaN(Number(config.timeout_ms))) {
|
||||
throw new TypeError('Twit config `timeout_ms` must be a Number. Got: ' + config.timeout_ms + '.');
|
||||
}
|
||||
|
||||
if (config.app_only_auth) {
|
||||
var auth_type = 'app-only auth'
|
||||
var required_keys = required_for_app_auth
|
||||
} else {
|
||||
var auth_type = 'user auth'
|
||||
var required_keys = required_for_user_auth
|
||||
}
|
||||
|
||||
required_keys.forEach(function (req_key) {
|
||||
if (!config[req_key]) {
|
||||
var err_msg = util.format('Twit config must include `%s` when using %s.', req_key, auth_type)
|
||||
throw new Error(err_msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = Twitter
|
||||
1
node_modules/twit/node_modules/.bin/mime
generated
vendored
Symbolic link
1
node_modules/twit/node_modules/.bin/mime
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../mime/cli.js
|
||||
21
node_modules/twit/node_modules/bluebird/LICENSE
generated
vendored
Normal file
21
node_modules/twit/node_modules/bluebird/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2015 Petka Antonov
|
||||
|
||||
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.
|
||||
51
node_modules/twit/node_modules/bluebird/README.md
generated
vendored
Normal file
51
node_modules/twit/node_modules/bluebird/README.md
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<a href="http://promisesaplus.com/">
|
||||
<img src="http://promisesaplus.com/assets/logo-small.png" alt="Promises/A+ logo"
|
||||
title="Promises/A+ 1.1 compliant" align="right" />
|
||||
</a>
|
||||
[](https://travis-ci.org/petkaantonov/bluebird)
|
||||
[](http://petkaantonov.github.io/bluebird/coverage/debug/index.html)
|
||||
|
||||
**Got a question?** Join us on [stackoverflow](http://stackoverflow.com/questions/tagged/bluebird), the [mailing list](https://groups.google.com/forum/#!forum/bluebird-js) or chat on [IRC](https://webchat.freenode.net/?channels=#promises)
|
||||
|
||||
# Introduction
|
||||
|
||||
Bluebird is a fully featured promise library with focus on innovative features and performance
|
||||
|
||||
See the [**bluebird website**](http://bluebirdjs.com/docs/getting-started.html) for further documentation, references and instructions. See the [**API reference**](http://bluebirdjs.com/docs/api-reference.html) here.
|
||||
|
||||
For bluebird 2.x documentation and files, see the [2.x tree](https://github.com/petkaantonov/bluebird/tree/2.x).
|
||||
|
||||
# Questions and issues
|
||||
|
||||
The [github issue tracker](https://github.com/petkaantonov/bluebird/issues) is **_only_** for bug reports and feature requests. Anything else, such as questions for help in using the library, should be posted in [StackOverflow](http://stackoverflow.com/questions/tagged/bluebird) under tags `promise` and `bluebird`.
|
||||
|
||||
|
||||
|
||||
## Thanks
|
||||
|
||||
Thanks to BrowserStack for providing us with a free account which lets us support old browsers like IE8.
|
||||
|
||||
# License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2016 Petka Antonov
|
||||
|
||||
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.
|
||||
|
||||
1
node_modules/twit/node_modules/bluebird/changelog.md
generated
vendored
Normal file
1
node_modules/twit/node_modules/bluebird/changelog.md
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[http://bluebirdjs.com/docs/changelog.html](http://bluebirdjs.com/docs/changelog.html)
|
||||
3654
node_modules/twit/node_modules/bluebird/js/browser/bluebird.core.js
generated
vendored
Normal file
3654
node_modules/twit/node_modules/bluebird/js/browser/bluebird.core.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
31
node_modules/twit/node_modules/bluebird/js/browser/bluebird.core.min.js
generated
vendored
Normal file
31
node_modules/twit/node_modules/bluebird/js/browser/bluebird.core.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5476
node_modules/twit/node_modules/bluebird/js/browser/bluebird.js
generated
vendored
Normal file
5476
node_modules/twit/node_modules/bluebird/js/browser/bluebird.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
31
node_modules/twit/node_modules/bluebird/js/browser/bluebird.min.js
generated
vendored
Normal file
31
node_modules/twit/node_modules/bluebird/js/browser/bluebird.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
21
node_modules/twit/node_modules/bluebird/js/release/any.js
generated
vendored
Normal file
21
node_modules/twit/node_modules/bluebird/js/release/any.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise) {
|
||||
var SomePromiseArray = Promise._SomePromiseArray;
|
||||
function any(promises) {
|
||||
var ret = new SomePromiseArray(promises);
|
||||
var promise = ret.promise();
|
||||
ret.setHowMany(1);
|
||||
ret.setUnwrap();
|
||||
ret.init();
|
||||
return promise;
|
||||
}
|
||||
|
||||
Promise.any = function (promises) {
|
||||
return any(promises);
|
||||
};
|
||||
|
||||
Promise.prototype.any = function () {
|
||||
return any(this);
|
||||
};
|
||||
|
||||
};
|
||||
55
node_modules/twit/node_modules/bluebird/js/release/assert.js
generated
vendored
Normal file
55
node_modules/twit/node_modules/bluebird/js/release/assert.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
module.exports = (function(){
|
||||
var AssertionError = (function() {
|
||||
function AssertionError(a) {
|
||||
this.constructor$(a);
|
||||
this.message = a;
|
||||
this.name = "AssertionError";
|
||||
}
|
||||
AssertionError.prototype = new Error();
|
||||
AssertionError.prototype.constructor = AssertionError;
|
||||
AssertionError.prototype.constructor$ = Error;
|
||||
return AssertionError;
|
||||
})();
|
||||
|
||||
function getParams(args) {
|
||||
var params = [];
|
||||
for (var i = 0; i < args.length; ++i) params.push("arg" + i);
|
||||
return params;
|
||||
}
|
||||
|
||||
function nativeAssert(callName, args, expect) {
|
||||
try {
|
||||
var params = getParams(args);
|
||||
var constructorArgs = params;
|
||||
constructorArgs.push("return " +
|
||||
callName + "("+ params.join(",") + ");");
|
||||
var fn = Function.apply(null, constructorArgs);
|
||||
return fn.apply(null, args);
|
||||
} catch (e) {
|
||||
if (!(e instanceof SyntaxError)) {
|
||||
throw e;
|
||||
} else {
|
||||
return expect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return function assert(boolExpr, message) {
|
||||
if (boolExpr === true) return;
|
||||
|
||||
if (typeof boolExpr === "string" &&
|
||||
boolExpr.charAt(0) === "%") {
|
||||
var nativeCallName = boolExpr;
|
||||
var $_len = arguments.length;var args = new Array(Math.max($_len - 2, 0)); for(var $_i = 2; $_i < $_len; ++$_i) {args[$_i - 2] = arguments[$_i];};
|
||||
if (nativeAssert(nativeCallName, args, message) === message) return;
|
||||
message = (nativeCallName + " !== " + message);
|
||||
}
|
||||
|
||||
var ret = new AssertionError(message);
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(ret, assert);
|
||||
}
|
||||
throw ret;
|
||||
};
|
||||
})();
|
||||
166
node_modules/twit/node_modules/bluebird/js/release/async.js
generated
vendored
Normal file
166
node_modules/twit/node_modules/bluebird/js/release/async.js
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
"use strict";
|
||||
var firstLineError;
|
||||
try {throw new Error(); } catch (e) {firstLineError = e;}
|
||||
var schedule = require("./schedule");
|
||||
var Queue = require("./queue");
|
||||
var util = require("./util");
|
||||
|
||||
function Async() {
|
||||
this._customScheduler = false;
|
||||
this._isTickUsed = false;
|
||||
this._lateQueue = new Queue(16);
|
||||
this._normalQueue = new Queue(16);
|
||||
this._haveDrainedQueues = false;
|
||||
this._trampolineEnabled = true;
|
||||
var self = this;
|
||||
this.drainQueues = function () {
|
||||
self._drainQueues();
|
||||
};
|
||||
this._schedule = schedule;
|
||||
}
|
||||
|
||||
Async.prototype.setScheduler = function(fn) {
|
||||
var prev = this._schedule;
|
||||
this._schedule = fn;
|
||||
this._customScheduler = true;
|
||||
return prev;
|
||||
};
|
||||
|
||||
Async.prototype.hasCustomScheduler = function() {
|
||||
return this._customScheduler;
|
||||
};
|
||||
|
||||
Async.prototype.enableTrampoline = function() {
|
||||
this._trampolineEnabled = true;
|
||||
};
|
||||
|
||||
Async.prototype.disableTrampolineIfNecessary = function() {
|
||||
if (util.hasDevTools) {
|
||||
this._trampolineEnabled = false;
|
||||
}
|
||||
};
|
||||
|
||||
Async.prototype.haveItemsQueued = function () {
|
||||
return this._isTickUsed || this._haveDrainedQueues;
|
||||
};
|
||||
|
||||
|
||||
Async.prototype.fatalError = function(e, isNode) {
|
||||
if (isNode) {
|
||||
process.stderr.write("Fatal " + (e instanceof Error ? e.stack : e) +
|
||||
"\n");
|
||||
process.exit(2);
|
||||
} else {
|
||||
this.throwLater(e);
|
||||
}
|
||||
};
|
||||
|
||||
Async.prototype.throwLater = function(fn, arg) {
|
||||
if (arguments.length === 1) {
|
||||
arg = fn;
|
||||
fn = function () { throw arg; };
|
||||
}
|
||||
if (typeof setTimeout !== "undefined") {
|
||||
setTimeout(function() {
|
||||
fn(arg);
|
||||
}, 0);
|
||||
} else try {
|
||||
this._schedule(function() {
|
||||
fn(arg);
|
||||
});
|
||||
} catch (e) {
|
||||
throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
}
|
||||
};
|
||||
|
||||
function AsyncInvokeLater(fn, receiver, arg) {
|
||||
this._lateQueue.push(fn, receiver, arg);
|
||||
this._queueTick();
|
||||
}
|
||||
|
||||
function AsyncInvoke(fn, receiver, arg) {
|
||||
this._normalQueue.push(fn, receiver, arg);
|
||||
this._queueTick();
|
||||
}
|
||||
|
||||
function AsyncSettlePromises(promise) {
|
||||
this._normalQueue._pushOne(promise);
|
||||
this._queueTick();
|
||||
}
|
||||
|
||||
if (!util.hasDevTools) {
|
||||
Async.prototype.invokeLater = AsyncInvokeLater;
|
||||
Async.prototype.invoke = AsyncInvoke;
|
||||
Async.prototype.settlePromises = AsyncSettlePromises;
|
||||
} else {
|
||||
Async.prototype.invokeLater = function (fn, receiver, arg) {
|
||||
if (this._trampolineEnabled) {
|
||||
AsyncInvokeLater.call(this, fn, receiver, arg);
|
||||
} else {
|
||||
this._schedule(function() {
|
||||
setTimeout(function() {
|
||||
fn.call(receiver, arg);
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Async.prototype.invoke = function (fn, receiver, arg) {
|
||||
if (this._trampolineEnabled) {
|
||||
AsyncInvoke.call(this, fn, receiver, arg);
|
||||
} else {
|
||||
this._schedule(function() {
|
||||
fn.call(receiver, arg);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Async.prototype.settlePromises = function(promise) {
|
||||
if (this._trampolineEnabled) {
|
||||
AsyncSettlePromises.call(this, promise);
|
||||
} else {
|
||||
this._schedule(function() {
|
||||
promise._settlePromises();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Async.prototype.invokeFirst = function (fn, receiver, arg) {
|
||||
this._normalQueue.unshift(fn, receiver, arg);
|
||||
this._queueTick();
|
||||
};
|
||||
|
||||
Async.prototype._drainQueue = function(queue) {
|
||||
while (queue.length() > 0) {
|
||||
var fn = queue.shift();
|
||||
if (typeof fn !== "function") {
|
||||
fn._settlePromises();
|
||||
continue;
|
||||
}
|
||||
var receiver = queue.shift();
|
||||
var arg = queue.shift();
|
||||
fn.call(receiver, arg);
|
||||
}
|
||||
};
|
||||
|
||||
Async.prototype._drainQueues = function () {
|
||||
this._drainQueue(this._normalQueue);
|
||||
this._reset();
|
||||
this._haveDrainedQueues = true;
|
||||
this._drainQueue(this._lateQueue);
|
||||
};
|
||||
|
||||
Async.prototype._queueTick = function () {
|
||||
if (!this._isTickUsed) {
|
||||
this._isTickUsed = true;
|
||||
this._schedule(this.drainQueues);
|
||||
}
|
||||
};
|
||||
|
||||
Async.prototype._reset = function () {
|
||||
this._isTickUsed = false;
|
||||
};
|
||||
|
||||
module.exports = Async;
|
||||
module.exports.firstLineError = firstLineError;
|
||||
67
node_modules/twit/node_modules/bluebird/js/release/bind.js
generated
vendored
Normal file
67
node_modules/twit/node_modules/bluebird/js/release/bind.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL, tryConvertToPromise, debug) {
|
||||
var calledBind = false;
|
||||
var rejectThis = function(_, e) {
|
||||
this._reject(e);
|
||||
};
|
||||
|
||||
var targetRejected = function(e, context) {
|
||||
context.promiseRejectionQueued = true;
|
||||
context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
|
||||
};
|
||||
|
||||
var bindingResolved = function(thisArg, context) {
|
||||
if (((this._bitField & 50397184) === 0)) {
|
||||
this._resolveCallback(context.target);
|
||||
}
|
||||
};
|
||||
|
||||
var bindingRejected = function(e, context) {
|
||||
if (!context.promiseRejectionQueued) this._reject(e);
|
||||
};
|
||||
|
||||
Promise.prototype.bind = function (thisArg) {
|
||||
if (!calledBind) {
|
||||
calledBind = true;
|
||||
Promise.prototype._propagateFrom = debug.propagateFromFunction();
|
||||
Promise.prototype._boundValue = debug.boundValueFunction();
|
||||
}
|
||||
var maybePromise = tryConvertToPromise(thisArg);
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._propagateFrom(this, 1);
|
||||
var target = this._target();
|
||||
ret._setBoundTo(maybePromise);
|
||||
if (maybePromise instanceof Promise) {
|
||||
var context = {
|
||||
promiseRejectionQueued: false,
|
||||
promise: ret,
|
||||
target: target,
|
||||
bindingPromise: maybePromise
|
||||
};
|
||||
target._then(INTERNAL, targetRejected, undefined, ret, context);
|
||||
maybePromise._then(
|
||||
bindingResolved, bindingRejected, undefined, ret, context);
|
||||
ret._setOnCancel(maybePromise);
|
||||
} else {
|
||||
ret._resolveCallback(target);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype._setBoundTo = function (obj) {
|
||||
if (obj !== undefined) {
|
||||
this._bitField = this._bitField | 2097152;
|
||||
this._boundTo = obj;
|
||||
} else {
|
||||
this._bitField = this._bitField & (~2097152);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._isBound = function () {
|
||||
return (this._bitField & 2097152) === 2097152;
|
||||
};
|
||||
|
||||
Promise.bind = function (thisArg, value) {
|
||||
return Promise.resolve(value).bind(thisArg);
|
||||
};
|
||||
};
|
||||
11
node_modules/twit/node_modules/bluebird/js/release/bluebird.js
generated
vendored
Normal file
11
node_modules/twit/node_modules/bluebird/js/release/bluebird.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
var old;
|
||||
if (typeof Promise !== "undefined") old = Promise;
|
||||
function noConflict() {
|
||||
try { if (Promise === bluebird) Promise = old; }
|
||||
catch (e) {}
|
||||
return bluebird;
|
||||
}
|
||||
var bluebird = require("./promise")();
|
||||
bluebird.noConflict = noConflict;
|
||||
module.exports = bluebird;
|
||||
123
node_modules/twit/node_modules/bluebird/js/release/call_get.js
generated
vendored
Normal file
123
node_modules/twit/node_modules/bluebird/js/release/call_get.js
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
"use strict";
|
||||
var cr = Object.create;
|
||||
if (cr) {
|
||||
var callerCache = cr(null);
|
||||
var getterCache = cr(null);
|
||||
callerCache[" size"] = getterCache[" size"] = 0;
|
||||
}
|
||||
|
||||
module.exports = function(Promise) {
|
||||
var util = require("./util");
|
||||
var canEvaluate = util.canEvaluate;
|
||||
var isIdentifier = util.isIdentifier;
|
||||
|
||||
var getMethodCaller;
|
||||
var getGetter;
|
||||
if (!false) {
|
||||
var makeMethodCaller = function (methodName) {
|
||||
return new Function("ensureMethod", " \n\
|
||||
return function(obj) { \n\
|
||||
'use strict' \n\
|
||||
var len = this.length; \n\
|
||||
ensureMethod(obj, 'methodName'); \n\
|
||||
switch(len) { \n\
|
||||
case 1: return obj.methodName(this[0]); \n\
|
||||
case 2: return obj.methodName(this[0], this[1]); \n\
|
||||
case 3: return obj.methodName(this[0], this[1], this[2]); \n\
|
||||
case 0: return obj.methodName(); \n\
|
||||
default: \n\
|
||||
return obj.methodName.apply(obj, this); \n\
|
||||
} \n\
|
||||
}; \n\
|
||||
".replace(/methodName/g, methodName))(ensureMethod);
|
||||
};
|
||||
|
||||
var makeGetter = function (propertyName) {
|
||||
return new Function("obj", " \n\
|
||||
'use strict'; \n\
|
||||
return obj.propertyName; \n\
|
||||
".replace("propertyName", propertyName));
|
||||
};
|
||||
|
||||
var getCompiled = function(name, compiler, cache) {
|
||||
var ret = cache[name];
|
||||
if (typeof ret !== "function") {
|
||||
if (!isIdentifier(name)) {
|
||||
return null;
|
||||
}
|
||||
ret = compiler(name);
|
||||
cache[name] = ret;
|
||||
cache[" size"]++;
|
||||
if (cache[" size"] > 512) {
|
||||
var keys = Object.keys(cache);
|
||||
for (var i = 0; i < 256; ++i) delete cache[keys[i]];
|
||||
cache[" size"] = keys.length - 256;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
getMethodCaller = function(name) {
|
||||
return getCompiled(name, makeMethodCaller, callerCache);
|
||||
};
|
||||
|
||||
getGetter = function(name) {
|
||||
return getCompiled(name, makeGetter, getterCache);
|
||||
};
|
||||
}
|
||||
|
||||
function ensureMethod(obj, methodName) {
|
||||
var fn;
|
||||
if (obj != null) fn = obj[methodName];
|
||||
if (typeof fn !== "function") {
|
||||
var message = "Object " + util.classString(obj) + " has no method '" +
|
||||
util.toString(methodName) + "'";
|
||||
throw new Promise.TypeError(message);
|
||||
}
|
||||
return fn;
|
||||
}
|
||||
|
||||
function caller(obj) {
|
||||
var methodName = this.pop();
|
||||
var fn = ensureMethod(obj, methodName);
|
||||
return fn.apply(obj, this);
|
||||
}
|
||||
Promise.prototype.call = function (methodName) {
|
||||
var $_len = arguments.length;var args = new Array(Math.max($_len - 1, 0)); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];};
|
||||
if (!false) {
|
||||
if (canEvaluate) {
|
||||
var maybeCaller = getMethodCaller(methodName);
|
||||
if (maybeCaller !== null) {
|
||||
return this._then(
|
||||
maybeCaller, undefined, undefined, args, undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
args.push(methodName);
|
||||
return this._then(caller, undefined, undefined, args, undefined);
|
||||
};
|
||||
|
||||
function namedGetter(obj) {
|
||||
return obj[this];
|
||||
}
|
||||
function indexedGetter(obj) {
|
||||
var index = +this;
|
||||
if (index < 0) index = Math.max(0, index + obj.length);
|
||||
return obj[index];
|
||||
}
|
||||
Promise.prototype.get = function (propertyName) {
|
||||
var isIndex = (typeof propertyName === "number");
|
||||
var getter;
|
||||
if (!isIndex) {
|
||||
if (canEvaluate) {
|
||||
var maybeGetter = getGetter(propertyName);
|
||||
getter = maybeGetter !== null ? maybeGetter : namedGetter;
|
||||
} else {
|
||||
getter = namedGetter;
|
||||
}
|
||||
} else {
|
||||
getter = indexedGetter;
|
||||
}
|
||||
return this._then(getter, undefined, undefined, propertyName, undefined);
|
||||
};
|
||||
};
|
||||
125
node_modules/twit/node_modules/bluebird/js/release/cancel.js
generated
vendored
Normal file
125
node_modules/twit/node_modules/bluebird/js/release/cancel.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, PromiseArray, apiRejection, debug) {
|
||||
var util = require("./util");
|
||||
var tryCatch = util.tryCatch;
|
||||
var errorObj = util.errorObj;
|
||||
var async = Promise._async;
|
||||
|
||||
Promise.prototype["break"] = Promise.prototype.cancel = function() {
|
||||
if (!debug.cancellation()) return this._warn("cancellation is disabled");
|
||||
|
||||
var promise = this;
|
||||
var child = promise;
|
||||
while (promise.isCancellable()) {
|
||||
if (!promise._cancelBy(child)) {
|
||||
if (child._isFollowing()) {
|
||||
child._followee().cancel();
|
||||
} else {
|
||||
child._cancelBranched();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var parent = promise._cancellationParent;
|
||||
if (parent == null || !parent.isCancellable()) {
|
||||
if (promise._isFollowing()) {
|
||||
promise._followee().cancel();
|
||||
} else {
|
||||
promise._cancelBranched();
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
if (promise._isFollowing()) promise._followee().cancel();
|
||||
child = promise;
|
||||
promise = parent;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._branchHasCancelled = function() {
|
||||
this._branchesRemainingToCancel--;
|
||||
};
|
||||
|
||||
Promise.prototype._enoughBranchesHaveCancelled = function() {
|
||||
return this._branchesRemainingToCancel === undefined ||
|
||||
this._branchesRemainingToCancel <= 0;
|
||||
};
|
||||
|
||||
Promise.prototype._cancelBy = function(canceller) {
|
||||
if (canceller === this) {
|
||||
this._branchesRemainingToCancel = 0;
|
||||
this._invokeOnCancel();
|
||||
return true;
|
||||
} else {
|
||||
this._branchHasCancelled();
|
||||
if (this._enoughBranchesHaveCancelled()) {
|
||||
this._invokeOnCancel();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Promise.prototype._cancelBranched = function() {
|
||||
if (this._enoughBranchesHaveCancelled()) {
|
||||
this._cancel();
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._cancel = function() {
|
||||
if (!this.isCancellable()) return;
|
||||
|
||||
this._setCancelled();
|
||||
async.invoke(this._cancelPromises, this, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype._cancelPromises = function() {
|
||||
if (this._length() > 0) this._settlePromises();
|
||||
};
|
||||
|
||||
Promise.prototype._unsetOnCancel = function() {
|
||||
this._onCancelField = undefined;
|
||||
};
|
||||
|
||||
Promise.prototype.isCancellable = function() {
|
||||
return this.isPending() && !this.isCancelled();
|
||||
};
|
||||
|
||||
Promise.prototype._doInvokeOnCancel = function(onCancelCallback, internalOnly) {
|
||||
if (util.isArray(onCancelCallback)) {
|
||||
for (var i = 0; i < onCancelCallback.length; ++i) {
|
||||
this._doInvokeOnCancel(onCancelCallback[i], internalOnly);
|
||||
}
|
||||
} else if (onCancelCallback !== undefined) {
|
||||
if (typeof onCancelCallback === "function") {
|
||||
if (!internalOnly) {
|
||||
var e = tryCatch(onCancelCallback).call(this._boundValue());
|
||||
if (e === errorObj) {
|
||||
this._attachExtraTrace(e.e);
|
||||
async.throwLater(e.e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
onCancelCallback._resultCancelled(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._invokeOnCancel = function() {
|
||||
var onCancelCallback = this._onCancel();
|
||||
this._unsetOnCancel();
|
||||
async.invoke(this._doInvokeOnCancel, this, onCancelCallback);
|
||||
};
|
||||
|
||||
Promise.prototype._invokeInternalOnCancel = function() {
|
||||
if (this.isCancellable()) {
|
||||
this._doInvokeOnCancel(this._onCancel(), true);
|
||||
this._unsetOnCancel();
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._resultCancelled = function() {
|
||||
this.cancel();
|
||||
};
|
||||
|
||||
};
|
||||
42
node_modules/twit/node_modules/bluebird/js/release/catch_filter.js
generated
vendored
Normal file
42
node_modules/twit/node_modules/bluebird/js/release/catch_filter.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
module.exports = function(NEXT_FILTER) {
|
||||
var util = require("./util");
|
||||
var getKeys = require("./es5").keys;
|
||||
var tryCatch = util.tryCatch;
|
||||
var errorObj = util.errorObj;
|
||||
|
||||
function catchFilter(instances, cb, promise) {
|
||||
return function(e) {
|
||||
var boundTo = promise._boundValue();
|
||||
predicateLoop: for (var i = 0; i < instances.length; ++i) {
|
||||
var item = instances[i];
|
||||
|
||||
if (item === Error ||
|
||||
(item != null && item.prototype instanceof Error)) {
|
||||
if (e instanceof item) {
|
||||
return tryCatch(cb).call(boundTo, e);
|
||||
}
|
||||
} else if (typeof item === "function") {
|
||||
var matchesPredicate = tryCatch(item).call(boundTo, e);
|
||||
if (matchesPredicate === errorObj) {
|
||||
return matchesPredicate;
|
||||
} else if (matchesPredicate) {
|
||||
return tryCatch(cb).call(boundTo, e);
|
||||
}
|
||||
} else if (util.isObject(e)) {
|
||||
var keys = getKeys(item);
|
||||
for (var j = 0; j < keys.length; ++j) {
|
||||
var key = keys[j];
|
||||
if (item[key] != e[key]) {
|
||||
continue predicateLoop;
|
||||
}
|
||||
}
|
||||
return tryCatch(cb).call(boundTo, e);
|
||||
}
|
||||
}
|
||||
return NEXT_FILTER;
|
||||
};
|
||||
}
|
||||
|
||||
return catchFilter;
|
||||
};
|
||||
69
node_modules/twit/node_modules/bluebird/js/release/context.js
generated
vendored
Normal file
69
node_modules/twit/node_modules/bluebird/js/release/context.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise) {
|
||||
var longStackTraces = false;
|
||||
var contextStack = [];
|
||||
|
||||
Promise.prototype._promiseCreated = function() {};
|
||||
Promise.prototype._pushContext = function() {};
|
||||
Promise.prototype._popContext = function() {return null;};
|
||||
Promise._peekContext = Promise.prototype._peekContext = function() {};
|
||||
|
||||
function Context() {
|
||||
this._trace = new Context.CapturedTrace(peekContext());
|
||||
}
|
||||
Context.prototype._pushContext = function () {
|
||||
if (this._trace !== undefined) {
|
||||
this._trace._promiseCreated = null;
|
||||
contextStack.push(this._trace);
|
||||
}
|
||||
};
|
||||
|
||||
Context.prototype._popContext = function () {
|
||||
if (this._trace !== undefined) {
|
||||
var trace = contextStack.pop();
|
||||
var ret = trace._promiseCreated;
|
||||
trace._promiseCreated = null;
|
||||
return ret;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
function createContext() {
|
||||
if (longStackTraces) return new Context();
|
||||
}
|
||||
|
||||
function peekContext() {
|
||||
var lastIndex = contextStack.length - 1;
|
||||
if (lastIndex >= 0) {
|
||||
return contextStack[lastIndex];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
Context.CapturedTrace = null;
|
||||
Context.create = createContext;
|
||||
Context.deactivateLongStackTraces = function() {};
|
||||
Context.activateLongStackTraces = function() {
|
||||
var Promise_pushContext = Promise.prototype._pushContext;
|
||||
var Promise_popContext = Promise.prototype._popContext;
|
||||
var Promise_PeekContext = Promise._peekContext;
|
||||
var Promise_peekContext = Promise.prototype._peekContext;
|
||||
var Promise_promiseCreated = Promise.prototype._promiseCreated;
|
||||
Context.deactivateLongStackTraces = function() {
|
||||
Promise.prototype._pushContext = Promise_pushContext;
|
||||
Promise.prototype._popContext = Promise_popContext;
|
||||
Promise._peekContext = Promise_PeekContext;
|
||||
Promise.prototype._peekContext = Promise_peekContext;
|
||||
Promise.prototype._promiseCreated = Promise_promiseCreated;
|
||||
longStackTraces = false;
|
||||
};
|
||||
longStackTraces = true;
|
||||
Promise.prototype._pushContext = Context.prototype._pushContext;
|
||||
Promise.prototype._popContext = Context.prototype._popContext;
|
||||
Promise._peekContext = Promise.prototype._peekContext = peekContext;
|
||||
Promise.prototype._promiseCreated = function() {
|
||||
var ctx = this._peekContext();
|
||||
if (ctx && ctx._promiseCreated == null) ctx._promiseCreated = this;
|
||||
};
|
||||
};
|
||||
return Context;
|
||||
};
|
||||
855
node_modules/twit/node_modules/bluebird/js/release/debuggability.js
generated
vendored
Normal file
855
node_modules/twit/node_modules/bluebird/js/release/debuggability.js
generated
vendored
Normal file
@@ -0,0 +1,855 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, Context) {
|
||||
var getDomain = Promise._getDomain;
|
||||
var async = Promise._async;
|
||||
var Warning = require("./errors").Warning;
|
||||
var util = require("./util");
|
||||
var canAttachTrace = util.canAttachTrace;
|
||||
var unhandledRejectionHandled;
|
||||
var possiblyUnhandledRejection;
|
||||
var bluebirdFramePattern =
|
||||
/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/;
|
||||
var stackFramePattern = null;
|
||||
var formatStack = null;
|
||||
var indentStackFrames = false;
|
||||
var printWarning;
|
||||
var debugging = !!(util.env("BLUEBIRD_DEBUG") != 0 &&
|
||||
(false ||
|
||||
util.env("BLUEBIRD_DEBUG") ||
|
||||
util.env("NODE_ENV") === "development"));
|
||||
|
||||
var warnings = !!(util.env("BLUEBIRD_WARNINGS") != 0 &&
|
||||
(debugging || util.env("BLUEBIRD_WARNINGS")));
|
||||
|
||||
var longStackTraces = !!(util.env("BLUEBIRD_LONG_STACK_TRACES") != 0 &&
|
||||
(debugging || util.env("BLUEBIRD_LONG_STACK_TRACES")));
|
||||
|
||||
var wForgottenReturn = util.env("BLUEBIRD_W_FORGOTTEN_RETURN") != 0 &&
|
||||
(warnings || !!util.env("BLUEBIRD_W_FORGOTTEN_RETURN"));
|
||||
|
||||
Promise.prototype.suppressUnhandledRejections = function() {
|
||||
var target = this._target();
|
||||
target._bitField = ((target._bitField & (~1048576)) |
|
||||
524288);
|
||||
};
|
||||
|
||||
Promise.prototype._ensurePossibleRejectionHandled = function () {
|
||||
if ((this._bitField & 524288) !== 0) return;
|
||||
this._setRejectionIsUnhandled();
|
||||
async.invokeLater(this._notifyUnhandledRejection, this, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype._notifyUnhandledRejectionIsHandled = function () {
|
||||
fireRejectionEvent("rejectionHandled",
|
||||
unhandledRejectionHandled, undefined, this);
|
||||
};
|
||||
|
||||
Promise.prototype._setReturnedNonUndefined = function() {
|
||||
this._bitField = this._bitField | 268435456;
|
||||
};
|
||||
|
||||
Promise.prototype._returnedNonUndefined = function() {
|
||||
return (this._bitField & 268435456) !== 0;
|
||||
};
|
||||
|
||||
Promise.prototype._notifyUnhandledRejection = function () {
|
||||
if (this._isRejectionUnhandled()) {
|
||||
var reason = this._settledValue();
|
||||
this._setUnhandledRejectionIsNotified();
|
||||
fireRejectionEvent("unhandledRejection",
|
||||
possiblyUnhandledRejection, reason, this);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._setUnhandledRejectionIsNotified = function () {
|
||||
this._bitField = this._bitField | 262144;
|
||||
};
|
||||
|
||||
Promise.prototype._unsetUnhandledRejectionIsNotified = function () {
|
||||
this._bitField = this._bitField & (~262144);
|
||||
};
|
||||
|
||||
Promise.prototype._isUnhandledRejectionNotified = function () {
|
||||
return (this._bitField & 262144) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._setRejectionIsUnhandled = function () {
|
||||
this._bitField = this._bitField | 1048576;
|
||||
};
|
||||
|
||||
Promise.prototype._unsetRejectionIsUnhandled = function () {
|
||||
this._bitField = this._bitField & (~1048576);
|
||||
if (this._isUnhandledRejectionNotified()) {
|
||||
this._unsetUnhandledRejectionIsNotified();
|
||||
this._notifyUnhandledRejectionIsHandled();
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._isRejectionUnhandled = function () {
|
||||
return (this._bitField & 1048576) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._warn = function(message, shouldUseOwnTrace, promise) {
|
||||
return warn(message, shouldUseOwnTrace, promise || this);
|
||||
};
|
||||
|
||||
Promise.onPossiblyUnhandledRejection = function (fn) {
|
||||
var domain = getDomain();
|
||||
possiblyUnhandledRejection =
|
||||
typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
|
||||
: undefined;
|
||||
};
|
||||
|
||||
Promise.onUnhandledRejectionHandled = function (fn) {
|
||||
var domain = getDomain();
|
||||
unhandledRejectionHandled =
|
||||
typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
|
||||
: undefined;
|
||||
};
|
||||
|
||||
var disableLongStackTraces = function() {};
|
||||
Promise.longStackTraces = function () {
|
||||
if (async.haveItemsQueued() && !config.longStackTraces) {
|
||||
throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
}
|
||||
if (!config.longStackTraces && longStackTracesIsSupported()) {
|
||||
var Promise_captureStackTrace = Promise.prototype._captureStackTrace;
|
||||
var Promise_attachExtraTrace = Promise.prototype._attachExtraTrace;
|
||||
config.longStackTraces = true;
|
||||
disableLongStackTraces = function() {
|
||||
if (async.haveItemsQueued() && !config.longStackTraces) {
|
||||
throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
}
|
||||
Promise.prototype._captureStackTrace = Promise_captureStackTrace;
|
||||
Promise.prototype._attachExtraTrace = Promise_attachExtraTrace;
|
||||
Context.deactivateLongStackTraces();
|
||||
async.enableTrampoline();
|
||||
config.longStackTraces = false;
|
||||
};
|
||||
Promise.prototype._captureStackTrace = longStackTracesCaptureStackTrace;
|
||||
Promise.prototype._attachExtraTrace = longStackTracesAttachExtraTrace;
|
||||
Context.activateLongStackTraces();
|
||||
async.disableTrampolineIfNecessary();
|
||||
}
|
||||
};
|
||||
|
||||
Promise.hasLongStackTraces = function () {
|
||||
return config.longStackTraces && longStackTracesIsSupported();
|
||||
};
|
||||
|
||||
var fireDomEvent = (function() {
|
||||
try {
|
||||
var event = document.createEvent("CustomEvent");
|
||||
event.initCustomEvent("testingtheevent", false, true, {});
|
||||
util.global.dispatchEvent(event);
|
||||
return function(name, event) {
|
||||
var domEvent = document.createEvent("CustomEvent");
|
||||
domEvent.initCustomEvent(name.toLowerCase(), false, true, event);
|
||||
return !util.global.dispatchEvent(domEvent);
|
||||
};
|
||||
} catch (e) {}
|
||||
return function() {
|
||||
return false;
|
||||
};
|
||||
})();
|
||||
|
||||
var fireGlobalEvent = (function() {
|
||||
if (util.isNode) {
|
||||
return function() {
|
||||
return process.emit.apply(process, arguments);
|
||||
};
|
||||
} else {
|
||||
if (!util.global) {
|
||||
return function() {
|
||||
return false;
|
||||
};
|
||||
}
|
||||
return function(name) {
|
||||
var methodName = "on" + name.toLowerCase();
|
||||
var method = util.global[methodName];
|
||||
if (!method) return false;
|
||||
method.apply(util.global, [].slice.call(arguments, 1));
|
||||
return true;
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
function generatePromiseLifecycleEventObject(name, promise) {
|
||||
return {promise: promise};
|
||||
}
|
||||
|
||||
var eventToObjectGenerator = {
|
||||
promiseCreated: generatePromiseLifecycleEventObject,
|
||||
promiseFulfilled: generatePromiseLifecycleEventObject,
|
||||
promiseRejected: generatePromiseLifecycleEventObject,
|
||||
promiseResolved: generatePromiseLifecycleEventObject,
|
||||
promiseCancelled: generatePromiseLifecycleEventObject,
|
||||
promiseChained: function(name, promise, child) {
|
||||
return {promise: promise, child: child};
|
||||
},
|
||||
warning: function(name, warning) {
|
||||
return {warning: warning};
|
||||
},
|
||||
unhandledRejection: function (name, reason, promise) {
|
||||
return {reason: reason, promise: promise};
|
||||
},
|
||||
rejectionHandled: generatePromiseLifecycleEventObject
|
||||
};
|
||||
|
||||
var activeFireEvent = function (name) {
|
||||
var globalEventFired = false;
|
||||
try {
|
||||
globalEventFired = fireGlobalEvent.apply(null, arguments);
|
||||
} catch (e) {
|
||||
async.throwLater(e);
|
||||
globalEventFired = true;
|
||||
}
|
||||
|
||||
var domEventFired = false;
|
||||
try {
|
||||
domEventFired = fireDomEvent(name,
|
||||
eventToObjectGenerator[name].apply(null, arguments));
|
||||
} catch (e) {
|
||||
async.throwLater(e);
|
||||
domEventFired = true;
|
||||
}
|
||||
|
||||
return domEventFired || globalEventFired;
|
||||
};
|
||||
|
||||
Promise.config = function(opts) {
|
||||
opts = Object(opts);
|
||||
if ("longStackTraces" in opts) {
|
||||
if (opts.longStackTraces) {
|
||||
Promise.longStackTraces();
|
||||
} else if (!opts.longStackTraces && Promise.hasLongStackTraces()) {
|
||||
disableLongStackTraces();
|
||||
}
|
||||
}
|
||||
if ("warnings" in opts) {
|
||||
var warningsOption = opts.warnings;
|
||||
config.warnings = !!warningsOption;
|
||||
wForgottenReturn = config.warnings;
|
||||
|
||||
if (util.isObject(warningsOption)) {
|
||||
if ("wForgottenReturn" in warningsOption) {
|
||||
wForgottenReturn = !!warningsOption.wForgottenReturn;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ("cancellation" in opts && opts.cancellation && !config.cancellation) {
|
||||
if (async.haveItemsQueued()) {
|
||||
throw new Error(
|
||||
"cannot enable cancellation after promises are in use");
|
||||
}
|
||||
Promise.prototype._clearCancellationData =
|
||||
cancellationClearCancellationData;
|
||||
Promise.prototype._propagateFrom = cancellationPropagateFrom;
|
||||
Promise.prototype._onCancel = cancellationOnCancel;
|
||||
Promise.prototype._setOnCancel = cancellationSetOnCancel;
|
||||
Promise.prototype._attachCancellationCallback =
|
||||
cancellationAttachCancellationCallback;
|
||||
Promise.prototype._execute = cancellationExecute;
|
||||
propagateFromFunction = cancellationPropagateFrom;
|
||||
config.cancellation = true;
|
||||
}
|
||||
if ("monitoring" in opts) {
|
||||
if (opts.monitoring && !config.monitoring) {
|
||||
config.monitoring = true;
|
||||
Promise.prototype._fireEvent = activeFireEvent;
|
||||
} else if (!opts.monitoring && config.monitoring) {
|
||||
config.monitoring = false;
|
||||
Promise.prototype._fireEvent = defaultFireEvent;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function defaultFireEvent() { return false; }
|
||||
|
||||
Promise.prototype._fireEvent = defaultFireEvent;
|
||||
Promise.prototype._execute = function(executor, resolve, reject) {
|
||||
try {
|
||||
executor(resolve, reject);
|
||||
} catch (e) {
|
||||
return e;
|
||||
}
|
||||
};
|
||||
Promise.prototype._onCancel = function () {};
|
||||
Promise.prototype._setOnCancel = function (handler) { ; };
|
||||
Promise.prototype._attachCancellationCallback = function(onCancel) {
|
||||
;
|
||||
};
|
||||
Promise.prototype._captureStackTrace = function () {};
|
||||
Promise.prototype._attachExtraTrace = function () {};
|
||||
Promise.prototype._clearCancellationData = function() {};
|
||||
Promise.prototype._propagateFrom = function (parent, flags) {
|
||||
;
|
||||
;
|
||||
};
|
||||
|
||||
function cancellationExecute(executor, resolve, reject) {
|
||||
var promise = this;
|
||||
try {
|
||||
executor(resolve, reject, function(onCancel) {
|
||||
if (typeof onCancel !== "function") {
|
||||
throw new TypeError("onCancel must be a function, got: " +
|
||||
util.toString(onCancel));
|
||||
}
|
||||
promise._attachCancellationCallback(onCancel);
|
||||
});
|
||||
} catch (e) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
function cancellationAttachCancellationCallback(onCancel) {
|
||||
if (!this.isCancellable()) return this;
|
||||
|
||||
var previousOnCancel = this._onCancel();
|
||||
if (previousOnCancel !== undefined) {
|
||||
if (util.isArray(previousOnCancel)) {
|
||||
previousOnCancel.push(onCancel);
|
||||
} else {
|
||||
this._setOnCancel([previousOnCancel, onCancel]);
|
||||
}
|
||||
} else {
|
||||
this._setOnCancel(onCancel);
|
||||
}
|
||||
}
|
||||
|
||||
function cancellationOnCancel() {
|
||||
return this._onCancelField;
|
||||
}
|
||||
|
||||
function cancellationSetOnCancel(onCancel) {
|
||||
this._onCancelField = onCancel;
|
||||
}
|
||||
|
||||
function cancellationClearCancellationData() {
|
||||
this._cancellationParent = undefined;
|
||||
this._onCancelField = undefined;
|
||||
}
|
||||
|
||||
function cancellationPropagateFrom(parent, flags) {
|
||||
if ((flags & 1) !== 0) {
|
||||
this._cancellationParent = parent;
|
||||
var branchesRemainingToCancel = parent._branchesRemainingToCancel;
|
||||
if (branchesRemainingToCancel === undefined) {
|
||||
branchesRemainingToCancel = 0;
|
||||
}
|
||||
parent._branchesRemainingToCancel = branchesRemainingToCancel + 1;
|
||||
}
|
||||
if ((flags & 2) !== 0 && parent._isBound()) {
|
||||
this._setBoundTo(parent._boundTo);
|
||||
}
|
||||
}
|
||||
|
||||
function bindingPropagateFrom(parent, flags) {
|
||||
if ((flags & 2) !== 0 && parent._isBound()) {
|
||||
this._setBoundTo(parent._boundTo);
|
||||
}
|
||||
}
|
||||
var propagateFromFunction = bindingPropagateFrom;
|
||||
|
||||
function boundValueFunction() {
|
||||
var ret = this._boundTo;
|
||||
if (ret !== undefined) {
|
||||
if (ret instanceof Promise) {
|
||||
if (ret.isFulfilled()) {
|
||||
return ret.value();
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
function longStackTracesCaptureStackTrace() {
|
||||
this._trace = new CapturedTrace(this._peekContext());
|
||||
}
|
||||
|
||||
function longStackTracesAttachExtraTrace(error, ignoreSelf) {
|
||||
if (canAttachTrace(error)) {
|
||||
var trace = this._trace;
|
||||
if (trace !== undefined) {
|
||||
if (ignoreSelf) trace = trace._parent;
|
||||
}
|
||||
if (trace !== undefined) {
|
||||
trace.attachExtraTrace(error);
|
||||
} else if (!error.__stackCleaned__) {
|
||||
var parsed = parseStackAndMessage(error);
|
||||
util.notEnumerableProp(error, "stack",
|
||||
parsed.message + "\n" + parsed.stack.join("\n"));
|
||||
util.notEnumerableProp(error, "__stackCleaned__", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkForgottenReturns(returnValue, promiseCreated, name, promise,
|
||||
parent) {
|
||||
if (returnValue === undefined && promiseCreated !== null &&
|
||||
wForgottenReturn) {
|
||||
if (parent !== undefined && parent._returnedNonUndefined()) return;
|
||||
if ((promise._bitField & 65535) === 0) return;
|
||||
|
||||
if (name) name = name + " ";
|
||||
var msg = "a promise was created in a " + name +
|
||||
"handler but was not returned from it";
|
||||
promise._warn(msg, true, promiseCreated);
|
||||
}
|
||||
}
|
||||
|
||||
function deprecated(name, replacement) {
|
||||
var message = name +
|
||||
" is deprecated and will be removed in a future version.";
|
||||
if (replacement) message += " Use " + replacement + " instead.";
|
||||
return warn(message);
|
||||
}
|
||||
|
||||
function warn(message, shouldUseOwnTrace, promise) {
|
||||
if (!config.warnings) return;
|
||||
var warning = new Warning(message);
|
||||
var ctx;
|
||||
if (shouldUseOwnTrace) {
|
||||
promise._attachExtraTrace(warning);
|
||||
} else if (config.longStackTraces && (ctx = Promise._peekContext())) {
|
||||
ctx.attachExtraTrace(warning);
|
||||
} else {
|
||||
var parsed = parseStackAndMessage(warning);
|
||||
warning.stack = parsed.message + "\n" + parsed.stack.join("\n");
|
||||
}
|
||||
|
||||
if (!activeFireEvent("warning", warning)) {
|
||||
formatAndLogError(warning, "", true);
|
||||
}
|
||||
}
|
||||
|
||||
function reconstructStack(message, stacks) {
|
||||
for (var i = 0; i < stacks.length - 1; ++i) {
|
||||
stacks[i].push("From previous event:");
|
||||
stacks[i] = stacks[i].join("\n");
|
||||
}
|
||||
if (i < stacks.length) {
|
||||
stacks[i] = stacks[i].join("\n");
|
||||
}
|
||||
return message + "\n" + stacks.join("\n");
|
||||
}
|
||||
|
||||
function removeDuplicateOrEmptyJumps(stacks) {
|
||||
for (var i = 0; i < stacks.length; ++i) {
|
||||
if (stacks[i].length === 0 ||
|
||||
((i + 1 < stacks.length) && stacks[i][0] === stacks[i+1][0])) {
|
||||
stacks.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeCommonRoots(stacks) {
|
||||
var current = stacks[0];
|
||||
for (var i = 1; i < stacks.length; ++i) {
|
||||
var prev = stacks[i];
|
||||
var currentLastIndex = current.length - 1;
|
||||
var currentLastLine = current[currentLastIndex];
|
||||
var commonRootMeetPoint = -1;
|
||||
|
||||
for (var j = prev.length - 1; j >= 0; --j) {
|
||||
if (prev[j] === currentLastLine) {
|
||||
commonRootMeetPoint = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (var j = commonRootMeetPoint; j >= 0; --j) {
|
||||
var line = prev[j];
|
||||
if (current[currentLastIndex] === line) {
|
||||
current.pop();
|
||||
currentLastIndex--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
current = prev;
|
||||
}
|
||||
}
|
||||
|
||||
function cleanStack(stack) {
|
||||
var ret = [];
|
||||
for (var i = 0; i < stack.length; ++i) {
|
||||
var line = stack[i];
|
||||
var isTraceLine = " (No stack trace)" === line ||
|
||||
stackFramePattern.test(line);
|
||||
var isInternalFrame = isTraceLine && shouldIgnore(line);
|
||||
if (isTraceLine && !isInternalFrame) {
|
||||
if (indentStackFrames && line.charAt(0) !== " ") {
|
||||
line = " " + line;
|
||||
}
|
||||
ret.push(line);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
function stackFramesAsArray(error) {
|
||||
var stack = error.stack.replace(/\s+$/g, "").split("\n");
|
||||
for (var i = 0; i < stack.length; ++i) {
|
||||
var line = stack[i];
|
||||
if (" (No stack trace)" === line || stackFramePattern.test(line)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 0) {
|
||||
stack = stack.slice(i);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
function parseStackAndMessage(error) {
|
||||
var stack = error.stack;
|
||||
var message = error.toString();
|
||||
stack = typeof stack === "string" && stack.length > 0
|
||||
? stackFramesAsArray(error) : [" (No stack trace)"];
|
||||
return {
|
||||
message: message,
|
||||
stack: cleanStack(stack)
|
||||
};
|
||||
}
|
||||
|
||||
function formatAndLogError(error, title, isSoft) {
|
||||
if (typeof console !== "undefined") {
|
||||
var message;
|
||||
if (util.isObject(error)) {
|
||||
var stack = error.stack;
|
||||
message = title + formatStack(stack, error);
|
||||
} else {
|
||||
message = title + String(error);
|
||||
}
|
||||
if (typeof printWarning === "function") {
|
||||
printWarning(message, isSoft);
|
||||
} else if (typeof console.log === "function" ||
|
||||
typeof console.log === "object") {
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fireRejectionEvent(name, localHandler, reason, promise) {
|
||||
var localEventFired = false;
|
||||
try {
|
||||
if (typeof localHandler === "function") {
|
||||
localEventFired = true;
|
||||
if (name === "rejectionHandled") {
|
||||
localHandler(promise);
|
||||
} else {
|
||||
localHandler(reason, promise);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
async.throwLater(e);
|
||||
}
|
||||
|
||||
if (name === "unhandledRejection") {
|
||||
if (!activeFireEvent(name, reason, promise) && !localEventFired) {
|
||||
formatAndLogError(reason, "Unhandled rejection ");
|
||||
}
|
||||
} else {
|
||||
activeFireEvent(name, promise);
|
||||
}
|
||||
}
|
||||
|
||||
function formatNonError(obj) {
|
||||
var str;
|
||||
if (typeof obj === "function") {
|
||||
str = "[function " +
|
||||
(obj.name || "anonymous") +
|
||||
"]";
|
||||
} else {
|
||||
str = obj && typeof obj.toString === "function"
|
||||
? obj.toString() : util.toString(obj);
|
||||
var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/;
|
||||
if (ruselessToString.test(str)) {
|
||||
try {
|
||||
var newStr = JSON.stringify(obj);
|
||||
str = newStr;
|
||||
}
|
||||
catch(e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (str.length === 0) {
|
||||
str = "(empty array)";
|
||||
}
|
||||
}
|
||||
return ("(<" + snip(str) + ">, no stack trace)");
|
||||
}
|
||||
|
||||
function snip(str) {
|
||||
var maxChars = 41;
|
||||
if (str.length < maxChars) {
|
||||
return str;
|
||||
}
|
||||
return str.substr(0, maxChars - 3) + "...";
|
||||
}
|
||||
|
||||
function longStackTracesIsSupported() {
|
||||
return typeof captureStackTrace === "function";
|
||||
}
|
||||
|
||||
var shouldIgnore = function() { return false; };
|
||||
var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;
|
||||
function parseLineInfo(line) {
|
||||
var matches = line.match(parseLineInfoRegex);
|
||||
if (matches) {
|
||||
return {
|
||||
fileName: matches[1],
|
||||
line: parseInt(matches[2], 10)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function setBounds(firstLineError, lastLineError) {
|
||||
if (!longStackTracesIsSupported()) return;
|
||||
var firstStackLines = firstLineError.stack.split("\n");
|
||||
var lastStackLines = lastLineError.stack.split("\n");
|
||||
var firstIndex = -1;
|
||||
var lastIndex = -1;
|
||||
var firstFileName;
|
||||
var lastFileName;
|
||||
for (var i = 0; i < firstStackLines.length; ++i) {
|
||||
var result = parseLineInfo(firstStackLines[i]);
|
||||
if (result) {
|
||||
firstFileName = result.fileName;
|
||||
firstIndex = result.line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < lastStackLines.length; ++i) {
|
||||
var result = parseLineInfo(lastStackLines[i]);
|
||||
if (result) {
|
||||
lastFileName = result.fileName;
|
||||
lastIndex = result.line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (firstIndex < 0 || lastIndex < 0 || !firstFileName || !lastFileName ||
|
||||
firstFileName !== lastFileName || firstIndex >= lastIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
shouldIgnore = function(line) {
|
||||
if (bluebirdFramePattern.test(line)) return true;
|
||||
var info = parseLineInfo(line);
|
||||
if (info) {
|
||||
if (info.fileName === firstFileName &&
|
||||
(firstIndex <= info.line && info.line <= lastIndex)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
function CapturedTrace(parent) {
|
||||
this._parent = parent;
|
||||
this._promisesCreated = 0;
|
||||
var length = this._length = 1 + (parent === undefined ? 0 : parent._length);
|
||||
captureStackTrace(this, CapturedTrace);
|
||||
if (length > 32) this.uncycle();
|
||||
}
|
||||
util.inherits(CapturedTrace, Error);
|
||||
Context.CapturedTrace = CapturedTrace;
|
||||
|
||||
CapturedTrace.prototype.uncycle = function() {
|
||||
var length = this._length;
|
||||
if (length < 2) return;
|
||||
var nodes = [];
|
||||
var stackToIndex = {};
|
||||
|
||||
for (var i = 0, node = this; node !== undefined; ++i) {
|
||||
nodes.push(node);
|
||||
node = node._parent;
|
||||
}
|
||||
length = this._length = i;
|
||||
for (var i = length - 1; i >= 0; --i) {
|
||||
var stack = nodes[i].stack;
|
||||
if (stackToIndex[stack] === undefined) {
|
||||
stackToIndex[stack] = i;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < length; ++i) {
|
||||
var currentStack = nodes[i].stack;
|
||||
var index = stackToIndex[currentStack];
|
||||
if (index !== undefined && index !== i) {
|
||||
if (index > 0) {
|
||||
nodes[index - 1]._parent = undefined;
|
||||
nodes[index - 1]._length = 1;
|
||||
}
|
||||
nodes[i]._parent = undefined;
|
||||
nodes[i]._length = 1;
|
||||
var cycleEdgeNode = i > 0 ? nodes[i - 1] : this;
|
||||
|
||||
if (index < length - 1) {
|
||||
cycleEdgeNode._parent = nodes[index + 1];
|
||||
cycleEdgeNode._parent.uncycle();
|
||||
cycleEdgeNode._length =
|
||||
cycleEdgeNode._parent._length + 1;
|
||||
} else {
|
||||
cycleEdgeNode._parent = undefined;
|
||||
cycleEdgeNode._length = 1;
|
||||
}
|
||||
var currentChildLength = cycleEdgeNode._length + 1;
|
||||
for (var j = i - 2; j >= 0; --j) {
|
||||
nodes[j]._length = currentChildLength;
|
||||
currentChildLength++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CapturedTrace.prototype.attachExtraTrace = function(error) {
|
||||
if (error.__stackCleaned__) return;
|
||||
this.uncycle();
|
||||
var parsed = parseStackAndMessage(error);
|
||||
var message = parsed.message;
|
||||
var stacks = [parsed.stack];
|
||||
|
||||
var trace = this;
|
||||
while (trace !== undefined) {
|
||||
stacks.push(cleanStack(trace.stack.split("\n")));
|
||||
trace = trace._parent;
|
||||
}
|
||||
removeCommonRoots(stacks);
|
||||
removeDuplicateOrEmptyJumps(stacks);
|
||||
util.notEnumerableProp(error, "stack", reconstructStack(message, stacks));
|
||||
util.notEnumerableProp(error, "__stackCleaned__", true);
|
||||
};
|
||||
|
||||
var captureStackTrace = (function stackDetection() {
|
||||
var v8stackFramePattern = /^\s*at\s*/;
|
||||
var v8stackFormatter = function(stack, error) {
|
||||
if (typeof stack === "string") return stack;
|
||||
|
||||
if (error.name !== undefined &&
|
||||
error.message !== undefined) {
|
||||
return error.toString();
|
||||
}
|
||||
return formatNonError(error);
|
||||
};
|
||||
|
||||
if (typeof Error.stackTraceLimit === "number" &&
|
||||
typeof Error.captureStackTrace === "function") {
|
||||
Error.stackTraceLimit += 6;
|
||||
stackFramePattern = v8stackFramePattern;
|
||||
formatStack = v8stackFormatter;
|
||||
var captureStackTrace = Error.captureStackTrace;
|
||||
|
||||
shouldIgnore = function(line) {
|
||||
return bluebirdFramePattern.test(line);
|
||||
};
|
||||
return function(receiver, ignoreUntil) {
|
||||
Error.stackTraceLimit += 6;
|
||||
captureStackTrace(receiver, ignoreUntil);
|
||||
Error.stackTraceLimit -= 6;
|
||||
};
|
||||
}
|
||||
var err = new Error();
|
||||
|
||||
if (typeof err.stack === "string" &&
|
||||
err.stack.split("\n")[0].indexOf("stackDetection@") >= 0) {
|
||||
stackFramePattern = /@/;
|
||||
formatStack = v8stackFormatter;
|
||||
indentStackFrames = true;
|
||||
return function captureStackTrace(o) {
|
||||
o.stack = new Error().stack;
|
||||
};
|
||||
}
|
||||
|
||||
var hasStackAfterThrow;
|
||||
try { throw new Error(); }
|
||||
catch(e) {
|
||||
hasStackAfterThrow = ("stack" in e);
|
||||
}
|
||||
if (!("stack" in err) && hasStackAfterThrow &&
|
||||
typeof Error.stackTraceLimit === "number") {
|
||||
stackFramePattern = v8stackFramePattern;
|
||||
formatStack = v8stackFormatter;
|
||||
return function captureStackTrace(o) {
|
||||
Error.stackTraceLimit += 6;
|
||||
try { throw new Error(); }
|
||||
catch(e) { o.stack = e.stack; }
|
||||
Error.stackTraceLimit -= 6;
|
||||
};
|
||||
}
|
||||
|
||||
formatStack = function(stack, error) {
|
||||
if (typeof stack === "string") return stack;
|
||||
|
||||
if ((typeof error === "object" ||
|
||||
typeof error === "function") &&
|
||||
error.name !== undefined &&
|
||||
error.message !== undefined) {
|
||||
return error.toString();
|
||||
}
|
||||
return formatNonError(error);
|
||||
};
|
||||
|
||||
return null;
|
||||
|
||||
})([]);
|
||||
|
||||
if (typeof console !== "undefined" && typeof console.warn !== "undefined") {
|
||||
printWarning = function (message) {
|
||||
console.warn(message);
|
||||
};
|
||||
if (util.isNode && process.stderr.isTTY) {
|
||||
printWarning = function(message, isSoft) {
|
||||
var color = isSoft ? "\u001b[33m" : "\u001b[31m";
|
||||
console.warn(color + message + "\u001b[0m\n");
|
||||
};
|
||||
} else if (!util.isNode && typeof (new Error().stack) === "string") {
|
||||
printWarning = function(message, isSoft) {
|
||||
console.warn("%c" + message,
|
||||
isSoft ? "color: darkorange" : "color: red");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var config = {
|
||||
warnings: warnings,
|
||||
longStackTraces: false,
|
||||
cancellation: false,
|
||||
monitoring: false
|
||||
};
|
||||
|
||||
if (longStackTraces) Promise.longStackTraces();
|
||||
|
||||
return {
|
||||
longStackTraces: function() {
|
||||
return config.longStackTraces;
|
||||
},
|
||||
warnings: function() {
|
||||
return config.warnings;
|
||||
},
|
||||
cancellation: function() {
|
||||
return config.cancellation;
|
||||
},
|
||||
monitoring: function() {
|
||||
return config.monitoring;
|
||||
},
|
||||
propagateFromFunction: function() {
|
||||
return propagateFromFunction;
|
||||
},
|
||||
boundValueFunction: function() {
|
||||
return boundValueFunction;
|
||||
},
|
||||
checkForgottenReturns: checkForgottenReturns,
|
||||
setBounds: setBounds,
|
||||
warn: warn,
|
||||
deprecated: deprecated,
|
||||
CapturedTrace: CapturedTrace,
|
||||
fireDomEvent: fireDomEvent,
|
||||
fireGlobalEvent: fireGlobalEvent
|
||||
};
|
||||
};
|
||||
46
node_modules/twit/node_modules/bluebird/js/release/direct_resolve.js
generated
vendored
Normal file
46
node_modules/twit/node_modules/bluebird/js/release/direct_resolve.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise) {
|
||||
function returner() {
|
||||
return this.value;
|
||||
}
|
||||
function thrower() {
|
||||
throw this.reason;
|
||||
}
|
||||
|
||||
Promise.prototype["return"] =
|
||||
Promise.prototype.thenReturn = function (value) {
|
||||
if (value instanceof Promise) value.suppressUnhandledRejections();
|
||||
return this._then(
|
||||
returner, undefined, undefined, {value: value}, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype["throw"] =
|
||||
Promise.prototype.thenThrow = function (reason) {
|
||||
return this._then(
|
||||
thrower, undefined, undefined, {reason: reason}, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.catchThrow = function (reason) {
|
||||
if (arguments.length <= 1) {
|
||||
return this._then(
|
||||
undefined, thrower, undefined, {reason: reason}, undefined);
|
||||
} else {
|
||||
var _reason = arguments[1];
|
||||
var handler = function() {throw _reason;};
|
||||
return this.caught(reason, handler);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype.catchReturn = function (value) {
|
||||
if (arguments.length <= 1) {
|
||||
if (value instanceof Promise) value.suppressUnhandledRejections();
|
||||
return this._then(
|
||||
undefined, returner, undefined, {value: value}, undefined);
|
||||
} else {
|
||||
var _value = arguments[1];
|
||||
if (_value instanceof Promise) _value.suppressUnhandledRejections();
|
||||
var handler = function() {return _value;};
|
||||
return this.caught(value, handler);
|
||||
}
|
||||
};
|
||||
};
|
||||
29
node_modules/twit/node_modules/bluebird/js/release/each.js
generated
vendored
Normal file
29
node_modules/twit/node_modules/bluebird/js/release/each.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL) {
|
||||
var PromiseReduce = Promise.reduce;
|
||||
var PromiseAll = Promise.all;
|
||||
|
||||
function promiseAllThis() {
|
||||
return PromiseAll(this);
|
||||
}
|
||||
|
||||
function PromiseMapSeries(promises, fn) {
|
||||
return PromiseReduce(promises, fn, INTERNAL, INTERNAL);
|
||||
}
|
||||
|
||||
Promise.prototype.each = function (fn) {
|
||||
return this.mapSeries(fn)
|
||||
._then(promiseAllThis, undefined, undefined, this, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.mapSeries = function (fn) {
|
||||
return PromiseReduce(this, fn, INTERNAL, INTERNAL);
|
||||
};
|
||||
|
||||
Promise.each = function (promises, fn) {
|
||||
return PromiseMapSeries(promises, fn)
|
||||
._then(promiseAllThis, undefined, undefined, promises, undefined);
|
||||
};
|
||||
|
||||
Promise.mapSeries = PromiseMapSeries;
|
||||
};
|
||||
116
node_modules/twit/node_modules/bluebird/js/release/errors.js
generated
vendored
Normal file
116
node_modules/twit/node_modules/bluebird/js/release/errors.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
"use strict";
|
||||
var es5 = require("./es5");
|
||||
var Objectfreeze = es5.freeze;
|
||||
var util = require("./util");
|
||||
var inherits = util.inherits;
|
||||
var notEnumerableProp = util.notEnumerableProp;
|
||||
|
||||
function subError(nameProperty, defaultMessage) {
|
||||
function SubError(message) {
|
||||
if (!(this instanceof SubError)) return new SubError(message);
|
||||
notEnumerableProp(this, "message",
|
||||
typeof message === "string" ? message : defaultMessage);
|
||||
notEnumerableProp(this, "name", nameProperty);
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
} else {
|
||||
Error.call(this);
|
||||
}
|
||||
}
|
||||
inherits(SubError, Error);
|
||||
return SubError;
|
||||
}
|
||||
|
||||
var _TypeError, _RangeError;
|
||||
var Warning = subError("Warning", "warning");
|
||||
var CancellationError = subError("CancellationError", "cancellation error");
|
||||
var TimeoutError = subError("TimeoutError", "timeout error");
|
||||
var AggregateError = subError("AggregateError", "aggregate error");
|
||||
try {
|
||||
_TypeError = TypeError;
|
||||
_RangeError = RangeError;
|
||||
} catch(e) {
|
||||
_TypeError = subError("TypeError", "type error");
|
||||
_RangeError = subError("RangeError", "range error");
|
||||
}
|
||||
|
||||
var methods = ("join pop push shift unshift slice filter forEach some " +
|
||||
"every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" ");
|
||||
|
||||
for (var i = 0; i < methods.length; ++i) {
|
||||
if (typeof Array.prototype[methods[i]] === "function") {
|
||||
AggregateError.prototype[methods[i]] = Array.prototype[methods[i]];
|
||||
}
|
||||
}
|
||||
|
||||
es5.defineProperty(AggregateError.prototype, "length", {
|
||||
value: 0,
|
||||
configurable: false,
|
||||
writable: true,
|
||||
enumerable: true
|
||||
});
|
||||
AggregateError.prototype["isOperational"] = true;
|
||||
var level = 0;
|
||||
AggregateError.prototype.toString = function() {
|
||||
var indent = Array(level * 4 + 1).join(" ");
|
||||
var ret = "\n" + indent + "AggregateError of:" + "\n";
|
||||
level++;
|
||||
indent = Array(level * 4 + 1).join(" ");
|
||||
for (var i = 0; i < this.length; ++i) {
|
||||
var str = this[i] === this ? "[Circular AggregateError]" : this[i] + "";
|
||||
var lines = str.split("\n");
|
||||
for (var j = 0; j < lines.length; ++j) {
|
||||
lines[j] = indent + lines[j];
|
||||
}
|
||||
str = lines.join("\n");
|
||||
ret += str + "\n";
|
||||
}
|
||||
level--;
|
||||
return ret;
|
||||
};
|
||||
|
||||
function OperationalError(message) {
|
||||
if (!(this instanceof OperationalError))
|
||||
return new OperationalError(message);
|
||||
notEnumerableProp(this, "name", "OperationalError");
|
||||
notEnumerableProp(this, "message", message);
|
||||
this.cause = message;
|
||||
this["isOperational"] = true;
|
||||
|
||||
if (message instanceof Error) {
|
||||
notEnumerableProp(this, "message", message.message);
|
||||
notEnumerableProp(this, "stack", message.stack);
|
||||
} else if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
|
||||
}
|
||||
inherits(OperationalError, Error);
|
||||
|
||||
var errorTypes = Error["__BluebirdErrorTypes__"];
|
||||
if (!errorTypes) {
|
||||
errorTypes = Objectfreeze({
|
||||
CancellationError: CancellationError,
|
||||
TimeoutError: TimeoutError,
|
||||
OperationalError: OperationalError,
|
||||
RejectionError: OperationalError,
|
||||
AggregateError: AggregateError
|
||||
});
|
||||
es5.defineProperty(Error, "__BluebirdErrorTypes__", {
|
||||
value: errorTypes,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Error: Error,
|
||||
TypeError: _TypeError,
|
||||
RangeError: _RangeError,
|
||||
CancellationError: errorTypes.CancellationError,
|
||||
OperationalError: errorTypes.OperationalError,
|
||||
TimeoutError: errorTypes.TimeoutError,
|
||||
AggregateError: errorTypes.AggregateError,
|
||||
Warning: Warning
|
||||
};
|
||||
80
node_modules/twit/node_modules/bluebird/js/release/es5.js
generated
vendored
Normal file
80
node_modules/twit/node_modules/bluebird/js/release/es5.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
var isES5 = (function(){
|
||||
"use strict";
|
||||
return this === undefined;
|
||||
})();
|
||||
|
||||
if (isES5) {
|
||||
module.exports = {
|
||||
freeze: Object.freeze,
|
||||
defineProperty: Object.defineProperty,
|
||||
getDescriptor: Object.getOwnPropertyDescriptor,
|
||||
keys: Object.keys,
|
||||
names: Object.getOwnPropertyNames,
|
||||
getPrototypeOf: Object.getPrototypeOf,
|
||||
isArray: Array.isArray,
|
||||
isES5: isES5,
|
||||
propertyIsWritable: function(obj, prop) {
|
||||
var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
||||
return !!(!descriptor || descriptor.writable || descriptor.set);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
var has = {}.hasOwnProperty;
|
||||
var str = {}.toString;
|
||||
var proto = {}.constructor.prototype;
|
||||
|
||||
var ObjectKeys = function (o) {
|
||||
var ret = [];
|
||||
for (var key in o) {
|
||||
if (has.call(o, key)) {
|
||||
ret.push(key);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
var ObjectGetDescriptor = function(o, key) {
|
||||
return {value: o[key]};
|
||||
};
|
||||
|
||||
var ObjectDefineProperty = function (o, key, desc) {
|
||||
o[key] = desc.value;
|
||||
return o;
|
||||
};
|
||||
|
||||
var ObjectFreeze = function (obj) {
|
||||
return obj;
|
||||
};
|
||||
|
||||
var ObjectGetPrototypeOf = function (obj) {
|
||||
try {
|
||||
return Object(obj).constructor.prototype;
|
||||
}
|
||||
catch (e) {
|
||||
return proto;
|
||||
}
|
||||
};
|
||||
|
||||
var ArrayIsArray = function (obj) {
|
||||
try {
|
||||
return str.call(obj) === "[object Array]";
|
||||
}
|
||||
catch(e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
isArray: ArrayIsArray,
|
||||
keys: ObjectKeys,
|
||||
names: ObjectKeys,
|
||||
defineProperty: ObjectDefineProperty,
|
||||
getDescriptor: ObjectGetDescriptor,
|
||||
freeze: ObjectFreeze,
|
||||
getPrototypeOf: ObjectGetPrototypeOf,
|
||||
isES5: isES5,
|
||||
propertyIsWritable: function() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
12
node_modules/twit/node_modules/bluebird/js/release/filter.js
generated
vendored
Normal file
12
node_modules/twit/node_modules/bluebird/js/release/filter.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL) {
|
||||
var PromiseMap = Promise.map;
|
||||
|
||||
Promise.prototype.filter = function (fn, options) {
|
||||
return PromiseMap(this, fn, options, INTERNAL);
|
||||
};
|
||||
|
||||
Promise.filter = function (promises, fn, options) {
|
||||
return PromiseMap(promises, fn, options, INTERNAL);
|
||||
};
|
||||
};
|
||||
111
node_modules/twit/node_modules/bluebird/js/release/finally.js
generated
vendored
Normal file
111
node_modules/twit/node_modules/bluebird/js/release/finally.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, tryConvertToPromise) {
|
||||
var util = require("./util");
|
||||
var CancellationError = Promise.CancellationError;
|
||||
var errorObj = util.errorObj;
|
||||
|
||||
function PassThroughHandlerContext(promise, type, handler) {
|
||||
this.promise = promise;
|
||||
this.type = type;
|
||||
this.handler = handler;
|
||||
this.called = false;
|
||||
this.cancelPromise = null;
|
||||
}
|
||||
|
||||
PassThroughHandlerContext.prototype.isFinallyHandler = function() {
|
||||
return this.type === 0;
|
||||
};
|
||||
|
||||
function FinallyHandlerCancelReaction(finallyHandler) {
|
||||
this.finallyHandler = finallyHandler;
|
||||
}
|
||||
|
||||
FinallyHandlerCancelReaction.prototype._resultCancelled = function() {
|
||||
checkCancel(this.finallyHandler);
|
||||
};
|
||||
|
||||
function checkCancel(ctx, reason) {
|
||||
if (ctx.cancelPromise != null) {
|
||||
if (arguments.length > 1) {
|
||||
ctx.cancelPromise._reject(reason);
|
||||
} else {
|
||||
ctx.cancelPromise._cancel();
|
||||
}
|
||||
ctx.cancelPromise = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function succeed() {
|
||||
return finallyHandler.call(this, this.promise._target()._settledValue());
|
||||
}
|
||||
function fail(reason) {
|
||||
if (checkCancel(this, reason)) return;
|
||||
errorObj.e = reason;
|
||||
return errorObj;
|
||||
}
|
||||
function finallyHandler(reasonOrValue) {
|
||||
var promise = this.promise;
|
||||
var handler = this.handler;
|
||||
|
||||
if (!this.called) {
|
||||
this.called = true;
|
||||
var ret = this.isFinallyHandler()
|
||||
? handler.call(promise._boundValue())
|
||||
: handler.call(promise._boundValue(), reasonOrValue);
|
||||
if (ret !== undefined) {
|
||||
promise._setReturnedNonUndefined();
|
||||
var maybePromise = tryConvertToPromise(ret, promise);
|
||||
if (maybePromise instanceof Promise) {
|
||||
if (this.cancelPromise != null) {
|
||||
if (maybePromise.isCancelled()) {
|
||||
var reason =
|
||||
new CancellationError("late cancellation observer");
|
||||
promise._attachExtraTrace(reason);
|
||||
errorObj.e = reason;
|
||||
return errorObj;
|
||||
} else if (maybePromise.isPending()) {
|
||||
maybePromise._attachCancellationCallback(
|
||||
new FinallyHandlerCancelReaction(this));
|
||||
}
|
||||
}
|
||||
return maybePromise._then(
|
||||
succeed, fail, undefined, this, undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (promise.isRejected()) {
|
||||
checkCancel(this);
|
||||
errorObj.e = reasonOrValue;
|
||||
return errorObj;
|
||||
} else {
|
||||
checkCancel(this);
|
||||
return reasonOrValue;
|
||||
}
|
||||
}
|
||||
|
||||
Promise.prototype._passThrough = function(handler, type, success, fail) {
|
||||
if (typeof handler !== "function") return this.then();
|
||||
return this._then(success,
|
||||
fail,
|
||||
undefined,
|
||||
new PassThroughHandlerContext(this, type, handler),
|
||||
undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.lastly =
|
||||
Promise.prototype["finally"] = function (handler) {
|
||||
return this._passThrough(handler,
|
||||
0,
|
||||
finallyHandler,
|
||||
finallyHandler);
|
||||
};
|
||||
|
||||
Promise.prototype.tap = function (handler) {
|
||||
return this._passThrough(handler, 1, finallyHandler);
|
||||
};
|
||||
|
||||
return PassThroughHandlerContext;
|
||||
};
|
||||
219
node_modules/twit/node_modules/bluebird/js/release/generators.js
generated
vendored
Normal file
219
node_modules/twit/node_modules/bluebird/js/release/generators.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise,
|
||||
apiRejection,
|
||||
INTERNAL,
|
||||
tryConvertToPromise,
|
||||
Proxyable,
|
||||
debug) {
|
||||
var errors = require("./errors");
|
||||
var TypeError = errors.TypeError;
|
||||
var util = require("./util");
|
||||
var errorObj = util.errorObj;
|
||||
var tryCatch = util.tryCatch;
|
||||
var yieldHandlers = [];
|
||||
|
||||
function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
|
||||
for (var i = 0; i < yieldHandlers.length; ++i) {
|
||||
traceParent._pushContext();
|
||||
var result = tryCatch(yieldHandlers[i])(value);
|
||||
traceParent._popContext();
|
||||
if (result === errorObj) {
|
||||
traceParent._pushContext();
|
||||
var ret = Promise.reject(errorObj.e);
|
||||
traceParent._popContext();
|
||||
return ret;
|
||||
}
|
||||
var maybePromise = tryConvertToPromise(result, traceParent);
|
||||
if (maybePromise instanceof Promise) return maybePromise;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
|
||||
if (debug.cancellation()) {
|
||||
var internal = new Promise(INTERNAL);
|
||||
var _finallyPromise = this._finallyPromise = new Promise(INTERNAL);
|
||||
this._promise = internal.lastly(function() {
|
||||
return _finallyPromise;
|
||||
});
|
||||
internal._captureStackTrace();
|
||||
internal._setOnCancel(this);
|
||||
} else {
|
||||
var promise = this._promise = new Promise(INTERNAL);
|
||||
promise._captureStackTrace();
|
||||
}
|
||||
this._stack = stack;
|
||||
this._generatorFunction = generatorFunction;
|
||||
this._receiver = receiver;
|
||||
this._generator = undefined;
|
||||
this._yieldHandlers = typeof yieldHandler === "function"
|
||||
? [yieldHandler].concat(yieldHandlers)
|
||||
: yieldHandlers;
|
||||
this._yieldedPromise = null;
|
||||
this._cancellationPhase = false;
|
||||
}
|
||||
util.inherits(PromiseSpawn, Proxyable);
|
||||
|
||||
PromiseSpawn.prototype._isResolved = function() {
|
||||
return this._promise === null;
|
||||
};
|
||||
|
||||
PromiseSpawn.prototype._cleanup = function() {
|
||||
this._promise = this._generator = null;
|
||||
if (debug.cancellation() && this._finallyPromise !== null) {
|
||||
this._finallyPromise._fulfill();
|
||||
this._finallyPromise = null;
|
||||
}
|
||||
};
|
||||
|
||||
PromiseSpawn.prototype._promiseCancelled = function() {
|
||||
if (this._isResolved()) return;
|
||||
var implementsReturn = typeof this._generator["return"] !== "undefined";
|
||||
|
||||
var result;
|
||||
if (!implementsReturn) {
|
||||
var reason = new Promise.CancellationError(
|
||||
"generator .return() sentinel");
|
||||
Promise.coroutine.returnSentinel = reason;
|
||||
this._promise._attachExtraTrace(reason);
|
||||
this._promise._pushContext();
|
||||
result = tryCatch(this._generator["throw"]).call(this._generator,
|
||||
reason);
|
||||
this._promise._popContext();
|
||||
} else {
|
||||
this._promise._pushContext();
|
||||
result = tryCatch(this._generator["return"]).call(this._generator,
|
||||
undefined);
|
||||
this._promise._popContext();
|
||||
}
|
||||
this._cancellationPhase = true;
|
||||
this._yieldedPromise = null;
|
||||
this._continue(result);
|
||||
};
|
||||
|
||||
PromiseSpawn.prototype._promiseFulfilled = function(value) {
|
||||
this._yieldedPromise = null;
|
||||
this._promise._pushContext();
|
||||
var result = tryCatch(this._generator.next).call(this._generator, value);
|
||||
this._promise._popContext();
|
||||
this._continue(result);
|
||||
};
|
||||
|
||||
PromiseSpawn.prototype._promiseRejected = function(reason) {
|
||||
this._yieldedPromise = null;
|
||||
this._promise._attachExtraTrace(reason);
|
||||
this._promise._pushContext();
|
||||
var result = tryCatch(this._generator["throw"])
|
||||
.call(this._generator, reason);
|
||||
this._promise._popContext();
|
||||
this._continue(result);
|
||||
};
|
||||
|
||||
PromiseSpawn.prototype._resultCancelled = function() {
|
||||
if (this._yieldedPromise instanceof Promise) {
|
||||
var promise = this._yieldedPromise;
|
||||
this._yieldedPromise = null;
|
||||
promise.cancel();
|
||||
}
|
||||
};
|
||||
|
||||
PromiseSpawn.prototype.promise = function () {
|
||||
return this._promise;
|
||||
};
|
||||
|
||||
PromiseSpawn.prototype._run = function () {
|
||||
this._generator = this._generatorFunction.call(this._receiver);
|
||||
this._receiver =
|
||||
this._generatorFunction = undefined;
|
||||
this._promiseFulfilled(undefined);
|
||||
};
|
||||
|
||||
PromiseSpawn.prototype._continue = function (result) {
|
||||
var promise = this._promise;
|
||||
if (result === errorObj) {
|
||||
this._cleanup();
|
||||
if (this._cancellationPhase) {
|
||||
return promise.cancel();
|
||||
} else {
|
||||
return promise._rejectCallback(result.e, false);
|
||||
}
|
||||
}
|
||||
|
||||
var value = result.value;
|
||||
if (result.done === true) {
|
||||
this._cleanup();
|
||||
if (this._cancellationPhase) {
|
||||
return promise.cancel();
|
||||
} else {
|
||||
return promise._resolveCallback(value);
|
||||
}
|
||||
} else {
|
||||
var maybePromise = tryConvertToPromise(value, this._promise);
|
||||
if (!(maybePromise instanceof Promise)) {
|
||||
maybePromise =
|
||||
promiseFromYieldHandler(maybePromise,
|
||||
this._yieldHandlers,
|
||||
this._promise);
|
||||
if (maybePromise === null) {
|
||||
this._promiseRejected(
|
||||
new TypeError(
|
||||
"A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/MqrFmX\u000a\u000a".replace("%s", value) +
|
||||
"From coroutine:\u000a" +
|
||||
this._stack.split("\n").slice(1, -7).join("\n")
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
maybePromise = maybePromise._target();
|
||||
var bitField = maybePromise._bitField;
|
||||
;
|
||||
if (((bitField & 50397184) === 0)) {
|
||||
this._yieldedPromise = maybePromise;
|
||||
maybePromise._proxy(this, null);
|
||||
} else if (((bitField & 33554432) !== 0)) {
|
||||
this._promiseFulfilled(maybePromise._value());
|
||||
} else if (((bitField & 16777216) !== 0)) {
|
||||
this._promiseRejected(maybePromise._reason());
|
||||
} else {
|
||||
this._promiseCancelled();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Promise.coroutine = function (generatorFunction, options) {
|
||||
if (typeof generatorFunction !== "function") {
|
||||
throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
}
|
||||
var yieldHandler = Object(options).yieldHandler;
|
||||
var PromiseSpawn$ = PromiseSpawn;
|
||||
var stack = new Error().stack;
|
||||
return function () {
|
||||
var generator = generatorFunction.apply(this, arguments);
|
||||
var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
|
||||
stack);
|
||||
var ret = spawn.promise();
|
||||
spawn._generator = generator;
|
||||
spawn._promiseFulfilled(undefined);
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
|
||||
Promise.coroutine.addYieldHandler = function(fn) {
|
||||
if (typeof fn !== "function") {
|
||||
throw new TypeError("expecting a function but got " + util.classString(fn));
|
||||
}
|
||||
yieldHandlers.push(fn);
|
||||
};
|
||||
|
||||
Promise.spawn = function (generatorFunction) {
|
||||
debug.deprecated("Promise.spawn()", "Promise.coroutine()");
|
||||
if (typeof generatorFunction !== "function") {
|
||||
return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
}
|
||||
var spawn = new PromiseSpawn(generatorFunction, this);
|
||||
var ret = spawn.promise();
|
||||
spawn._run(Promise.spawn);
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
149
node_modules/twit/node_modules/bluebird/js/release/join.js
generated
vendored
Normal file
149
node_modules/twit/node_modules/bluebird/js/release/join.js
generated
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
"use strict";
|
||||
module.exports =
|
||||
function(Promise, PromiseArray, tryConvertToPromise, INTERNAL) {
|
||||
var util = require("./util");
|
||||
var canEvaluate = util.canEvaluate;
|
||||
var tryCatch = util.tryCatch;
|
||||
var errorObj = util.errorObj;
|
||||
var reject;
|
||||
|
||||
if (!false) {
|
||||
if (canEvaluate) {
|
||||
var thenCallback = function(i) {
|
||||
return new Function("value", "holder", " \n\
|
||||
'use strict'; \n\
|
||||
holder.pIndex = value; \n\
|
||||
holder.checkFulfillment(this); \n\
|
||||
".replace(/Index/g, i));
|
||||
};
|
||||
|
||||
var promiseSetter = function(i) {
|
||||
return new Function("promise", "holder", " \n\
|
||||
'use strict'; \n\
|
||||
holder.pIndex = promise; \n\
|
||||
".replace(/Index/g, i));
|
||||
};
|
||||
|
||||
var generateHolderClass = function(total) {
|
||||
var props = new Array(total);
|
||||
for (var i = 0; i < props.length; ++i) {
|
||||
props[i] = "this.p" + (i+1);
|
||||
}
|
||||
var assignment = props.join(" = ") + " = null;";
|
||||
var cancellationCode= "var promise;\n" + props.map(function(prop) {
|
||||
return " \n\
|
||||
promise = " + prop + "; \n\
|
||||
if (promise instanceof Promise) { \n\
|
||||
promise.cancel(); \n\
|
||||
} \n\
|
||||
";
|
||||
}).join("\n");
|
||||
var passedArguments = props.join(", ");
|
||||
var name = "Holder$" + total;
|
||||
|
||||
|
||||
var code = "return function(tryCatch, errorObj, Promise) { \n\
|
||||
'use strict'; \n\
|
||||
function [TheName](fn) { \n\
|
||||
[TheProperties] \n\
|
||||
this.fn = fn; \n\
|
||||
this.now = 0; \n\
|
||||
} \n\
|
||||
[TheName].prototype.checkFulfillment = function(promise) { \n\
|
||||
var now = ++this.now; \n\
|
||||
if (now === [TheTotal]) { \n\
|
||||
promise._pushContext(); \n\
|
||||
var callback = this.fn; \n\
|
||||
var ret = tryCatch(callback)([ThePassedArguments]); \n\
|
||||
promise._popContext(); \n\
|
||||
if (ret === errorObj) { \n\
|
||||
promise._rejectCallback(ret.e, false); \n\
|
||||
} else { \n\
|
||||
promise._resolveCallback(ret); \n\
|
||||
} \n\
|
||||
} \n\
|
||||
}; \n\
|
||||
\n\
|
||||
[TheName].prototype._resultCancelled = function() { \n\
|
||||
[CancellationCode] \n\
|
||||
}; \n\
|
||||
\n\
|
||||
return [TheName]; \n\
|
||||
}(tryCatch, errorObj, Promise); \n\
|
||||
";
|
||||
|
||||
code = code.replace(/\[TheName\]/g, name)
|
||||
.replace(/\[TheTotal\]/g, total)
|
||||
.replace(/\[ThePassedArguments\]/g, passedArguments)
|
||||
.replace(/\[TheProperties\]/g, assignment)
|
||||
.replace(/\[CancellationCode\]/g, cancellationCode);
|
||||
|
||||
return new Function("tryCatch", "errorObj", "Promise", code)
|
||||
(tryCatch, errorObj, Promise);
|
||||
};
|
||||
|
||||
var holderClasses = [];
|
||||
var thenCallbacks = [];
|
||||
var promiseSetters = [];
|
||||
|
||||
for (var i = 0; i < 8; ++i) {
|
||||
holderClasses.push(generateHolderClass(i + 1));
|
||||
thenCallbacks.push(thenCallback(i + 1));
|
||||
promiseSetters.push(promiseSetter(i + 1));
|
||||
}
|
||||
|
||||
reject = function (reason) {
|
||||
this._reject(reason);
|
||||
};
|
||||
}}
|
||||
|
||||
Promise.join = function () {
|
||||
var last = arguments.length - 1;
|
||||
var fn;
|
||||
if (last > 0 && typeof arguments[last] === "function") {
|
||||
fn = arguments[last];
|
||||
if (!false) {
|
||||
if (last <= 8 && canEvaluate) {
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
var HolderClass = holderClasses[last - 1];
|
||||
var holder = new HolderClass(fn);
|
||||
var callbacks = thenCallbacks;
|
||||
|
||||
for (var i = 0; i < last; ++i) {
|
||||
var maybePromise = tryConvertToPromise(arguments[i], ret);
|
||||
if (maybePromise instanceof Promise) {
|
||||
maybePromise = maybePromise._target();
|
||||
var bitField = maybePromise._bitField;
|
||||
;
|
||||
if (((bitField & 50397184) === 0)) {
|
||||
maybePromise._then(callbacks[i], reject,
|
||||
undefined, ret, holder);
|
||||
promiseSetters[i](maybePromise, holder);
|
||||
} else if (((bitField & 33554432) !== 0)) {
|
||||
callbacks[i].call(ret,
|
||||
maybePromise._value(), holder);
|
||||
} else if (((bitField & 16777216) !== 0)) {
|
||||
ret._reject(maybePromise._reason());
|
||||
} else {
|
||||
ret._cancel();
|
||||
}
|
||||
} else {
|
||||
callbacks[i].call(ret, maybePromise, holder);
|
||||
}
|
||||
}
|
||||
if (!ret._isFateSealed()) {
|
||||
ret._setAsyncGuaranteed();
|
||||
ret._setOnCancel(holder);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];};
|
||||
if (fn) args.pop();
|
||||
var ret = new PromiseArray(args).promise();
|
||||
return fn !== undefined ? ret.spread(fn) : ret;
|
||||
};
|
||||
|
||||
};
|
||||
164
node_modules/twit/node_modules/bluebird/js/release/map.js
generated
vendored
Normal file
164
node_modules/twit/node_modules/bluebird/js/release/map.js
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise,
|
||||
PromiseArray,
|
||||
apiRejection,
|
||||
tryConvertToPromise,
|
||||
INTERNAL,
|
||||
debug) {
|
||||
var getDomain = Promise._getDomain;
|
||||
var util = require("./util");
|
||||
var tryCatch = util.tryCatch;
|
||||
var errorObj = util.errorObj;
|
||||
var EMPTY_ARRAY = [];
|
||||
|
||||
function MappingPromiseArray(promises, fn, limit, _filter) {
|
||||
this.constructor$(promises);
|
||||
this._promise._captureStackTrace();
|
||||
var domain = getDomain();
|
||||
this._callback = domain === null ? fn : domain.bind(fn);
|
||||
this._preservedValues = _filter === INTERNAL
|
||||
? new Array(this.length())
|
||||
: null;
|
||||
this._limit = limit;
|
||||
this._inFlight = 0;
|
||||
this._queue = limit >= 1 ? [] : EMPTY_ARRAY;
|
||||
this._init$(undefined, -2);
|
||||
}
|
||||
util.inherits(MappingPromiseArray, PromiseArray);
|
||||
|
||||
MappingPromiseArray.prototype._init = function () {};
|
||||
|
||||
MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
||||
var values = this._values;
|
||||
var length = this.length();
|
||||
var preservedValues = this._preservedValues;
|
||||
var limit = this._limit;
|
||||
|
||||
if (index < 0) {
|
||||
index = (index * -1) - 1;
|
||||
values[index] = value;
|
||||
if (limit >= 1) {
|
||||
this._inFlight--;
|
||||
this._drainQueue();
|
||||
if (this._isResolved()) return true;
|
||||
}
|
||||
} else {
|
||||
if (limit >= 1 && this._inFlight >= limit) {
|
||||
values[index] = value;
|
||||
this._queue.push(index);
|
||||
return false;
|
||||
}
|
||||
if (preservedValues !== null) preservedValues[index] = value;
|
||||
|
||||
var promise = this._promise;
|
||||
var callback = this._callback;
|
||||
var receiver = promise._boundValue();
|
||||
promise._pushContext();
|
||||
var ret = tryCatch(callback).call(receiver, value, index, length);
|
||||
var promiseCreated = promise._popContext();
|
||||
debug.checkForgottenReturns(
|
||||
ret,
|
||||
promiseCreated,
|
||||
preservedValues !== null ? "Promise.filter" : "Promise.map",
|
||||
promise
|
||||
);
|
||||
if (ret === errorObj) {
|
||||
this._reject(ret.e);
|
||||
return true;
|
||||
}
|
||||
|
||||
var maybePromise = tryConvertToPromise(ret, this._promise);
|
||||
if (maybePromise instanceof Promise) {
|
||||
maybePromise = maybePromise._target();
|
||||
var bitField = maybePromise._bitField;
|
||||
;
|
||||
if (((bitField & 50397184) === 0)) {
|
||||
if (limit >= 1) this._inFlight++;
|
||||
values[index] = maybePromise;
|
||||
maybePromise._proxy(this, (index + 1) * -1);
|
||||
return false;
|
||||
} else if (((bitField & 33554432) !== 0)) {
|
||||
ret = maybePromise._value();
|
||||
} else if (((bitField & 16777216) !== 0)) {
|
||||
this._reject(maybePromise._reason());
|
||||
return true;
|
||||
} else {
|
||||
this._cancel();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
values[index] = ret;
|
||||
}
|
||||
var totalResolved = ++this._totalResolved;
|
||||
if (totalResolved >= length) {
|
||||
if (preservedValues !== null) {
|
||||
this._filter(values, preservedValues);
|
||||
} else {
|
||||
this._resolve(values);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
MappingPromiseArray.prototype._drainQueue = function () {
|
||||
var queue = this._queue;
|
||||
var limit = this._limit;
|
||||
var values = this._values;
|
||||
while (queue.length > 0 && this._inFlight < limit) {
|
||||
if (this._isResolved()) return;
|
||||
var index = queue.pop();
|
||||
this._promiseFulfilled(values[index], index);
|
||||
}
|
||||
};
|
||||
|
||||
MappingPromiseArray.prototype._filter = function (booleans, values) {
|
||||
var len = values.length;
|
||||
var ret = new Array(len);
|
||||
var j = 0;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
if (booleans[i]) ret[j++] = values[i];
|
||||
}
|
||||
ret.length = j;
|
||||
this._resolve(ret);
|
||||
};
|
||||
|
||||
MappingPromiseArray.prototype.preservedValues = function () {
|
||||
return this._preservedValues;
|
||||
};
|
||||
|
||||
function map(promises, fn, options, _filter) {
|
||||
if (typeof fn !== "function") {
|
||||
return apiRejection("expecting a function but got " + util.classString(fn));
|
||||
}
|
||||
|
||||
var limit = 0;
|
||||
if (options !== undefined) {
|
||||
if (typeof options === "object" && options !== null) {
|
||||
if (typeof options.concurrency !== "number") {
|
||||
return Promise.reject(
|
||||
new TypeError("'concurrency' must be a number but it is " +
|
||||
util.classString(options.concurrency)));
|
||||
}
|
||||
limit = options.concurrency;
|
||||
} else {
|
||||
return Promise.reject(new TypeError(
|
||||
"options argument must be an object but it is " +
|
||||
util.classString(options)));
|
||||
}
|
||||
}
|
||||
limit = typeof limit === "number" &&
|
||||
isFinite(limit) && limit >= 1 ? limit : 0;
|
||||
return new MappingPromiseArray(promises, fn, limit, _filter).promise();
|
||||
}
|
||||
|
||||
Promise.prototype.map = function (fn, options) {
|
||||
return map(this, fn, options, null);
|
||||
};
|
||||
|
||||
Promise.map = function (promises, fn, options, _filter) {
|
||||
return map(promises, fn, options, _filter);
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
55
node_modules/twit/node_modules/bluebird/js/release/method.js
generated
vendored
Normal file
55
node_modules/twit/node_modules/bluebird/js/release/method.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
module.exports =
|
||||
function(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug) {
|
||||
var util = require("./util");
|
||||
var tryCatch = util.tryCatch;
|
||||
|
||||
Promise.method = function (fn) {
|
||||
if (typeof fn !== "function") {
|
||||
throw new Promise.TypeError("expecting a function but got " + util.classString(fn));
|
||||
}
|
||||
return function () {
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
ret._pushContext();
|
||||
var value = tryCatch(fn).apply(this, arguments);
|
||||
var promiseCreated = ret._popContext();
|
||||
debug.checkForgottenReturns(
|
||||
value, promiseCreated, "Promise.method", ret);
|
||||
ret._resolveFromSyncValue(value);
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
|
||||
Promise.attempt = Promise["try"] = function (fn) {
|
||||
if (typeof fn !== "function") {
|
||||
return apiRejection("expecting a function but got " + util.classString(fn));
|
||||
}
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
ret._pushContext();
|
||||
var value;
|
||||
if (arguments.length > 1) {
|
||||
debug.deprecated("calling Promise.try with more than 1 argument");
|
||||
var arg = arguments[1];
|
||||
var ctx = arguments[2];
|
||||
value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg)
|
||||
: tryCatch(fn).call(ctx, arg);
|
||||
} else {
|
||||
value = tryCatch(fn)();
|
||||
}
|
||||
var promiseCreated = ret._popContext();
|
||||
debug.checkForgottenReturns(
|
||||
value, promiseCreated, "Promise.try", ret);
|
||||
ret._resolveFromSyncValue(value);
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype._resolveFromSyncValue = function (value) {
|
||||
if (value === util.errorObj) {
|
||||
this._rejectCallback(value.e, false);
|
||||
} else {
|
||||
this._resolveCallback(value, true);
|
||||
}
|
||||
};
|
||||
};
|
||||
51
node_modules/twit/node_modules/bluebird/js/release/nodeback.js
generated
vendored
Normal file
51
node_modules/twit/node_modules/bluebird/js/release/nodeback.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
var util = require("./util");
|
||||
var maybeWrapAsError = util.maybeWrapAsError;
|
||||
var errors = require("./errors");
|
||||
var OperationalError = errors.OperationalError;
|
||||
var es5 = require("./es5");
|
||||
|
||||
function isUntypedError(obj) {
|
||||
return obj instanceof Error &&
|
||||
es5.getPrototypeOf(obj) === Error.prototype;
|
||||
}
|
||||
|
||||
var rErrorKey = /^(?:name|message|stack|cause)$/;
|
||||
function wrapAsOperationalError(obj) {
|
||||
var ret;
|
||||
if (isUntypedError(obj)) {
|
||||
ret = new OperationalError(obj);
|
||||
ret.name = obj.name;
|
||||
ret.message = obj.message;
|
||||
ret.stack = obj.stack;
|
||||
var keys = es5.keys(obj);
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
if (!rErrorKey.test(key)) {
|
||||
ret[key] = obj[key];
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
util.markAsOriginatingFromRejection(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
function nodebackForPromise(promise, multiArgs) {
|
||||
return function(err, value) {
|
||||
if (promise === null) return;
|
||||
if (err) {
|
||||
var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
|
||||
promise._attachExtraTrace(wrapped);
|
||||
promise._reject(wrapped);
|
||||
} else if (!multiArgs) {
|
||||
promise._fulfill(value);
|
||||
} else {
|
||||
var $_len = arguments.length;var args = new Array(Math.max($_len - 1, 0)); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];};
|
||||
promise._fulfill(args);
|
||||
}
|
||||
promise = null;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = nodebackForPromise;
|
||||
58
node_modules/twit/node_modules/bluebird/js/release/nodeify.js
generated
vendored
Normal file
58
node_modules/twit/node_modules/bluebird/js/release/nodeify.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise) {
|
||||
var util = require("./util");
|
||||
var async = Promise._async;
|
||||
var tryCatch = util.tryCatch;
|
||||
var errorObj = util.errorObj;
|
||||
|
||||
function spreadAdapter(val, nodeback) {
|
||||
var promise = this;
|
||||
if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
|
||||
var ret =
|
||||
tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
|
||||
if (ret === errorObj) {
|
||||
async.throwLater(ret.e);
|
||||
}
|
||||
}
|
||||
|
||||
function successAdapter(val, nodeback) {
|
||||
var promise = this;
|
||||
var receiver = promise._boundValue();
|
||||
var ret = val === undefined
|
||||
? tryCatch(nodeback).call(receiver, null)
|
||||
: tryCatch(nodeback).call(receiver, null, val);
|
||||
if (ret === errorObj) {
|
||||
async.throwLater(ret.e);
|
||||
}
|
||||
}
|
||||
function errorAdapter(reason, nodeback) {
|
||||
var promise = this;
|
||||
if (!reason) {
|
||||
var newReason = new Error(reason + "");
|
||||
newReason.cause = reason;
|
||||
reason = newReason;
|
||||
}
|
||||
var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
|
||||
if (ret === errorObj) {
|
||||
async.throwLater(ret.e);
|
||||
}
|
||||
}
|
||||
|
||||
Promise.prototype.asCallback = Promise.prototype.nodeify = function (nodeback,
|
||||
options) {
|
||||
if (typeof nodeback == "function") {
|
||||
var adapter = successAdapter;
|
||||
if (options !== undefined && Object(options).spread) {
|
||||
adapter = spreadAdapter;
|
||||
}
|
||||
this._then(
|
||||
adapter,
|
||||
errorAdapter,
|
||||
undefined,
|
||||
this,
|
||||
nodeback
|
||||
);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
};
|
||||
767
node_modules/twit/node_modules/bluebird/js/release/promise.js
generated
vendored
Normal file
767
node_modules/twit/node_modules/bluebird/js/release/promise.js
generated
vendored
Normal file
@@ -0,0 +1,767 @@
|
||||
"use strict";
|
||||
module.exports = function() {
|
||||
var makeSelfResolutionError = function () {
|
||||
return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
};
|
||||
var reflectHandler = function() {
|
||||
return new Promise.PromiseInspection(this._target());
|
||||
};
|
||||
var apiRejection = function(msg) {
|
||||
return Promise.reject(new TypeError(msg));
|
||||
};
|
||||
function Proxyable() {}
|
||||
var UNDEFINED_BINDING = {};
|
||||
var util = require("./util");
|
||||
|
||||
var getDomain;
|
||||
if (util.isNode) {
|
||||
getDomain = function() {
|
||||
var ret = process.domain;
|
||||
if (ret === undefined) ret = null;
|
||||
return ret;
|
||||
};
|
||||
} else {
|
||||
getDomain = function() {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
util.notEnumerableProp(Promise, "_getDomain", getDomain);
|
||||
|
||||
var es5 = require("./es5");
|
||||
var Async = require("./async");
|
||||
var async = new Async();
|
||||
es5.defineProperty(Promise, "_async", {value: async});
|
||||
var errors = require("./errors");
|
||||
var TypeError = Promise.TypeError = errors.TypeError;
|
||||
Promise.RangeError = errors.RangeError;
|
||||
var CancellationError = Promise.CancellationError = errors.CancellationError;
|
||||
Promise.TimeoutError = errors.TimeoutError;
|
||||
Promise.OperationalError = errors.OperationalError;
|
||||
Promise.RejectionError = errors.OperationalError;
|
||||
Promise.AggregateError = errors.AggregateError;
|
||||
var INTERNAL = function(){};
|
||||
var APPLY = {};
|
||||
var NEXT_FILTER = {};
|
||||
var tryConvertToPromise = require("./thenables")(Promise, INTERNAL);
|
||||
var PromiseArray =
|
||||
require("./promise_array")(Promise, INTERNAL,
|
||||
tryConvertToPromise, apiRejection, Proxyable);
|
||||
var Context = require("./context")(Promise);
|
||||
/*jshint unused:false*/
|
||||
var createContext = Context.create;
|
||||
var debug = require("./debuggability")(Promise, Context);
|
||||
var CapturedTrace = debug.CapturedTrace;
|
||||
var PassThroughHandlerContext =
|
||||
require("./finally")(Promise, tryConvertToPromise);
|
||||
var catchFilter = require("./catch_filter")(NEXT_FILTER);
|
||||
var nodebackForPromise = require("./nodeback");
|
||||
var errorObj = util.errorObj;
|
||||
var tryCatch = util.tryCatch;
|
||||
function check(self, executor) {
|
||||
if (typeof executor !== "function") {
|
||||
throw new TypeError("expecting a function but got " + util.classString(executor));
|
||||
}
|
||||
if (self.constructor !== Promise) {
|
||||
throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
}
|
||||
}
|
||||
|
||||
function Promise(executor) {
|
||||
this._bitField = 0;
|
||||
this._fulfillmentHandler0 = undefined;
|
||||
this._rejectionHandler0 = undefined;
|
||||
this._promise0 = undefined;
|
||||
this._receiver0 = undefined;
|
||||
if (executor !== INTERNAL) {
|
||||
check(this, executor);
|
||||
this._resolveFromExecutor(executor);
|
||||
}
|
||||
this._promiseCreated();
|
||||
this._fireEvent("promiseCreated", this);
|
||||
}
|
||||
|
||||
Promise.prototype.toString = function () {
|
||||
return "[object Promise]";
|
||||
};
|
||||
|
||||
Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
|
||||
var len = arguments.length;
|
||||
if (len > 1) {
|
||||
var catchInstances = new Array(len - 1),
|
||||
j = 0, i;
|
||||
for (i = 0; i < len - 1; ++i) {
|
||||
var item = arguments[i];
|
||||
if (util.isObject(item)) {
|
||||
catchInstances[j++] = item;
|
||||
} else {
|
||||
return apiRejection("expecting an object but got " + util.classString(item));
|
||||
}
|
||||
}
|
||||
catchInstances.length = j;
|
||||
fn = arguments[i];
|
||||
return this.then(undefined, catchFilter(catchInstances, fn, this));
|
||||
}
|
||||
return this.then(undefined, fn);
|
||||
};
|
||||
|
||||
Promise.prototype.reflect = function () {
|
||||
return this._then(reflectHandler,
|
||||
reflectHandler, undefined, this, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.then = function (didFulfill, didReject) {
|
||||
if (debug.warnings() && arguments.length > 0 &&
|
||||
typeof didFulfill !== "function" &&
|
||||
typeof didReject !== "function") {
|
||||
var msg = ".then() only accepts functions but was passed: " +
|
||||
util.classString(didFulfill);
|
||||
if (arguments.length > 1) {
|
||||
msg += ", " + util.classString(didReject);
|
||||
}
|
||||
this._warn(msg);
|
||||
}
|
||||
return this._then(didFulfill, didReject, undefined, undefined, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.done = function (didFulfill, didReject) {
|
||||
var promise =
|
||||
this._then(didFulfill, didReject, undefined, undefined, undefined);
|
||||
promise._setIsFinal();
|
||||
};
|
||||
|
||||
Promise.prototype.spread = function (fn) {
|
||||
if (typeof fn !== "function") {
|
||||
return apiRejection("expecting a function but got " + util.classString(fn));
|
||||
}
|
||||
return this.all()._then(fn, undefined, undefined, APPLY, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.toJSON = function () {
|
||||
var ret = {
|
||||
isFulfilled: false,
|
||||
isRejected: false,
|
||||
fulfillmentValue: undefined,
|
||||
rejectionReason: undefined
|
||||
};
|
||||
if (this.isFulfilled()) {
|
||||
ret.fulfillmentValue = this.value();
|
||||
ret.isFulfilled = true;
|
||||
} else if (this.isRejected()) {
|
||||
ret.rejectionReason = this.reason();
|
||||
ret.isRejected = true;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype.all = function () {
|
||||
if (arguments.length > 0) {
|
||||
this._warn(".all() was passed arguments but it does not take any");
|
||||
}
|
||||
return new PromiseArray(this).promise();
|
||||
};
|
||||
|
||||
Promise.prototype.error = function (fn) {
|
||||
return this.caught(util.originatesFromRejection, fn);
|
||||
};
|
||||
|
||||
Promise.getNewLibraryCopy = module.exports;
|
||||
|
||||
Promise.is = function (val) {
|
||||
return val instanceof Promise;
|
||||
};
|
||||
|
||||
Promise.fromNode = Promise.fromCallback = function(fn) {
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs
|
||||
: false;
|
||||
var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs));
|
||||
if (result === errorObj) {
|
||||
ret._rejectCallback(result.e, true);
|
||||
}
|
||||
if (!ret._isFateSealed()) ret._setAsyncGuaranteed();
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.all = function (promises) {
|
||||
return new PromiseArray(promises).promise();
|
||||
};
|
||||
|
||||
Promise.cast = function (obj) {
|
||||
var ret = tryConvertToPromise(obj);
|
||||
if (!(ret instanceof Promise)) {
|
||||
ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
ret._setFulfilled();
|
||||
ret._rejectionHandler0 = obj;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.resolve = Promise.fulfilled = Promise.cast;
|
||||
|
||||
Promise.reject = Promise.rejected = function (reason) {
|
||||
var ret = new Promise(INTERNAL);
|
||||
ret._captureStackTrace();
|
||||
ret._rejectCallback(reason, true);
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.setScheduler = function(fn) {
|
||||
if (typeof fn !== "function") {
|
||||
throw new TypeError("expecting a function but got " + util.classString(fn));
|
||||
}
|
||||
return async.setScheduler(fn);
|
||||
};
|
||||
|
||||
Promise.prototype._then = function (
|
||||
didFulfill,
|
||||
didReject,
|
||||
_, receiver,
|
||||
internalData
|
||||
) {
|
||||
var haveInternalData = internalData !== undefined;
|
||||
var promise = haveInternalData ? internalData : new Promise(INTERNAL);
|
||||
var target = this._target();
|
||||
var bitField = target._bitField;
|
||||
|
||||
if (!haveInternalData) {
|
||||
promise._propagateFrom(this, 3);
|
||||
promise._captureStackTrace();
|
||||
if (receiver === undefined &&
|
||||
((this._bitField & 2097152) !== 0)) {
|
||||
if (!((bitField & 50397184) === 0)) {
|
||||
receiver = this._boundValue();
|
||||
} else {
|
||||
receiver = target === this ? undefined : this._boundTo;
|
||||
}
|
||||
}
|
||||
this._fireEvent("promiseChained", this, promise);
|
||||
}
|
||||
|
||||
var domain = getDomain();
|
||||
if (!((bitField & 50397184) === 0)) {
|
||||
var handler, value, settler = target._settlePromiseCtx;
|
||||
if (((bitField & 33554432) !== 0)) {
|
||||
value = target._rejectionHandler0;
|
||||
handler = didFulfill;
|
||||
} else if (((bitField & 16777216) !== 0)) {
|
||||
value = target._fulfillmentHandler0;
|
||||
handler = didReject;
|
||||
target._unsetRejectionIsUnhandled();
|
||||
} else {
|
||||
settler = target._settlePromiseLateCancellationObserver;
|
||||
value = new CancellationError("late cancellation observer");
|
||||
target._attachExtraTrace(value);
|
||||
handler = didReject;
|
||||
}
|
||||
|
||||
async.invoke(settler, target, {
|
||||
handler: domain === null ? handler
|
||||
: (typeof handler === "function" && domain.bind(handler)),
|
||||
promise: promise,
|
||||
receiver: receiver,
|
||||
value: value
|
||||
});
|
||||
} else {
|
||||
target._addCallbacks(didFulfill, didReject, promise, receiver, domain);
|
||||
}
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
Promise.prototype._length = function () {
|
||||
return this._bitField & 65535;
|
||||
};
|
||||
|
||||
Promise.prototype._isFateSealed = function () {
|
||||
return (this._bitField & 117506048) !== 0;
|
||||
};
|
||||
|
||||
Promise.prototype._isFollowing = function () {
|
||||
return (this._bitField & 67108864) === 67108864;
|
||||
};
|
||||
|
||||
Promise.prototype._setLength = function (len) {
|
||||
this._bitField = (this._bitField & -65536) |
|
||||
(len & 65535);
|
||||
};
|
||||
|
||||
Promise.prototype._setFulfilled = function () {
|
||||
this._bitField = this._bitField | 33554432;
|
||||
this._fireEvent("promiseFulfilled", this);
|
||||
};
|
||||
|
||||
Promise.prototype._setRejected = function () {
|
||||
this._bitField = this._bitField | 16777216;
|
||||
this._fireEvent("promiseRejected", this);
|
||||
};
|
||||
|
||||
Promise.prototype._setFollowing = function () {
|
||||
this._bitField = this._bitField | 67108864;
|
||||
this._fireEvent("promiseResolved", this);
|
||||
};
|
||||
|
||||
Promise.prototype._setIsFinal = function () {
|
||||
this._bitField = this._bitField | 4194304;
|
||||
};
|
||||
|
||||
Promise.prototype._isFinal = function () {
|
||||
return (this._bitField & 4194304) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._unsetCancelled = function() {
|
||||
this._bitField = this._bitField & (~65536);
|
||||
};
|
||||
|
||||
Promise.prototype._setCancelled = function() {
|
||||
this._bitField = this._bitField | 65536;
|
||||
this._fireEvent("promiseCancelled", this);
|
||||
};
|
||||
|
||||
Promise.prototype._setAsyncGuaranteed = function() {
|
||||
if (async.hasCustomScheduler()) return;
|
||||
this._bitField = this._bitField | 134217728;
|
||||
};
|
||||
|
||||
Promise.prototype._receiverAt = function (index) {
|
||||
var ret = index === 0 ? this._receiver0 : this[
|
||||
index * 4 - 4 + 3];
|
||||
if (ret === UNDEFINED_BINDING) {
|
||||
return undefined;
|
||||
} else if (ret === undefined && this._isBound()) {
|
||||
return this._boundValue();
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype._promiseAt = function (index) {
|
||||
return this[
|
||||
index * 4 - 4 + 2];
|
||||
};
|
||||
|
||||
Promise.prototype._fulfillmentHandlerAt = function (index) {
|
||||
return this[
|
||||
index * 4 - 4 + 0];
|
||||
};
|
||||
|
||||
Promise.prototype._rejectionHandlerAt = function (index) {
|
||||
return this[
|
||||
index * 4 - 4 + 1];
|
||||
};
|
||||
|
||||
Promise.prototype._boundValue = function() {};
|
||||
|
||||
Promise.prototype._migrateCallback0 = function (follower) {
|
||||
var bitField = follower._bitField;
|
||||
var fulfill = follower._fulfillmentHandler0;
|
||||
var reject = follower._rejectionHandler0;
|
||||
var promise = follower._promise0;
|
||||
var receiver = follower._receiverAt(0);
|
||||
if (receiver === undefined) receiver = UNDEFINED_BINDING;
|
||||
this._addCallbacks(fulfill, reject, promise, receiver, null);
|
||||
};
|
||||
|
||||
Promise.prototype._migrateCallbackAt = function (follower, index) {
|
||||
var fulfill = follower._fulfillmentHandlerAt(index);
|
||||
var reject = follower._rejectionHandlerAt(index);
|
||||
var promise = follower._promiseAt(index);
|
||||
var receiver = follower._receiverAt(index);
|
||||
if (receiver === undefined) receiver = UNDEFINED_BINDING;
|
||||
this._addCallbacks(fulfill, reject, promise, receiver, null);
|
||||
};
|
||||
|
||||
Promise.prototype._addCallbacks = function (
|
||||
fulfill,
|
||||
reject,
|
||||
promise,
|
||||
receiver,
|
||||
domain
|
||||
) {
|
||||
var index = this._length();
|
||||
|
||||
if (index >= 65535 - 4) {
|
||||
index = 0;
|
||||
this._setLength(0);
|
||||
}
|
||||
|
||||
if (index === 0) {
|
||||
this._promise0 = promise;
|
||||
this._receiver0 = receiver;
|
||||
if (typeof fulfill === "function") {
|
||||
this._fulfillmentHandler0 =
|
||||
domain === null ? fulfill : domain.bind(fulfill);
|
||||
}
|
||||
if (typeof reject === "function") {
|
||||
this._rejectionHandler0 =
|
||||
domain === null ? reject : domain.bind(reject);
|
||||
}
|
||||
} else {
|
||||
var base = index * 4 - 4;
|
||||
this[base + 2] = promise;
|
||||
this[base + 3] = receiver;
|
||||
if (typeof fulfill === "function") {
|
||||
this[base + 0] =
|
||||
domain === null ? fulfill : domain.bind(fulfill);
|
||||
}
|
||||
if (typeof reject === "function") {
|
||||
this[base + 1] =
|
||||
domain === null ? reject : domain.bind(reject);
|
||||
}
|
||||
}
|
||||
this._setLength(index + 1);
|
||||
return index;
|
||||
};
|
||||
|
||||
Promise.prototype._proxy = function (proxyable, arg) {
|
||||
this._addCallbacks(undefined, undefined, arg, proxyable, null);
|
||||
};
|
||||
|
||||
Promise.prototype._resolveCallback = function(value, shouldBind) {
|
||||
if (((this._bitField & 117506048) !== 0)) return;
|
||||
if (value === this)
|
||||
return this._rejectCallback(makeSelfResolutionError(), false);
|
||||
var maybePromise = tryConvertToPromise(value, this);
|
||||
if (!(maybePromise instanceof Promise)) return this._fulfill(value);
|
||||
|
||||
if (shouldBind) this._propagateFrom(maybePromise, 2);
|
||||
|
||||
var promise = maybePromise._target();
|
||||
|
||||
if (promise === this) {
|
||||
this._reject(makeSelfResolutionError());
|
||||
return;
|
||||
}
|
||||
|
||||
var bitField = promise._bitField;
|
||||
if (((bitField & 50397184) === 0)) {
|
||||
var len = this._length();
|
||||
if (len > 0) promise._migrateCallback0(this);
|
||||
for (var i = 1; i < len; ++i) {
|
||||
promise._migrateCallbackAt(this, i);
|
||||
}
|
||||
this._setFollowing();
|
||||
this._setLength(0);
|
||||
this._setFollowee(promise);
|
||||
} else if (((bitField & 33554432) !== 0)) {
|
||||
this._fulfill(promise._value());
|
||||
} else if (((bitField & 16777216) !== 0)) {
|
||||
this._reject(promise._reason());
|
||||
} else {
|
||||
var reason = new CancellationError("late cancellation observer");
|
||||
promise._attachExtraTrace(reason);
|
||||
this._reject(reason);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._rejectCallback =
|
||||
function(reason, synchronous, ignoreNonErrorWarnings) {
|
||||
var trace = util.ensureErrorObject(reason);
|
||||
var hasStack = trace === reason;
|
||||
if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) {
|
||||
var message = "a promise was rejected with a non-error: " +
|
||||
util.classString(reason);
|
||||
this._warn(message, true);
|
||||
}
|
||||
this._attachExtraTrace(trace, synchronous ? hasStack : false);
|
||||
this._reject(reason);
|
||||
};
|
||||
|
||||
Promise.prototype._resolveFromExecutor = function (executor) {
|
||||
var promise = this;
|
||||
this._captureStackTrace();
|
||||
this._pushContext();
|
||||
var synchronous = true;
|
||||
var r = this._execute(executor, function(value) {
|
||||
promise._resolveCallback(value);
|
||||
}, function (reason) {
|
||||
promise._rejectCallback(reason, synchronous);
|
||||
});
|
||||
synchronous = false;
|
||||
this._popContext();
|
||||
|
||||
if (r !== undefined) {
|
||||
promise._rejectCallback(r, true);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromiseFromHandler = function (
|
||||
handler, receiver, value, promise
|
||||
) {
|
||||
var bitField = promise._bitField;
|
||||
if (((bitField & 65536) !== 0)) return;
|
||||
promise._pushContext();
|
||||
var x;
|
||||
if (receiver === APPLY) {
|
||||
if (!value || typeof value.length !== "number") {
|
||||
x = errorObj;
|
||||
x.e = new TypeError("cannot .spread() a non-array: " +
|
||||
util.classString(value));
|
||||
} else {
|
||||
x = tryCatch(handler).apply(this._boundValue(), value);
|
||||
}
|
||||
} else {
|
||||
x = tryCatch(handler).call(receiver, value);
|
||||
}
|
||||
var promiseCreated = promise._popContext();
|
||||
bitField = promise._bitField;
|
||||
if (((bitField & 65536) !== 0)) return;
|
||||
|
||||
if (x === NEXT_FILTER) {
|
||||
promise._reject(value);
|
||||
} else if (x === errorObj) {
|
||||
promise._rejectCallback(x.e, false);
|
||||
} else {
|
||||
debug.checkForgottenReturns(x, promiseCreated, "", promise, this);
|
||||
promise._resolveCallback(x);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._target = function() {
|
||||
var ret = this;
|
||||
while (ret._isFollowing()) ret = ret._followee();
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype._followee = function() {
|
||||
return this._rejectionHandler0;
|
||||
};
|
||||
|
||||
Promise.prototype._setFollowee = function(promise) {
|
||||
this._rejectionHandler0 = promise;
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromise = function(promise, handler, receiver, value) {
|
||||
var isPromise = promise instanceof Promise;
|
||||
var bitField = this._bitField;
|
||||
var asyncGuaranteed = ((bitField & 134217728) !== 0);
|
||||
if (((bitField & 65536) !== 0)) {
|
||||
if (isPromise) promise._invokeInternalOnCancel();
|
||||
|
||||
if (receiver instanceof PassThroughHandlerContext &&
|
||||
receiver.isFinallyHandler()) {
|
||||
receiver.cancelPromise = promise;
|
||||
if (tryCatch(handler).call(receiver, value) === errorObj) {
|
||||
promise._reject(errorObj.e);
|
||||
}
|
||||
} else if (handler === reflectHandler) {
|
||||
promise._fulfill(reflectHandler.call(receiver));
|
||||
} else if (receiver instanceof Proxyable) {
|
||||
receiver._promiseCancelled(promise);
|
||||
} else if (isPromise || promise instanceof PromiseArray) {
|
||||
promise._cancel();
|
||||
} else {
|
||||
receiver.cancel();
|
||||
}
|
||||
} else if (typeof handler === "function") {
|
||||
if (!isPromise) {
|
||||
handler.call(receiver, value, promise);
|
||||
} else {
|
||||
if (asyncGuaranteed) promise._setAsyncGuaranteed();
|
||||
this._settlePromiseFromHandler(handler, receiver, value, promise);
|
||||
}
|
||||
} else if (receiver instanceof Proxyable) {
|
||||
if (!receiver._isResolved()) {
|
||||
if (((bitField & 33554432) !== 0)) {
|
||||
receiver._promiseFulfilled(value, promise);
|
||||
} else {
|
||||
receiver._promiseRejected(value, promise);
|
||||
}
|
||||
}
|
||||
} else if (isPromise) {
|
||||
if (asyncGuaranteed) promise._setAsyncGuaranteed();
|
||||
if (((bitField & 33554432) !== 0)) {
|
||||
promise._fulfill(value);
|
||||
} else {
|
||||
promise._reject(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromiseLateCancellationObserver = function(ctx) {
|
||||
var handler = ctx.handler;
|
||||
var promise = ctx.promise;
|
||||
var receiver = ctx.receiver;
|
||||
var value = ctx.value;
|
||||
if (typeof handler === "function") {
|
||||
if (!(promise instanceof Promise)) {
|
||||
handler.call(receiver, value, promise);
|
||||
} else {
|
||||
this._settlePromiseFromHandler(handler, receiver, value, promise);
|
||||
}
|
||||
} else if (promise instanceof Promise) {
|
||||
promise._reject(value);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromiseCtx = function(ctx) {
|
||||
this._settlePromise(ctx.promise, ctx.handler, ctx.receiver, ctx.value);
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromise0 = function(handler, value, bitField) {
|
||||
var promise = this._promise0;
|
||||
var receiver = this._receiverAt(0);
|
||||
this._promise0 = undefined;
|
||||
this._receiver0 = undefined;
|
||||
this._settlePromise(promise, handler, receiver, value);
|
||||
};
|
||||
|
||||
Promise.prototype._clearCallbackDataAtIndex = function(index) {
|
||||
var base = index * 4 - 4;
|
||||
this[base + 2] =
|
||||
this[base + 3] =
|
||||
this[base + 0] =
|
||||
this[base + 1] = undefined;
|
||||
};
|
||||
|
||||
Promise.prototype._fulfill = function (value) {
|
||||
var bitField = this._bitField;
|
||||
if (((bitField & 117506048) >>> 16)) return;
|
||||
if (value === this) {
|
||||
var err = makeSelfResolutionError();
|
||||
this._attachExtraTrace(err);
|
||||
return this._reject(err);
|
||||
}
|
||||
this._setFulfilled();
|
||||
this._rejectionHandler0 = value;
|
||||
|
||||
if ((bitField & 65535) > 0) {
|
||||
if (((bitField & 134217728) !== 0)) {
|
||||
this._settlePromises();
|
||||
} else {
|
||||
async.settlePromises(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._reject = function (reason) {
|
||||
var bitField = this._bitField;
|
||||
if (((bitField & 117506048) >>> 16)) return;
|
||||
this._setRejected();
|
||||
this._fulfillmentHandler0 = reason;
|
||||
|
||||
if (this._isFinal()) {
|
||||
return async.fatalError(reason, util.isNode);
|
||||
}
|
||||
|
||||
if ((bitField & 65535) > 0) {
|
||||
async.settlePromises(this);
|
||||
} else {
|
||||
this._ensurePossibleRejectionHandled();
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._fulfillPromises = function (len, value) {
|
||||
for (var i = 1; i < len; i++) {
|
||||
var handler = this._fulfillmentHandlerAt(i);
|
||||
var promise = this._promiseAt(i);
|
||||
var receiver = this._receiverAt(i);
|
||||
this._clearCallbackDataAtIndex(i);
|
||||
this._settlePromise(promise, handler, receiver, value);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._rejectPromises = function (len, reason) {
|
||||
for (var i = 1; i < len; i++) {
|
||||
var handler = this._rejectionHandlerAt(i);
|
||||
var promise = this._promiseAt(i);
|
||||
var receiver = this._receiverAt(i);
|
||||
this._clearCallbackDataAtIndex(i);
|
||||
this._settlePromise(promise, handler, receiver, reason);
|
||||
}
|
||||
};
|
||||
|
||||
Promise.prototype._settlePromises = function () {
|
||||
var bitField = this._bitField;
|
||||
var len = (bitField & 65535);
|
||||
|
||||
if (len > 0) {
|
||||
if (((bitField & 16842752) !== 0)) {
|
||||
var reason = this._fulfillmentHandler0;
|
||||
this._settlePromise0(this._rejectionHandler0, reason, bitField);
|
||||
this._rejectPromises(len, reason);
|
||||
} else {
|
||||
var value = this._rejectionHandler0;
|
||||
this._settlePromise0(this._fulfillmentHandler0, value, bitField);
|
||||
this._fulfillPromises(len, value);
|
||||
}
|
||||
this._setLength(0);
|
||||
}
|
||||
this._clearCancellationData();
|
||||
};
|
||||
|
||||
Promise.prototype._settledValue = function() {
|
||||
var bitField = this._bitField;
|
||||
if (((bitField & 33554432) !== 0)) {
|
||||
return this._rejectionHandler0;
|
||||
} else if (((bitField & 16777216) !== 0)) {
|
||||
return this._fulfillmentHandler0;
|
||||
}
|
||||
};
|
||||
|
||||
function deferResolve(v) {this.promise._resolveCallback(v);}
|
||||
function deferReject(v) {this.promise._rejectCallback(v, false);}
|
||||
|
||||
Promise.defer = Promise.pending = function() {
|
||||
debug.deprecated("Promise.defer", "new Promise");
|
||||
var promise = new Promise(INTERNAL);
|
||||
return {
|
||||
promise: promise,
|
||||
resolve: deferResolve,
|
||||
reject: deferReject
|
||||
};
|
||||
};
|
||||
|
||||
util.notEnumerableProp(Promise,
|
||||
"_makeSelfResolutionError",
|
||||
makeSelfResolutionError);
|
||||
|
||||
require("./method")(Promise, INTERNAL, tryConvertToPromise, apiRejection,
|
||||
debug);
|
||||
require("./bind")(Promise, INTERNAL, tryConvertToPromise, debug);
|
||||
require("./cancel")(Promise, PromiseArray, apiRejection, debug);
|
||||
require("./direct_resolve")(Promise);
|
||||
require("./synchronous_inspection")(Promise);
|
||||
require("./join")(
|
||||
Promise, PromiseArray, tryConvertToPromise, INTERNAL, debug);
|
||||
Promise.Promise = Promise;
|
||||
Promise.version = "3.4.0";
|
||||
require('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
|
||||
require('./call_get.js')(Promise);
|
||||
require('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug);
|
||||
require('./timers.js')(Promise, INTERNAL, debug);
|
||||
require('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug);
|
||||
require('./nodeify.js')(Promise);
|
||||
require('./promisify.js')(Promise, INTERNAL);
|
||||
require('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
|
||||
require('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
|
||||
require('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
|
||||
require('./settle.js')(Promise, PromiseArray, debug);
|
||||
require('./some.js')(Promise, PromiseArray, apiRejection);
|
||||
require('./filter.js')(Promise, INTERNAL);
|
||||
require('./each.js')(Promise, INTERNAL);
|
||||
require('./any.js')(Promise);
|
||||
|
||||
util.toFastProperties(Promise);
|
||||
util.toFastProperties(Promise.prototype);
|
||||
function fillTypes(value) {
|
||||
var p = new Promise(INTERNAL);
|
||||
p._fulfillmentHandler0 = value;
|
||||
p._rejectionHandler0 = value;
|
||||
p._promise0 = value;
|
||||
p._receiver0 = value;
|
||||
}
|
||||
// Complete slack tracking, opt out of field-type tracking and
|
||||
// stabilize map
|
||||
fillTypes({a: 1});
|
||||
fillTypes({b: 2});
|
||||
fillTypes({c: 3});
|
||||
fillTypes(1);
|
||||
fillTypes(function(){});
|
||||
fillTypes(undefined);
|
||||
fillTypes(false);
|
||||
fillTypes(new Promise(INTERNAL));
|
||||
debug.setBounds(Async.firstLineError, util.lastLineError);
|
||||
return Promise;
|
||||
|
||||
};
|
||||
184
node_modules/twit/node_modules/bluebird/js/release/promise_array.js
generated
vendored
Normal file
184
node_modules/twit/node_modules/bluebird/js/release/promise_array.js
generated
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL, tryConvertToPromise,
|
||||
apiRejection, Proxyable) {
|
||||
var util = require("./util");
|
||||
var isArray = util.isArray;
|
||||
|
||||
function toResolutionValue(val) {
|
||||
switch(val) {
|
||||
case -2: return [];
|
||||
case -3: return {};
|
||||
}
|
||||
}
|
||||
|
||||
function PromiseArray(values) {
|
||||
var promise = this._promise = new Promise(INTERNAL);
|
||||
if (values instanceof Promise) {
|
||||
promise._propagateFrom(values, 3);
|
||||
}
|
||||
promise._setOnCancel(this);
|
||||
this._values = values;
|
||||
this._length = 0;
|
||||
this._totalResolved = 0;
|
||||
this._init(undefined, -2);
|
||||
}
|
||||
util.inherits(PromiseArray, Proxyable);
|
||||
|
||||
PromiseArray.prototype.length = function () {
|
||||
return this._length;
|
||||
};
|
||||
|
||||
PromiseArray.prototype.promise = function () {
|
||||
return this._promise;
|
||||
};
|
||||
|
||||
PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
|
||||
var values = tryConvertToPromise(this._values, this._promise);
|
||||
if (values instanceof Promise) {
|
||||
values = values._target();
|
||||
var bitField = values._bitField;
|
||||
;
|
||||
this._values = values;
|
||||
|
||||
if (((bitField & 50397184) === 0)) {
|
||||
this._promise._setAsyncGuaranteed();
|
||||
return values._then(
|
||||
init,
|
||||
this._reject,
|
||||
undefined,
|
||||
this,
|
||||
resolveValueIfEmpty
|
||||
);
|
||||
} else if (((bitField & 33554432) !== 0)) {
|
||||
values = values._value();
|
||||
} else if (((bitField & 16777216) !== 0)) {
|
||||
return this._reject(values._reason());
|
||||
} else {
|
||||
return this._cancel();
|
||||
}
|
||||
}
|
||||
values = util.asArray(values);
|
||||
if (values === null) {
|
||||
var err = apiRejection(
|
||||
"expecting an array or an iterable object but got " + util.classString(values)).reason();
|
||||
this._promise._rejectCallback(err, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (values.length === 0) {
|
||||
if (resolveValueIfEmpty === -5) {
|
||||
this._resolveEmptyArray();
|
||||
}
|
||||
else {
|
||||
this._resolve(toResolutionValue(resolveValueIfEmpty));
|
||||
}
|
||||
return;
|
||||
}
|
||||
this._iterate(values);
|
||||
};
|
||||
|
||||
PromiseArray.prototype._iterate = function(values) {
|
||||
var len = this.getActualLength(values.length);
|
||||
this._length = len;
|
||||
this._values = this.shouldCopyValues() ? new Array(len) : this._values;
|
||||
var result = this._promise;
|
||||
var isResolved = false;
|
||||
var bitField = null;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var maybePromise = tryConvertToPromise(values[i], result);
|
||||
|
||||
if (maybePromise instanceof Promise) {
|
||||
maybePromise = maybePromise._target();
|
||||
bitField = maybePromise._bitField;
|
||||
} else {
|
||||
bitField = null;
|
||||
}
|
||||
|
||||
if (isResolved) {
|
||||
if (bitField !== null) {
|
||||
maybePromise.suppressUnhandledRejections();
|
||||
}
|
||||
} else if (bitField !== null) {
|
||||
if (((bitField & 50397184) === 0)) {
|
||||
maybePromise._proxy(this, i);
|
||||
this._values[i] = maybePromise;
|
||||
} else if (((bitField & 33554432) !== 0)) {
|
||||
isResolved = this._promiseFulfilled(maybePromise._value(), i);
|
||||
} else if (((bitField & 16777216) !== 0)) {
|
||||
isResolved = this._promiseRejected(maybePromise._reason(), i);
|
||||
} else {
|
||||
isResolved = this._promiseCancelled(i);
|
||||
}
|
||||
} else {
|
||||
isResolved = this._promiseFulfilled(maybePromise, i);
|
||||
}
|
||||
}
|
||||
if (!isResolved) result._setAsyncGuaranteed();
|
||||
};
|
||||
|
||||
PromiseArray.prototype._isResolved = function () {
|
||||
return this._values === null;
|
||||
};
|
||||
|
||||
PromiseArray.prototype._resolve = function (value) {
|
||||
this._values = null;
|
||||
this._promise._fulfill(value);
|
||||
};
|
||||
|
||||
PromiseArray.prototype._cancel = function() {
|
||||
if (this._isResolved() || !this._promise.isCancellable()) return;
|
||||
this._values = null;
|
||||
this._promise._cancel();
|
||||
};
|
||||
|
||||
PromiseArray.prototype._reject = function (reason) {
|
||||
this._values = null;
|
||||
this._promise._rejectCallback(reason, false);
|
||||
};
|
||||
|
||||
PromiseArray.prototype._promiseFulfilled = function (value, index) {
|
||||
this._values[index] = value;
|
||||
var totalResolved = ++this._totalResolved;
|
||||
if (totalResolved >= this._length) {
|
||||
this._resolve(this._values);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
PromiseArray.prototype._promiseCancelled = function() {
|
||||
this._cancel();
|
||||
return true;
|
||||
};
|
||||
|
||||
PromiseArray.prototype._promiseRejected = function (reason) {
|
||||
this._totalResolved++;
|
||||
this._reject(reason);
|
||||
return true;
|
||||
};
|
||||
|
||||
PromiseArray.prototype._resultCancelled = function() {
|
||||
if (this._isResolved()) return;
|
||||
var values = this._values;
|
||||
this._cancel();
|
||||
if (values instanceof Promise) {
|
||||
values.cancel();
|
||||
} else {
|
||||
for (var i = 0; i < values.length; ++i) {
|
||||
if (values[i] instanceof Promise) {
|
||||
values[i].cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PromiseArray.prototype.shouldCopyValues = function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
PromiseArray.prototype.getActualLength = function (len) {
|
||||
return len;
|
||||
};
|
||||
|
||||
return PromiseArray;
|
||||
};
|
||||
314
node_modules/twit/node_modules/bluebird/js/release/promisify.js
generated
vendored
Normal file
314
node_modules/twit/node_modules/bluebird/js/release/promisify.js
generated
vendored
Normal file
@@ -0,0 +1,314 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL) {
|
||||
var THIS = {};
|
||||
var util = require("./util");
|
||||
var nodebackForPromise = require("./nodeback");
|
||||
var withAppended = util.withAppended;
|
||||
var maybeWrapAsError = util.maybeWrapAsError;
|
||||
var canEvaluate = util.canEvaluate;
|
||||
var TypeError = require("./errors").TypeError;
|
||||
var defaultSuffix = "Async";
|
||||
var defaultPromisified = {__isPromisified__: true};
|
||||
var noCopyProps = [
|
||||
"arity", "length",
|
||||
"name",
|
||||
"arguments",
|
||||
"caller",
|
||||
"callee",
|
||||
"prototype",
|
||||
"__isPromisified__"
|
||||
];
|
||||
var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
|
||||
|
||||
var defaultFilter = function(name) {
|
||||
return util.isIdentifier(name) &&
|
||||
name.charAt(0) !== "_" &&
|
||||
name !== "constructor";
|
||||
};
|
||||
|
||||
function propsFilter(key) {
|
||||
return !noCopyPropsPattern.test(key);
|
||||
}
|
||||
|
||||
function isPromisified(fn) {
|
||||
try {
|
||||
return fn.__isPromisified__ === true;
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hasPromisified(obj, key, suffix) {
|
||||
var val = util.getDataPropertyOrDefault(obj, key + suffix,
|
||||
defaultPromisified);
|
||||
return val ? isPromisified(val) : false;
|
||||
}
|
||||
function checkValid(ret, suffix, suffixRegexp) {
|
||||
for (var i = 0; i < ret.length; i += 2) {
|
||||
var key = ret[i];
|
||||
if (suffixRegexp.test(key)) {
|
||||
var keyWithoutAsyncSuffix = key.replace(suffixRegexp, "");
|
||||
for (var j = 0; j < ret.length; j += 2) {
|
||||
if (ret[j] === keyWithoutAsyncSuffix) {
|
||||
throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a See http://goo.gl/MqrFmX\u000a"
|
||||
.replace("%s", suffix));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function promisifiableMethods(obj, suffix, suffixRegexp, filter) {
|
||||
var keys = util.inheritedDataKeys(obj);
|
||||
var ret = [];
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
var value = obj[key];
|
||||
var passesDefaultFilter = filter === defaultFilter
|
||||
? true : defaultFilter(key, value, obj);
|
||||
if (typeof value === "function" &&
|
||||
!isPromisified(value) &&
|
||||
!hasPromisified(obj, key, suffix) &&
|
||||
filter(key, value, obj, passesDefaultFilter)) {
|
||||
ret.push(key, value);
|
||||
}
|
||||
}
|
||||
checkValid(ret, suffix, suffixRegexp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
var escapeIdentRegex = function(str) {
|
||||
return str.replace(/([$])/, "\\$");
|
||||
};
|
||||
|
||||
var makeNodePromisifiedEval;
|
||||
if (!false) {
|
||||
var switchCaseArgumentOrder = function(likelyArgumentCount) {
|
||||
var ret = [likelyArgumentCount];
|
||||
var min = Math.max(0, likelyArgumentCount - 1 - 3);
|
||||
for(var i = likelyArgumentCount - 1; i >= min; --i) {
|
||||
ret.push(i);
|
||||
}
|
||||
for(var i = likelyArgumentCount + 1; i <= 3; ++i) {
|
||||
ret.push(i);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
var argumentSequence = function(argumentCount) {
|
||||
return util.filledRange(argumentCount, "_arg", "");
|
||||
};
|
||||
|
||||
var parameterDeclaration = function(parameterCount) {
|
||||
return util.filledRange(
|
||||
Math.max(parameterCount, 3), "_arg", "");
|
||||
};
|
||||
|
||||
var parameterCount = function(fn) {
|
||||
if (typeof fn.length === "number") {
|
||||
return Math.max(Math.min(fn.length, 1023 + 1), 0);
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
makeNodePromisifiedEval =
|
||||
function(callback, receiver, originalName, fn, _, multiArgs) {
|
||||
var newParameterCount = Math.max(0, parameterCount(fn) - 1);
|
||||
var argumentOrder = switchCaseArgumentOrder(newParameterCount);
|
||||
var shouldProxyThis = typeof callback === "string" || receiver === THIS;
|
||||
|
||||
function generateCallForArgumentCount(count) {
|
||||
var args = argumentSequence(count).join(", ");
|
||||
var comma = count > 0 ? ", " : "";
|
||||
var ret;
|
||||
if (shouldProxyThis) {
|
||||
ret = "ret = callback.call(this, {{args}}, nodeback); break;\n";
|
||||
} else {
|
||||
ret = receiver === undefined
|
||||
? "ret = callback({{args}}, nodeback); break;\n"
|
||||
: "ret = callback.call(receiver, {{args}}, nodeback); break;\n";
|
||||
}
|
||||
return ret.replace("{{args}}", args).replace(", ", comma);
|
||||
}
|
||||
|
||||
function generateArgumentSwitchCase() {
|
||||
var ret = "";
|
||||
for (var i = 0; i < argumentOrder.length; ++i) {
|
||||
ret += "case " + argumentOrder[i] +":" +
|
||||
generateCallForArgumentCount(argumentOrder[i]);
|
||||
}
|
||||
|
||||
ret += " \n\
|
||||
default: \n\
|
||||
var args = new Array(len + 1); \n\
|
||||
var i = 0; \n\
|
||||
for (var i = 0; i < len; ++i) { \n\
|
||||
args[i] = arguments[i]; \n\
|
||||
} \n\
|
||||
args[i] = nodeback; \n\
|
||||
[CodeForCall] \n\
|
||||
break; \n\
|
||||
".replace("[CodeForCall]", (shouldProxyThis
|
||||
? "ret = callback.apply(this, args);\n"
|
||||
: "ret = callback.apply(receiver, args);\n"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
var getFunctionCode = typeof callback === "string"
|
||||
? ("this != null ? this['"+callback+"'] : fn")
|
||||
: "fn";
|
||||
var body = "'use strict'; \n\
|
||||
var ret = function (Parameters) { \n\
|
||||
'use strict'; \n\
|
||||
var len = arguments.length; \n\
|
||||
var promise = new Promise(INTERNAL); \n\
|
||||
promise._captureStackTrace(); \n\
|
||||
var nodeback = nodebackForPromise(promise, " + multiArgs + "); \n\
|
||||
var ret; \n\
|
||||
var callback = tryCatch([GetFunctionCode]); \n\
|
||||
switch(len) { \n\
|
||||
[CodeForSwitchCase] \n\
|
||||
} \n\
|
||||
if (ret === errorObj) { \n\
|
||||
promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\
|
||||
} \n\
|
||||
if (!promise._isFateSealed()) promise._setAsyncGuaranteed(); \n\
|
||||
return promise; \n\
|
||||
}; \n\
|
||||
notEnumerableProp(ret, '__isPromisified__', true); \n\
|
||||
return ret; \n\
|
||||
".replace("[CodeForSwitchCase]", generateArgumentSwitchCase())
|
||||
.replace("[GetFunctionCode]", getFunctionCode);
|
||||
body = body.replace("Parameters", parameterDeclaration(newParameterCount));
|
||||
return new Function("Promise",
|
||||
"fn",
|
||||
"receiver",
|
||||
"withAppended",
|
||||
"maybeWrapAsError",
|
||||
"nodebackForPromise",
|
||||
"tryCatch",
|
||||
"errorObj",
|
||||
"notEnumerableProp",
|
||||
"INTERNAL",
|
||||
body)(
|
||||
Promise,
|
||||
fn,
|
||||
receiver,
|
||||
withAppended,
|
||||
maybeWrapAsError,
|
||||
nodebackForPromise,
|
||||
util.tryCatch,
|
||||
util.errorObj,
|
||||
util.notEnumerableProp,
|
||||
INTERNAL);
|
||||
};
|
||||
}
|
||||
|
||||
function makeNodePromisifiedClosure(callback, receiver, _, fn, __, multiArgs) {
|
||||
var defaultThis = (function() {return this;})();
|
||||
var method = callback;
|
||||
if (typeof method === "string") {
|
||||
callback = fn;
|
||||
}
|
||||
function promisified() {
|
||||
var _receiver = receiver;
|
||||
if (receiver === THIS) _receiver = this;
|
||||
var promise = new Promise(INTERNAL);
|
||||
promise._captureStackTrace();
|
||||
var cb = typeof method === "string" && this !== defaultThis
|
||||
? this[method] : callback;
|
||||
var fn = nodebackForPromise(promise, multiArgs);
|
||||
try {
|
||||
cb.apply(_receiver, withAppended(arguments, fn));
|
||||
} catch(e) {
|
||||
promise._rejectCallback(maybeWrapAsError(e), true, true);
|
||||
}
|
||||
if (!promise._isFateSealed()) promise._setAsyncGuaranteed();
|
||||
return promise;
|
||||
}
|
||||
util.notEnumerableProp(promisified, "__isPromisified__", true);
|
||||
return promisified;
|
||||
}
|
||||
|
||||
var makeNodePromisified = canEvaluate
|
||||
? makeNodePromisifiedEval
|
||||
: makeNodePromisifiedClosure;
|
||||
|
||||
function promisifyAll(obj, suffix, filter, promisifier, multiArgs) {
|
||||
var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$");
|
||||
var methods =
|
||||
promisifiableMethods(obj, suffix, suffixRegexp, filter);
|
||||
|
||||
for (var i = 0, len = methods.length; i < len; i+= 2) {
|
||||
var key = methods[i];
|
||||
var fn = methods[i+1];
|
||||
var promisifiedKey = key + suffix;
|
||||
if (promisifier === makeNodePromisified) {
|
||||
obj[promisifiedKey] =
|
||||
makeNodePromisified(key, THIS, key, fn, suffix, multiArgs);
|
||||
} else {
|
||||
var promisified = promisifier(fn, function() {
|
||||
return makeNodePromisified(key, THIS, key,
|
||||
fn, suffix, multiArgs);
|
||||
});
|
||||
util.notEnumerableProp(promisified, "__isPromisified__", true);
|
||||
obj[promisifiedKey] = promisified;
|
||||
}
|
||||
}
|
||||
util.toFastProperties(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
function promisify(callback, receiver, multiArgs) {
|
||||
return makeNodePromisified(callback, receiver, undefined,
|
||||
callback, null, multiArgs);
|
||||
}
|
||||
|
||||
Promise.promisify = function (fn, options) {
|
||||
if (typeof fn !== "function") {
|
||||
throw new TypeError("expecting a function but got " + util.classString(fn));
|
||||
}
|
||||
if (isPromisified(fn)) {
|
||||
return fn;
|
||||
}
|
||||
options = Object(options);
|
||||
var receiver = options.context === undefined ? THIS : options.context;
|
||||
var multiArgs = !!options.multiArgs;
|
||||
var ret = promisify(fn, receiver, multiArgs);
|
||||
util.copyDescriptors(fn, ret, propsFilter);
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.promisifyAll = function (target, options) {
|
||||
if (typeof target !== "function" && typeof target !== "object") {
|
||||
throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
}
|
||||
options = Object(options);
|
||||
var multiArgs = !!options.multiArgs;
|
||||
var suffix = options.suffix;
|
||||
if (typeof suffix !== "string") suffix = defaultSuffix;
|
||||
var filter = options.filter;
|
||||
if (typeof filter !== "function") filter = defaultFilter;
|
||||
var promisifier = options.promisifier;
|
||||
if (typeof promisifier !== "function") promisifier = makeNodePromisified;
|
||||
|
||||
if (!util.isIdentifier(suffix)) {
|
||||
throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
}
|
||||
|
||||
var keys = util.inheritedDataKeys(target);
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var value = target[keys[i]];
|
||||
if (keys[i] !== "constructor" &&
|
||||
util.isClass(value)) {
|
||||
promisifyAll(value.prototype, suffix, filter, promisifier,
|
||||
multiArgs);
|
||||
promisifyAll(value, suffix, filter, promisifier, multiArgs);
|
||||
}
|
||||
}
|
||||
|
||||
return promisifyAll(target, suffix, filter, promisifier, multiArgs);
|
||||
};
|
||||
};
|
||||
|
||||
118
node_modules/twit/node_modules/bluebird/js/release/props.js
generated
vendored
Normal file
118
node_modules/twit/node_modules/bluebird/js/release/props.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
"use strict";
|
||||
module.exports = function(
|
||||
Promise, PromiseArray, tryConvertToPromise, apiRejection) {
|
||||
var util = require("./util");
|
||||
var isObject = util.isObject;
|
||||
var es5 = require("./es5");
|
||||
var Es6Map;
|
||||
if (typeof Map === "function") Es6Map = Map;
|
||||
|
||||
var mapToEntries = (function() {
|
||||
var index = 0;
|
||||
var size = 0;
|
||||
|
||||
function extractEntry(value, key) {
|
||||
this[index] = value;
|
||||
this[index + size] = key;
|
||||
index++;
|
||||
}
|
||||
|
||||
return function mapToEntries(map) {
|
||||
size = map.size;
|
||||
index = 0;
|
||||
var ret = new Array(map.size * 2);
|
||||
map.forEach(extractEntry, ret);
|
||||
return ret;
|
||||
};
|
||||
})();
|
||||
|
||||
var entriesToMap = function(entries) {
|
||||
var ret = new Es6Map();
|
||||
var length = entries.length / 2 | 0;
|
||||
for (var i = 0; i < length; ++i) {
|
||||
var key = entries[length + i];
|
||||
var value = entries[i];
|
||||
ret.set(key, value);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
function PropertiesPromiseArray(obj) {
|
||||
var isMap = false;
|
||||
var entries;
|
||||
if (Es6Map !== undefined && obj instanceof Es6Map) {
|
||||
entries = mapToEntries(obj);
|
||||
isMap = true;
|
||||
} else {
|
||||
var keys = es5.keys(obj);
|
||||
var len = keys.length;
|
||||
entries = new Array(len * 2);
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var key = keys[i];
|
||||
entries[i] = obj[key];
|
||||
entries[i + len] = key;
|
||||
}
|
||||
}
|
||||
this.constructor$(entries);
|
||||
this._isMap = isMap;
|
||||
this._init$(undefined, -3);
|
||||
}
|
||||
util.inherits(PropertiesPromiseArray, PromiseArray);
|
||||
|
||||
PropertiesPromiseArray.prototype._init = function () {};
|
||||
|
||||
PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
||||
this._values[index] = value;
|
||||
var totalResolved = ++this._totalResolved;
|
||||
if (totalResolved >= this._length) {
|
||||
var val;
|
||||
if (this._isMap) {
|
||||
val = entriesToMap(this._values);
|
||||
} else {
|
||||
val = {};
|
||||
var keyOffset = this.length();
|
||||
for (var i = 0, len = this.length(); i < len; ++i) {
|
||||
val[this._values[i + keyOffset]] = this._values[i];
|
||||
}
|
||||
}
|
||||
this._resolve(val);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
PropertiesPromiseArray.prototype.shouldCopyValues = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
PropertiesPromiseArray.prototype.getActualLength = function (len) {
|
||||
return len >> 1;
|
||||
};
|
||||
|
||||
function props(promises) {
|
||||
var ret;
|
||||
var castValue = tryConvertToPromise(promises);
|
||||
|
||||
if (!isObject(castValue)) {
|
||||
return apiRejection("cannot await properties of a non-object\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
} else if (castValue instanceof Promise) {
|
||||
ret = castValue._then(
|
||||
Promise.props, undefined, undefined, undefined, undefined);
|
||||
} else {
|
||||
ret = new PropertiesPromiseArray(castValue).promise();
|
||||
}
|
||||
|
||||
if (castValue instanceof Promise) {
|
||||
ret._propagateFrom(castValue, 2);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Promise.prototype.props = function () {
|
||||
return props(this);
|
||||
};
|
||||
|
||||
Promise.props = function (promises) {
|
||||
return props(promises);
|
||||
};
|
||||
};
|
||||
90
node_modules/twit/node_modules/bluebird/js/release/queue.js
generated
vendored
Normal file
90
node_modules/twit/node_modules/bluebird/js/release/queue.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
function arrayMove(src, srcIndex, dst, dstIndex, len) {
|
||||
for (var j = 0; j < len; ++j) {
|
||||
dst[j + dstIndex] = src[j + srcIndex];
|
||||
src[j + srcIndex] = void 0;
|
||||
}
|
||||
}
|
||||
|
||||
function Queue(capacity) {
|
||||
this._capacity = capacity;
|
||||
this._length = 0;
|
||||
this._front = 0;
|
||||
}
|
||||
|
||||
Queue.prototype._willBeOverCapacity = function (size) {
|
||||
return this._capacity < size;
|
||||
};
|
||||
|
||||
Queue.prototype._pushOne = function (arg) {
|
||||
var length = this.length();
|
||||
this._checkCapacity(length + 1);
|
||||
var i = (this._front + length) & (this._capacity - 1);
|
||||
this[i] = arg;
|
||||
this._length = length + 1;
|
||||
};
|
||||
|
||||
Queue.prototype._unshiftOne = function(value) {
|
||||
var capacity = this._capacity;
|
||||
this._checkCapacity(this.length() + 1);
|
||||
var front = this._front;
|
||||
var i = (((( front - 1 ) &
|
||||
( capacity - 1) ) ^ capacity ) - capacity );
|
||||
this[i] = value;
|
||||
this._front = i;
|
||||
this._length = this.length() + 1;
|
||||
};
|
||||
|
||||
Queue.prototype.unshift = function(fn, receiver, arg) {
|
||||
this._unshiftOne(arg);
|
||||
this._unshiftOne(receiver);
|
||||
this._unshiftOne(fn);
|
||||
};
|
||||
|
||||
Queue.prototype.push = function (fn, receiver, arg) {
|
||||
var length = this.length() + 3;
|
||||
if (this._willBeOverCapacity(length)) {
|
||||
this._pushOne(fn);
|
||||
this._pushOne(receiver);
|
||||
this._pushOne(arg);
|
||||
return;
|
||||
}
|
||||
var j = this._front + length - 3;
|
||||
this._checkCapacity(length);
|
||||
var wrapMask = this._capacity - 1;
|
||||
this[(j + 0) & wrapMask] = fn;
|
||||
this[(j + 1) & wrapMask] = receiver;
|
||||
this[(j + 2) & wrapMask] = arg;
|
||||
this._length = length;
|
||||
};
|
||||
|
||||
Queue.prototype.shift = function () {
|
||||
var front = this._front,
|
||||
ret = this[front];
|
||||
|
||||
this[front] = undefined;
|
||||
this._front = (front + 1) & (this._capacity - 1);
|
||||
this._length--;
|
||||
return ret;
|
||||
};
|
||||
|
||||
Queue.prototype.length = function () {
|
||||
return this._length;
|
||||
};
|
||||
|
||||
Queue.prototype._checkCapacity = function (size) {
|
||||
if (this._capacity < size) {
|
||||
this._resizeTo(this._capacity << 1);
|
||||
}
|
||||
};
|
||||
|
||||
Queue.prototype._resizeTo = function (capacity) {
|
||||
var oldCapacity = this._capacity;
|
||||
this._capacity = capacity;
|
||||
var front = this._front;
|
||||
var length = this._length;
|
||||
var moveItemsCount = (front + length) & (oldCapacity - 1);
|
||||
arrayMove(this, 0, this, oldCapacity, moveItemsCount);
|
||||
};
|
||||
|
||||
module.exports = Queue;
|
||||
49
node_modules/twit/node_modules/bluebird/js/release/race.js
generated
vendored
Normal file
49
node_modules/twit/node_modules/bluebird/js/release/race.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
module.exports = function(
|
||||
Promise, INTERNAL, tryConvertToPromise, apiRejection) {
|
||||
var util = require("./util");
|
||||
|
||||
var raceLater = function (promise) {
|
||||
return promise.then(function(array) {
|
||||
return race(array, promise);
|
||||
});
|
||||
};
|
||||
|
||||
function race(promises, parent) {
|
||||
var maybePromise = tryConvertToPromise(promises);
|
||||
|
||||
if (maybePromise instanceof Promise) {
|
||||
return raceLater(maybePromise);
|
||||
} else {
|
||||
promises = util.asArray(promises);
|
||||
if (promises === null)
|
||||
return apiRejection("expecting an array or an iterable object but got " + util.classString(promises));
|
||||
}
|
||||
|
||||
var ret = new Promise(INTERNAL);
|
||||
if (parent !== undefined) {
|
||||
ret._propagateFrom(parent, 3);
|
||||
}
|
||||
var fulfill = ret._fulfill;
|
||||
var reject = ret._reject;
|
||||
for (var i = 0, len = promises.length; i < len; ++i) {
|
||||
var val = promises[i];
|
||||
|
||||
if (val === undefined && !(i in promises)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Promise.race = function (promises) {
|
||||
return race(promises, undefined);
|
||||
};
|
||||
|
||||
Promise.prototype.race = function () {
|
||||
return race(this, undefined);
|
||||
};
|
||||
|
||||
};
|
||||
162
node_modules/twit/node_modules/bluebird/js/release/reduce.js
generated
vendored
Normal file
162
node_modules/twit/node_modules/bluebird/js/release/reduce.js
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise,
|
||||
PromiseArray,
|
||||
apiRejection,
|
||||
tryConvertToPromise,
|
||||
INTERNAL,
|
||||
debug) {
|
||||
var getDomain = Promise._getDomain;
|
||||
var util = require("./util");
|
||||
var tryCatch = util.tryCatch;
|
||||
|
||||
function ReductionPromiseArray(promises, fn, initialValue, _each) {
|
||||
this.constructor$(promises);
|
||||
var domain = getDomain();
|
||||
this._fn = domain === null ? fn : domain.bind(fn);
|
||||
if (initialValue !== undefined) {
|
||||
initialValue = Promise.resolve(initialValue);
|
||||
initialValue._attachCancellationCallback(this);
|
||||
}
|
||||
this._initialValue = initialValue;
|
||||
this._currentCancellable = null;
|
||||
this._eachValues = _each === INTERNAL ? [] : undefined;
|
||||
this._promise._captureStackTrace();
|
||||
this._init$(undefined, -5);
|
||||
}
|
||||
util.inherits(ReductionPromiseArray, PromiseArray);
|
||||
|
||||
ReductionPromiseArray.prototype._gotAccum = function(accum) {
|
||||
if (this._eachValues !== undefined && accum !== INTERNAL) {
|
||||
this._eachValues.push(accum);
|
||||
}
|
||||
};
|
||||
|
||||
ReductionPromiseArray.prototype._eachComplete = function(value) {
|
||||
this._eachValues.push(value);
|
||||
return this._eachValues;
|
||||
};
|
||||
|
||||
ReductionPromiseArray.prototype._init = function() {};
|
||||
|
||||
ReductionPromiseArray.prototype._resolveEmptyArray = function() {
|
||||
this._resolve(this._eachValues !== undefined ? this._eachValues
|
||||
: this._initialValue);
|
||||
};
|
||||
|
||||
ReductionPromiseArray.prototype.shouldCopyValues = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
ReductionPromiseArray.prototype._resolve = function(value) {
|
||||
this._promise._resolveCallback(value);
|
||||
this._values = null;
|
||||
};
|
||||
|
||||
ReductionPromiseArray.prototype._resultCancelled = function(sender) {
|
||||
if (sender === this._initialValue) return this._cancel();
|
||||
if (this._isResolved()) return;
|
||||
this._resultCancelled$();
|
||||
if (this._currentCancellable instanceof Promise) {
|
||||
this._currentCancellable.cancel();
|
||||
}
|
||||
if (this._initialValue instanceof Promise) {
|
||||
this._initialValue.cancel();
|
||||
}
|
||||
};
|
||||
|
||||
ReductionPromiseArray.prototype._iterate = function (values) {
|
||||
this._values = values;
|
||||
var value;
|
||||
var i;
|
||||
var length = values.length;
|
||||
if (this._initialValue !== undefined) {
|
||||
value = this._initialValue;
|
||||
i = 0;
|
||||
} else {
|
||||
value = Promise.resolve(values[0]);
|
||||
i = 1;
|
||||
}
|
||||
|
||||
this._currentCancellable = value;
|
||||
|
||||
if (!value.isRejected()) {
|
||||
for (; i < length; ++i) {
|
||||
var ctx = {
|
||||
accum: null,
|
||||
value: values[i],
|
||||
index: i,
|
||||
length: length,
|
||||
array: this
|
||||
};
|
||||
value = value._then(gotAccum, undefined, undefined, ctx, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
if (this._eachValues !== undefined) {
|
||||
value = value
|
||||
._then(this._eachComplete, undefined, undefined, this, undefined);
|
||||
}
|
||||
value._then(completed, completed, undefined, value, this);
|
||||
};
|
||||
|
||||
Promise.prototype.reduce = function (fn, initialValue) {
|
||||
return reduce(this, fn, initialValue, null);
|
||||
};
|
||||
|
||||
Promise.reduce = function (promises, fn, initialValue, _each) {
|
||||
return reduce(promises, fn, initialValue, _each);
|
||||
};
|
||||
|
||||
function completed(valueOrReason, array) {
|
||||
if (this.isFulfilled()) {
|
||||
array._resolve(valueOrReason);
|
||||
} else {
|
||||
array._reject(valueOrReason);
|
||||
}
|
||||
}
|
||||
|
||||
function reduce(promises, fn, initialValue, _each) {
|
||||
if (typeof fn !== "function") {
|
||||
return apiRejection("expecting a function but got " + util.classString(fn));
|
||||
}
|
||||
var array = new ReductionPromiseArray(promises, fn, initialValue, _each);
|
||||
return array.promise();
|
||||
}
|
||||
|
||||
function gotAccum(accum) {
|
||||
this.accum = accum;
|
||||
this.array._gotAccum(accum);
|
||||
var value = tryConvertToPromise(this.value, this.array._promise);
|
||||
if (value instanceof Promise) {
|
||||
this.array._currentCancellable = value;
|
||||
return value._then(gotValue, undefined, undefined, this, undefined);
|
||||
} else {
|
||||
return gotValue.call(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
function gotValue(value) {
|
||||
var array = this.array;
|
||||
var promise = array._promise;
|
||||
var fn = tryCatch(array._fn);
|
||||
promise._pushContext();
|
||||
var ret;
|
||||
if (array._eachValues !== undefined) {
|
||||
ret = fn.call(promise._boundValue(), value, this.index, this.length);
|
||||
} else {
|
||||
ret = fn.call(promise._boundValue(),
|
||||
this.accum, value, this.index, this.length);
|
||||
}
|
||||
if (ret instanceof Promise) {
|
||||
array._currentCancellable = ret;
|
||||
}
|
||||
var promiseCreated = promise._popContext();
|
||||
debug.checkForgottenReturns(
|
||||
ret,
|
||||
promiseCreated,
|
||||
array._eachValues !== undefined ? "Promise.each" : "Promise.reduce",
|
||||
promise
|
||||
);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
60
node_modules/twit/node_modules/bluebird/js/release/schedule.js
generated
vendored
Normal file
60
node_modules/twit/node_modules/bluebird/js/release/schedule.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
var util = require("./util");
|
||||
var schedule;
|
||||
var noAsyncScheduler = function() {
|
||||
throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
};
|
||||
var NativePromise = util.getNativePromise();
|
||||
if (util.isNode && typeof MutationObserver === "undefined") {
|
||||
var GlobalSetImmediate = global.setImmediate;
|
||||
var ProcessNextTick = process.nextTick;
|
||||
schedule = util.isRecentNode
|
||||
? function(fn) { GlobalSetImmediate.call(global, fn); }
|
||||
: function(fn) { ProcessNextTick.call(process, fn); };
|
||||
} else if (typeof NativePromise === "function") {
|
||||
var nativePromise = NativePromise.resolve();
|
||||
schedule = function(fn) {
|
||||
nativePromise.then(fn);
|
||||
};
|
||||
} else if ((typeof MutationObserver !== "undefined") &&
|
||||
!(typeof window !== "undefined" &&
|
||||
window.navigator &&
|
||||
window.navigator.standalone)) {
|
||||
schedule = (function() {
|
||||
var div = document.createElement("div");
|
||||
var opts = {attributes: true};
|
||||
var toggleScheduled = false;
|
||||
var div2 = document.createElement("div");
|
||||
var o2 = new MutationObserver(function() {
|
||||
div.classList.toggle("foo");
|
||||
toggleScheduled = false;
|
||||
});
|
||||
o2.observe(div2, opts);
|
||||
|
||||
var scheduleToggle = function() {
|
||||
if (toggleScheduled) return;
|
||||
toggleScheduled = true;
|
||||
div2.classList.toggle("foo");
|
||||
};
|
||||
|
||||
return function schedule(fn) {
|
||||
var o = new MutationObserver(function() {
|
||||
o.disconnect();
|
||||
fn();
|
||||
});
|
||||
o.observe(div, opts);
|
||||
scheduleToggle();
|
||||
};
|
||||
})();
|
||||
} else if (typeof setImmediate !== "undefined") {
|
||||
schedule = function (fn) {
|
||||
setImmediate(fn);
|
||||
};
|
||||
} else if (typeof setTimeout !== "undefined") {
|
||||
schedule = function (fn) {
|
||||
setTimeout(fn, 0);
|
||||
};
|
||||
} else {
|
||||
schedule = noAsyncScheduler;
|
||||
}
|
||||
module.exports = schedule;
|
||||
43
node_modules/twit/node_modules/bluebird/js/release/settle.js
generated
vendored
Normal file
43
node_modules/twit/node_modules/bluebird/js/release/settle.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
module.exports =
|
||||
function(Promise, PromiseArray, debug) {
|
||||
var PromiseInspection = Promise.PromiseInspection;
|
||||
var util = require("./util");
|
||||
|
||||
function SettledPromiseArray(values) {
|
||||
this.constructor$(values);
|
||||
}
|
||||
util.inherits(SettledPromiseArray, PromiseArray);
|
||||
|
||||
SettledPromiseArray.prototype._promiseResolved = function (index, inspection) {
|
||||
this._values[index] = inspection;
|
||||
var totalResolved = ++this._totalResolved;
|
||||
if (totalResolved >= this._length) {
|
||||
this._resolve(this._values);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
SettledPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
||||
var ret = new PromiseInspection();
|
||||
ret._bitField = 33554432;
|
||||
ret._settledValueField = value;
|
||||
return this._promiseResolved(index, ret);
|
||||
};
|
||||
SettledPromiseArray.prototype._promiseRejected = function (reason, index) {
|
||||
var ret = new PromiseInspection();
|
||||
ret._bitField = 16777216;
|
||||
ret._settledValueField = reason;
|
||||
return this._promiseResolved(index, ret);
|
||||
};
|
||||
|
||||
Promise.settle = function (promises) {
|
||||
debug.deprecated(".settle()", ".reflect()");
|
||||
return new SettledPromiseArray(promises).promise();
|
||||
};
|
||||
|
||||
Promise.prototype.settle = function () {
|
||||
return Promise.settle(this);
|
||||
};
|
||||
};
|
||||
148
node_modules/twit/node_modules/bluebird/js/release/some.js
generated
vendored
Normal file
148
node_modules/twit/node_modules/bluebird/js/release/some.js
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
"use strict";
|
||||
module.exports =
|
||||
function(Promise, PromiseArray, apiRejection) {
|
||||
var util = require("./util");
|
||||
var RangeError = require("./errors").RangeError;
|
||||
var AggregateError = require("./errors").AggregateError;
|
||||
var isArray = util.isArray;
|
||||
var CANCELLATION = {};
|
||||
|
||||
|
||||
function SomePromiseArray(values) {
|
||||
this.constructor$(values);
|
||||
this._howMany = 0;
|
||||
this._unwrap = false;
|
||||
this._initialized = false;
|
||||
}
|
||||
util.inherits(SomePromiseArray, PromiseArray);
|
||||
|
||||
SomePromiseArray.prototype._init = function () {
|
||||
if (!this._initialized) {
|
||||
return;
|
||||
}
|
||||
if (this._howMany === 0) {
|
||||
this._resolve([]);
|
||||
return;
|
||||
}
|
||||
this._init$(undefined, -5);
|
||||
var isArrayResolved = isArray(this._values);
|
||||
if (!this._isResolved() &&
|
||||
isArrayResolved &&
|
||||
this._howMany > this._canPossiblyFulfill()) {
|
||||
this._reject(this._getRangeError(this.length()));
|
||||
}
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype.init = function () {
|
||||
this._initialized = true;
|
||||
this._init();
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype.setUnwrap = function () {
|
||||
this._unwrap = true;
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype.howMany = function () {
|
||||
return this._howMany;
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype.setHowMany = function (count) {
|
||||
this._howMany = count;
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._promiseFulfilled = function (value) {
|
||||
this._addFulfilled(value);
|
||||
if (this._fulfilled() === this.howMany()) {
|
||||
this._values.length = this.howMany();
|
||||
if (this.howMany() === 1 && this._unwrap) {
|
||||
this._resolve(this._values[0]);
|
||||
} else {
|
||||
this._resolve(this._values);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
};
|
||||
SomePromiseArray.prototype._promiseRejected = function (reason) {
|
||||
this._addRejected(reason);
|
||||
return this._checkOutcome();
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._promiseCancelled = function () {
|
||||
if (this._values instanceof Promise || this._values == null) {
|
||||
return this._cancel();
|
||||
}
|
||||
this._addRejected(CANCELLATION);
|
||||
return this._checkOutcome();
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._checkOutcome = function() {
|
||||
if (this.howMany() > this._canPossiblyFulfill()) {
|
||||
var e = new AggregateError();
|
||||
for (var i = this.length(); i < this._values.length; ++i) {
|
||||
if (this._values[i] !== CANCELLATION) {
|
||||
e.push(this._values[i]);
|
||||
}
|
||||
}
|
||||
if (e.length > 0) {
|
||||
this._reject(e);
|
||||
} else {
|
||||
this._cancel();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._fulfilled = function () {
|
||||
return this._totalResolved;
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._rejected = function () {
|
||||
return this._values.length - this.length();
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._addRejected = function (reason) {
|
||||
this._values.push(reason);
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._addFulfilled = function (value) {
|
||||
this._values[this._totalResolved++] = value;
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._canPossiblyFulfill = function () {
|
||||
return this.length() - this._rejected();
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._getRangeError = function (count) {
|
||||
var message = "Input array must contain at least " +
|
||||
this._howMany + " items but contains only " + count + " items";
|
||||
return new RangeError(message);
|
||||
};
|
||||
|
||||
SomePromiseArray.prototype._resolveEmptyArray = function () {
|
||||
this._reject(this._getRangeError(0));
|
||||
};
|
||||
|
||||
function some(promises, howMany) {
|
||||
if ((howMany | 0) !== howMany || howMany < 0) {
|
||||
return apiRejection("expecting a positive integer\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
}
|
||||
var ret = new SomePromiseArray(promises);
|
||||
var promise = ret.promise();
|
||||
ret.setHowMany(howMany);
|
||||
ret.init();
|
||||
return promise;
|
||||
}
|
||||
|
||||
Promise.some = function (promises, howMany) {
|
||||
return some(promises, howMany);
|
||||
};
|
||||
|
||||
Promise.prototype.some = function (howMany) {
|
||||
return some(this, howMany);
|
||||
};
|
||||
|
||||
Promise._SomePromiseArray = SomePromiseArray;
|
||||
};
|
||||
96
node_modules/twit/node_modules/bluebird/js/release/synchronous_inspection.js
generated
vendored
Normal file
96
node_modules/twit/node_modules/bluebird/js/release/synchronous_inspection.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise) {
|
||||
function PromiseInspection(promise) {
|
||||
if (promise !== undefined) {
|
||||
promise = promise._target();
|
||||
this._bitField = promise._bitField;
|
||||
this._settledValueField = promise._isFateSealed()
|
||||
? promise._settledValue() : undefined;
|
||||
}
|
||||
else {
|
||||
this._bitField = 0;
|
||||
this._settledValueField = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
PromiseInspection.prototype._settledValue = function() {
|
||||
return this._settledValueField;
|
||||
};
|
||||
|
||||
var value = PromiseInspection.prototype.value = function () {
|
||||
if (!this.isFulfilled()) {
|
||||
throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
}
|
||||
return this._settledValue();
|
||||
};
|
||||
|
||||
var reason = PromiseInspection.prototype.error =
|
||||
PromiseInspection.prototype.reason = function () {
|
||||
if (!this.isRejected()) {
|
||||
throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
||||
}
|
||||
return this._settledValue();
|
||||
};
|
||||
|
||||
var isFulfilled = PromiseInspection.prototype.isFulfilled = function() {
|
||||
return (this._bitField & 33554432) !== 0;
|
||||
};
|
||||
|
||||
var isRejected = PromiseInspection.prototype.isRejected = function () {
|
||||
return (this._bitField & 16777216) !== 0;
|
||||
};
|
||||
|
||||
var isPending = PromiseInspection.prototype.isPending = function () {
|
||||
return (this._bitField & 50397184) === 0;
|
||||
};
|
||||
|
||||
var isResolved = PromiseInspection.prototype.isResolved = function () {
|
||||
return (this._bitField & 50331648) !== 0;
|
||||
};
|
||||
|
||||
PromiseInspection.prototype.isCancelled =
|
||||
Promise.prototype._isCancelled = function() {
|
||||
return (this._bitField & 65536) === 65536;
|
||||
};
|
||||
|
||||
Promise.prototype.isCancelled = function() {
|
||||
return this._target()._isCancelled();
|
||||
};
|
||||
|
||||
Promise.prototype.isPending = function() {
|
||||
return isPending.call(this._target());
|
||||
};
|
||||
|
||||
Promise.prototype.isRejected = function() {
|
||||
return isRejected.call(this._target());
|
||||
};
|
||||
|
||||
Promise.prototype.isFulfilled = function() {
|
||||
return isFulfilled.call(this._target());
|
||||
};
|
||||
|
||||
Promise.prototype.isResolved = function() {
|
||||
return isResolved.call(this._target());
|
||||
};
|
||||
|
||||
Promise.prototype.value = function() {
|
||||
return value.call(this._target());
|
||||
};
|
||||
|
||||
Promise.prototype.reason = function() {
|
||||
var target = this._target();
|
||||
target._unsetRejectionIsUnhandled();
|
||||
return reason.call(target);
|
||||
};
|
||||
|
||||
Promise.prototype._value = function() {
|
||||
return this._settledValue();
|
||||
};
|
||||
|
||||
Promise.prototype._reason = function() {
|
||||
this._unsetRejectionIsUnhandled();
|
||||
return this._settledValue();
|
||||
};
|
||||
|
||||
Promise.PromiseInspection = PromiseInspection;
|
||||
};
|
||||
86
node_modules/twit/node_modules/bluebird/js/release/thenables.js
generated
vendored
Normal file
86
node_modules/twit/node_modules/bluebird/js/release/thenables.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL) {
|
||||
var util = require("./util");
|
||||
var errorObj = util.errorObj;
|
||||
var isObject = util.isObject;
|
||||
|
||||
function tryConvertToPromise(obj, context) {
|
||||
if (isObject(obj)) {
|
||||
if (obj instanceof Promise) return obj;
|
||||
var then = getThen(obj);
|
||||
if (then === errorObj) {
|
||||
if (context) context._pushContext();
|
||||
var ret = Promise.reject(then.e);
|
||||
if (context) context._popContext();
|
||||
return ret;
|
||||
} else if (typeof then === "function") {
|
||||
if (isAnyBluebirdPromise(obj)) {
|
||||
var ret = new Promise(INTERNAL);
|
||||
obj._then(
|
||||
ret._fulfill,
|
||||
ret._reject,
|
||||
undefined,
|
||||
ret,
|
||||
null
|
||||
);
|
||||
return ret;
|
||||
}
|
||||
return doThenable(obj, then, context);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function doGetThen(obj) {
|
||||
return obj.then;
|
||||
}
|
||||
|
||||
function getThen(obj) {
|
||||
try {
|
||||
return doGetThen(obj);
|
||||
} catch (e) {
|
||||
errorObj.e = e;
|
||||
return errorObj;
|
||||
}
|
||||
}
|
||||
|
||||
var hasProp = {}.hasOwnProperty;
|
||||
function isAnyBluebirdPromise(obj) {
|
||||
try {
|
||||
return hasProp.call(obj, "_promise0");
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function doThenable(x, then, context) {
|
||||
var promise = new Promise(INTERNAL);
|
||||
var ret = promise;
|
||||
if (context) context._pushContext();
|
||||
promise._captureStackTrace();
|
||||
if (context) context._popContext();
|
||||
var synchronous = true;
|
||||
var result = util.tryCatch(then).call(x, resolve, reject);
|
||||
synchronous = false;
|
||||
|
||||
if (promise && result === errorObj) {
|
||||
promise._rejectCallback(result.e, true, true);
|
||||
promise = null;
|
||||
}
|
||||
|
||||
function resolve(value) {
|
||||
if (!promise) return;
|
||||
promise._resolveCallback(value);
|
||||
promise = null;
|
||||
}
|
||||
|
||||
function reject(reason) {
|
||||
if (!promise) return;
|
||||
promise._rejectCallback(reason, synchronous, true);
|
||||
promise = null;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
return tryConvertToPromise;
|
||||
};
|
||||
92
node_modules/twit/node_modules/bluebird/js/release/timers.js
generated
vendored
Normal file
92
node_modules/twit/node_modules/bluebird/js/release/timers.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
"use strict";
|
||||
module.exports = function(Promise, INTERNAL, debug) {
|
||||
var util = require("./util");
|
||||
var TimeoutError = Promise.TimeoutError;
|
||||
|
||||
function HandleWrapper(handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
HandleWrapper.prototype._resultCancelled = function() {
|
||||
clearTimeout(this.handle);
|
||||
};
|
||||
|
||||
var afterValue = function(value) { return delay(+this).thenReturn(value); };
|
||||
var delay = Promise.delay = function (ms, value) {
|
||||
var ret;
|
||||
var handle;
|
||||
if (value !== undefined) {
|
||||
ret = Promise.resolve(value)
|
||||
._then(afterValue, null, null, ms, undefined);
|
||||
if (debug.cancellation() && value instanceof Promise) {
|
||||
ret._setOnCancel(value);
|
||||
}
|
||||
} else {
|
||||
ret = new Promise(INTERNAL);
|
||||
handle = setTimeout(function() { ret._fulfill(); }, +ms);
|
||||
if (debug.cancellation()) {
|
||||
ret._setOnCancel(new HandleWrapper(handle));
|
||||
}
|
||||
}
|
||||
ret._setAsyncGuaranteed();
|
||||
return ret;
|
||||
};
|
||||
|
||||
Promise.prototype.delay = function (ms) {
|
||||
return delay(ms, this);
|
||||
};
|
||||
|
||||
var afterTimeout = function (promise, message, parent) {
|
||||
var err;
|
||||
if (typeof message !== "string") {
|
||||
if (message instanceof Error) {
|
||||
err = message;
|
||||
} else {
|
||||
err = new TimeoutError("operation timed out");
|
||||
}
|
||||
} else {
|
||||
err = new TimeoutError(message);
|
||||
}
|
||||
util.markAsOriginatingFromRejection(err);
|
||||
promise._attachExtraTrace(err);
|
||||
promise._reject(err);
|
||||
|
||||
if (parent != null) {
|
||||
parent.cancel();
|
||||
}
|
||||
};
|
||||
|
||||
function successClear(value) {
|
||||
clearTimeout(this.handle);
|
||||
return value;
|
||||
}
|
||||
|
||||
function failureClear(reason) {
|
||||
clearTimeout(this.handle);
|
||||
throw reason;
|
||||
}
|
||||
|
||||
Promise.prototype.timeout = function (ms, message) {
|
||||
ms = +ms;
|
||||
var ret, parent;
|
||||
|
||||
var handleWrapper = new HandleWrapper(setTimeout(function timeoutTimeout() {
|
||||
if (ret.isPending()) {
|
||||
afterTimeout(ret, message, parent);
|
||||
}
|
||||
}, ms));
|
||||
|
||||
if (debug.cancellation()) {
|
||||
parent = this.then();
|
||||
ret = parent._then(successClear, failureClear,
|
||||
undefined, handleWrapper, undefined);
|
||||
ret._setOnCancel(handleWrapper);
|
||||
} else {
|
||||
ret = this._then(successClear, failureClear,
|
||||
undefined, handleWrapper, undefined);
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
};
|
||||
226
node_modules/twit/node_modules/bluebird/js/release/using.js
generated
vendored
Normal file
226
node_modules/twit/node_modules/bluebird/js/release/using.js
generated
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
"use strict";
|
||||
module.exports = function (Promise, apiRejection, tryConvertToPromise,
|
||||
createContext, INTERNAL, debug) {
|
||||
var util = require("./util");
|
||||
var TypeError = require("./errors").TypeError;
|
||||
var inherits = require("./util").inherits;
|
||||
var errorObj = util.errorObj;
|
||||
var tryCatch = util.tryCatch;
|
||||
var NULL = {};
|
||||
|
||||
function thrower(e) {
|
||||
setTimeout(function(){throw e;}, 0);
|
||||
}
|
||||
|
||||
function castPreservingDisposable(thenable) {
|
||||
var maybePromise = tryConvertToPromise(thenable);
|
||||
if (maybePromise !== thenable &&
|
||||
typeof thenable._isDisposable === "function" &&
|
||||
typeof thenable._getDisposer === "function" &&
|
||||
thenable._isDisposable()) {
|
||||
maybePromise._setDisposable(thenable._getDisposer());
|
||||
}
|
||||
return maybePromise;
|
||||
}
|
||||
function dispose(resources, inspection) {
|
||||
var i = 0;
|
||||
var len = resources.length;
|
||||
var ret = new Promise(INTERNAL);
|
||||
function iterator() {
|
||||
if (i >= len) return ret._fulfill();
|
||||
var maybePromise = castPreservingDisposable(resources[i++]);
|
||||
if (maybePromise instanceof Promise &&
|
||||
maybePromise._isDisposable()) {
|
||||
try {
|
||||
maybePromise = tryConvertToPromise(
|
||||
maybePromise._getDisposer().tryDispose(inspection),
|
||||
resources.promise);
|
||||
} catch (e) {
|
||||
return thrower(e);
|
||||
}
|
||||
if (maybePromise instanceof Promise) {
|
||||
return maybePromise._then(iterator, thrower,
|
||||
null, null, null);
|
||||
}
|
||||
}
|
||||
iterator();
|
||||
}
|
||||
iterator();
|
||||
return ret;
|
||||
}
|
||||
|
||||
function Disposer(data, promise, context) {
|
||||
this._data = data;
|
||||
this._promise = promise;
|
||||
this._context = context;
|
||||
}
|
||||
|
||||
Disposer.prototype.data = function () {
|
||||
return this._data;
|
||||
};
|
||||
|
||||
Disposer.prototype.promise = function () {
|
||||
return this._promise;
|
||||
};
|
||||
|
||||
Disposer.prototype.resource = function () {
|
||||
if (this.promise().isFulfilled()) {
|
||||
return this.promise().value();
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
Disposer.prototype.tryDispose = function(inspection) {
|
||||
var resource = this.resource();
|
||||
var context = this._context;
|
||||
if (context !== undefined) context._pushContext();
|
||||
var ret = resource !== NULL
|
||||
? this.doDispose(resource, inspection) : null;
|
||||
if (context !== undefined) context._popContext();
|
||||
this._promise._unsetDisposable();
|
||||
this._data = null;
|
||||
return ret;
|
||||
};
|
||||
|
||||
Disposer.isDisposer = function (d) {
|
||||
return (d != null &&
|
||||
typeof d.resource === "function" &&
|
||||
typeof d.tryDispose === "function");
|
||||
};
|
||||
|
||||
function FunctionDisposer(fn, promise, context) {
|
||||
this.constructor$(fn, promise, context);
|
||||
}
|
||||
inherits(FunctionDisposer, Disposer);
|
||||
|
||||
FunctionDisposer.prototype.doDispose = function (resource, inspection) {
|
||||
var fn = this.data();
|
||||
return fn.call(resource, resource, inspection);
|
||||
};
|
||||
|
||||
function maybeUnwrapDisposer(value) {
|
||||
if (Disposer.isDisposer(value)) {
|
||||
this.resources[this.index]._setDisposable(value);
|
||||
return value.promise();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function ResourceList(length) {
|
||||
this.length = length;
|
||||
this.promise = null;
|
||||
this[length-1] = null;
|
||||
}
|
||||
|
||||
ResourceList.prototype._resultCancelled = function() {
|
||||
var len = this.length;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var item = this[i];
|
||||
if (item instanceof Promise) {
|
||||
item.cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Promise.using = function () {
|
||||
var len = arguments.length;
|
||||
if (len < 2) return apiRejection(
|
||||
"you must pass at least 2 arguments to Promise.using");
|
||||
var fn = arguments[len - 1];
|
||||
if (typeof fn !== "function") {
|
||||
return apiRejection("expecting a function but got " + util.classString(fn));
|
||||
}
|
||||
var input;
|
||||
var spreadArgs = true;
|
||||
if (len === 2 && Array.isArray(arguments[0])) {
|
||||
input = arguments[0];
|
||||
len = input.length;
|
||||
spreadArgs = false;
|
||||
} else {
|
||||
input = arguments;
|
||||
len--;
|
||||
}
|
||||
var resources = new ResourceList(len);
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var resource = input[i];
|
||||
if (Disposer.isDisposer(resource)) {
|
||||
var disposer = resource;
|
||||
resource = resource.promise();
|
||||
resource._setDisposable(disposer);
|
||||
} else {
|
||||
var maybePromise = tryConvertToPromise(resource);
|
||||
if (maybePromise instanceof Promise) {
|
||||
resource =
|
||||
maybePromise._then(maybeUnwrapDisposer, null, null, {
|
||||
resources: resources,
|
||||
index: i
|
||||
}, undefined);
|
||||
}
|
||||
}
|
||||
resources[i] = resource;
|
||||
}
|
||||
|
||||
var reflectedResources = new Array(resources.length);
|
||||
for (var i = 0; i < reflectedResources.length; ++i) {
|
||||
reflectedResources[i] = Promise.resolve(resources[i]).reflect();
|
||||
}
|
||||
|
||||
var resultPromise = Promise.all(reflectedResources)
|
||||
.then(function(inspections) {
|
||||
for (var i = 0; i < inspections.length; ++i) {
|
||||
var inspection = inspections[i];
|
||||
if (inspection.isRejected()) {
|
||||
errorObj.e = inspection.error();
|
||||
return errorObj;
|
||||
} else if (!inspection.isFulfilled()) {
|
||||
resultPromise.cancel();
|
||||
return;
|
||||
}
|
||||
inspections[i] = inspection.value();
|
||||
}
|
||||
promise._pushContext();
|
||||
|
||||
fn = tryCatch(fn);
|
||||
var ret = spreadArgs
|
||||
? fn.apply(undefined, inspections) : fn(inspections);
|
||||
var promiseCreated = promise._popContext();
|
||||
debug.checkForgottenReturns(
|
||||
ret, promiseCreated, "Promise.using", promise);
|
||||
return ret;
|
||||
});
|
||||
|
||||
var promise = resultPromise.lastly(function() {
|
||||
var inspection = new Promise.PromiseInspection(resultPromise);
|
||||
return dispose(resources, inspection);
|
||||
});
|
||||
resources.promise = promise;
|
||||
promise._setOnCancel(resources);
|
||||
return promise;
|
||||
};
|
||||
|
||||
Promise.prototype._setDisposable = function (disposer) {
|
||||
this._bitField = this._bitField | 131072;
|
||||
this._disposer = disposer;
|
||||
};
|
||||
|
||||
Promise.prototype._isDisposable = function () {
|
||||
return (this._bitField & 131072) > 0;
|
||||
};
|
||||
|
||||
Promise.prototype._getDisposer = function () {
|
||||
return this._disposer;
|
||||
};
|
||||
|
||||
Promise.prototype._unsetDisposable = function () {
|
||||
this._bitField = this._bitField & (~131072);
|
||||
this._disposer = undefined;
|
||||
};
|
||||
|
||||
Promise.prototype.disposer = function (fn) {
|
||||
if (typeof fn === "function") {
|
||||
return new FunctionDisposer(fn, this, createContext());
|
||||
}
|
||||
throw new TypeError();
|
||||
};
|
||||
|
||||
};
|
||||
370
node_modules/twit/node_modules/bluebird/js/release/util.js
generated
vendored
Normal file
370
node_modules/twit/node_modules/bluebird/js/release/util.js
generated
vendored
Normal file
@@ -0,0 +1,370 @@
|
||||
"use strict";
|
||||
var es5 = require("./es5");
|
||||
var canEvaluate = typeof navigator == "undefined";
|
||||
|
||||
var errorObj = {e: {}};
|
||||
var tryCatchTarget;
|
||||
var globalObject = typeof self !== "undefined" ? self :
|
||||
typeof window !== "undefined" ? window :
|
||||
typeof global !== "undefined" ? global :
|
||||
this !== undefined ? this : null;
|
||||
|
||||
function tryCatcher() {
|
||||
try {
|
||||
var target = tryCatchTarget;
|
||||
tryCatchTarget = null;
|
||||
return target.apply(this, arguments);
|
||||
} catch (e) {
|
||||
errorObj.e = e;
|
||||
return errorObj;
|
||||
}
|
||||
}
|
||||
function tryCatch(fn) {
|
||||
tryCatchTarget = fn;
|
||||
return tryCatcher;
|
||||
}
|
||||
|
||||
var inherits = function(Child, Parent) {
|
||||
var hasProp = {}.hasOwnProperty;
|
||||
|
||||
function T() {
|
||||
this.constructor = Child;
|
||||
this.constructor$ = Parent;
|
||||
for (var propertyName in Parent.prototype) {
|
||||
if (hasProp.call(Parent.prototype, propertyName) &&
|
||||
propertyName.charAt(propertyName.length-1) !== "$"
|
||||
) {
|
||||
this[propertyName + "$"] = Parent.prototype[propertyName];
|
||||
}
|
||||
}
|
||||
}
|
||||
T.prototype = Parent.prototype;
|
||||
Child.prototype = new T();
|
||||
return Child.prototype;
|
||||
};
|
||||
|
||||
|
||||
function isPrimitive(val) {
|
||||
return val == null || val === true || val === false ||
|
||||
typeof val === "string" || typeof val === "number";
|
||||
|
||||
}
|
||||
|
||||
function isObject(value) {
|
||||
return typeof value === "function" ||
|
||||
typeof value === "object" && value !== null;
|
||||
}
|
||||
|
||||
function maybeWrapAsError(maybeError) {
|
||||
if (!isPrimitive(maybeError)) return maybeError;
|
||||
|
||||
return new Error(safeToString(maybeError));
|
||||
}
|
||||
|
||||
function withAppended(target, appendee) {
|
||||
var len = target.length;
|
||||
var ret = new Array(len + 1);
|
||||
var i;
|
||||
for (i = 0; i < len; ++i) {
|
||||
ret[i] = target[i];
|
||||
}
|
||||
ret[i] = appendee;
|
||||
return ret;
|
||||
}
|
||||
|
||||
function getDataPropertyOrDefault(obj, key, defaultValue) {
|
||||
if (es5.isES5) {
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, key);
|
||||
|
||||
if (desc != null) {
|
||||
return desc.get == null && desc.set == null
|
||||
? desc.value
|
||||
: defaultValue;
|
||||
}
|
||||
} else {
|
||||
return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function notEnumerableProp(obj, name, value) {
|
||||
if (isPrimitive(obj)) return obj;
|
||||
var descriptor = {
|
||||
value: value,
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
};
|
||||
es5.defineProperty(obj, name, descriptor);
|
||||
return obj;
|
||||
}
|
||||
|
||||
function thrower(r) {
|
||||
throw r;
|
||||
}
|
||||
|
||||
var inheritedDataKeys = (function() {
|
||||
var excludedPrototypes = [
|
||||
Array.prototype,
|
||||
Object.prototype,
|
||||
Function.prototype
|
||||
];
|
||||
|
||||
var isExcludedProto = function(val) {
|
||||
for (var i = 0; i < excludedPrototypes.length; ++i) {
|
||||
if (excludedPrototypes[i] === val) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if (es5.isES5) {
|
||||
var getKeys = Object.getOwnPropertyNames;
|
||||
return function(obj) {
|
||||
var ret = [];
|
||||
var visitedKeys = Object.create(null);
|
||||
while (obj != null && !isExcludedProto(obj)) {
|
||||
var keys;
|
||||
try {
|
||||
keys = getKeys(obj);
|
||||
} catch (e) {
|
||||
return ret;
|
||||
}
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
if (visitedKeys[key]) continue;
|
||||
visitedKeys[key] = true;
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, key);
|
||||
if (desc != null && desc.get == null && desc.set == null) {
|
||||
ret.push(key);
|
||||
}
|
||||
}
|
||||
obj = es5.getPrototypeOf(obj);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
} else {
|
||||
var hasProp = {}.hasOwnProperty;
|
||||
return function(obj) {
|
||||
if (isExcludedProto(obj)) return [];
|
||||
var ret = [];
|
||||
|
||||
/*jshint forin:false */
|
||||
enumeration: for (var key in obj) {
|
||||
if (hasProp.call(obj, key)) {
|
||||
ret.push(key);
|
||||
} else {
|
||||
for (var i = 0; i < excludedPrototypes.length; ++i) {
|
||||
if (hasProp.call(excludedPrototypes[i], key)) {
|
||||
continue enumeration;
|
||||
}
|
||||
}
|
||||
ret.push(key);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/;
|
||||
function isClass(fn) {
|
||||
try {
|
||||
if (typeof fn === "function") {
|
||||
var keys = es5.names(fn.prototype);
|
||||
|
||||
var hasMethods = es5.isES5 && keys.length > 1;
|
||||
var hasMethodsOtherThanConstructor = keys.length > 0 &&
|
||||
!(keys.length === 1 && keys[0] === "constructor");
|
||||
var hasThisAssignmentAndStaticMethods =
|
||||
thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0;
|
||||
|
||||
if (hasMethods || hasMethodsOtherThanConstructor ||
|
||||
hasThisAssignmentAndStaticMethods) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function toFastProperties(obj) {
|
||||
/*jshint -W027,-W055,-W031*/
|
||||
function FakeConstructor() {}
|
||||
FakeConstructor.prototype = obj;
|
||||
var l = 8;
|
||||
while (l--) new FakeConstructor();
|
||||
return obj;
|
||||
eval(obj);
|
||||
}
|
||||
|
||||
var rident = /^[a-z$_][a-z$_0-9]*$/i;
|
||||
function isIdentifier(str) {
|
||||
return rident.test(str);
|
||||
}
|
||||
|
||||
function filledRange(count, prefix, suffix) {
|
||||
var ret = new Array(count);
|
||||
for(var i = 0; i < count; ++i) {
|
||||
ret[i] = prefix + i + suffix;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
function safeToString(obj) {
|
||||
try {
|
||||
return obj + "";
|
||||
} catch (e) {
|
||||
return "[no string representation]";
|
||||
}
|
||||
}
|
||||
|
||||
function isError(obj) {
|
||||
return obj !== null &&
|
||||
typeof obj === "object" &&
|
||||
typeof obj.message === "string" &&
|
||||
typeof obj.name === "string";
|
||||
}
|
||||
|
||||
function markAsOriginatingFromRejection(e) {
|
||||
try {
|
||||
notEnumerableProp(e, "isOperational", true);
|
||||
}
|
||||
catch(ignore) {}
|
||||
}
|
||||
|
||||
function originatesFromRejection(e) {
|
||||
if (e == null) return false;
|
||||
return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) ||
|
||||
e["isOperational"] === true);
|
||||
}
|
||||
|
||||
function canAttachTrace(obj) {
|
||||
return isError(obj) && es5.propertyIsWritable(obj, "stack");
|
||||
}
|
||||
|
||||
var ensureErrorObject = (function() {
|
||||
if (!("stack" in new Error())) {
|
||||
return function(value) {
|
||||
if (canAttachTrace(value)) return value;
|
||||
try {throw new Error(safeToString(value));}
|
||||
catch(err) {return err;}
|
||||
};
|
||||
} else {
|
||||
return function(value) {
|
||||
if (canAttachTrace(value)) return value;
|
||||
return new Error(safeToString(value));
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
function classString(obj) {
|
||||
return {}.toString.call(obj);
|
||||
}
|
||||
|
||||
function copyDescriptors(from, to, filter) {
|
||||
var keys = es5.names(from);
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
if (filter(key)) {
|
||||
try {
|
||||
es5.defineProperty(to, key, es5.getDescriptor(from, key));
|
||||
} catch (ignore) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var asArray = function(v) {
|
||||
if (es5.isArray(v)) {
|
||||
return v;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
if (typeof Symbol !== "undefined" && Symbol.iterator) {
|
||||
var ArrayFrom = typeof Array.from === "function" ? function(v) {
|
||||
return Array.from(v);
|
||||
} : function(v) {
|
||||
var ret = [];
|
||||
var it = v[Symbol.iterator]();
|
||||
var itResult;
|
||||
while (!((itResult = it.next()).done)) {
|
||||
ret.push(itResult.value);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
asArray = function(v) {
|
||||
if (es5.isArray(v)) {
|
||||
return v;
|
||||
} else if (v != null && typeof v[Symbol.iterator] === "function") {
|
||||
return ArrayFrom(v);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
var isNode = typeof process !== "undefined" &&
|
||||
classString(process).toLowerCase() === "[object process]";
|
||||
|
||||
function env(key, def) {
|
||||
return isNode ? process.env[key] : def;
|
||||
}
|
||||
|
||||
function getNativePromise() {
|
||||
if (typeof Promise === "function") {
|
||||
try {
|
||||
var promise = new Promise(function(){});
|
||||
if ({}.toString.call(promise) === "[object Promise]") {
|
||||
return Promise;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
var ret = {
|
||||
isClass: isClass,
|
||||
isIdentifier: isIdentifier,
|
||||
inheritedDataKeys: inheritedDataKeys,
|
||||
getDataPropertyOrDefault: getDataPropertyOrDefault,
|
||||
thrower: thrower,
|
||||
isArray: es5.isArray,
|
||||
asArray: asArray,
|
||||
notEnumerableProp: notEnumerableProp,
|
||||
isPrimitive: isPrimitive,
|
||||
isObject: isObject,
|
||||
isError: isError,
|
||||
canEvaluate: canEvaluate,
|
||||
errorObj: errorObj,
|
||||
tryCatch: tryCatch,
|
||||
inherits: inherits,
|
||||
withAppended: withAppended,
|
||||
maybeWrapAsError: maybeWrapAsError,
|
||||
toFastProperties: toFastProperties,
|
||||
filledRange: filledRange,
|
||||
toString: safeToString,
|
||||
canAttachTrace: canAttachTrace,
|
||||
ensureErrorObject: ensureErrorObject,
|
||||
originatesFromRejection: originatesFromRejection,
|
||||
markAsOriginatingFromRejection: markAsOriginatingFromRejection,
|
||||
classString: classString,
|
||||
copyDescriptors: copyDescriptors,
|
||||
hasDevTools: typeof chrome !== "undefined" && chrome &&
|
||||
typeof chrome.loadTimes === "function",
|
||||
isNode: isNode,
|
||||
env: env,
|
||||
global: globalObject,
|
||||
getNativePromise: getNativePromise
|
||||
};
|
||||
ret.isRecentNode = ret.isNode && (function() {
|
||||
var version = process.versions.node.split(".").map(Number);
|
||||
return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
|
||||
})();
|
||||
|
||||
if (ret.isNode) ret.toFastProperties(process);
|
||||
|
||||
try {throw new Error(); } catch (e) {ret.lastLineError = e;}
|
||||
module.exports = ret;
|
||||
102
node_modules/twit/node_modules/bluebird/package.json
generated
vendored
Normal file
102
node_modules/twit/node_modules/bluebird/package.json
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"name": "bluebird",
|
||||
"description": "Full featured Promises/A+ implementation with exceptionally good performance",
|
||||
"version": "3.4.1",
|
||||
"keywords": [
|
||||
"promise",
|
||||
"performance",
|
||||
"promises",
|
||||
"promises-a",
|
||||
"promises-aplus",
|
||||
"async",
|
||||
"await",
|
||||
"deferred",
|
||||
"deferreds",
|
||||
"future",
|
||||
"flow control",
|
||||
"dsl",
|
||||
"fluent interface"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "node scripts/jshint.js",
|
||||
"test": "node tools/test.js",
|
||||
"istanbul": "istanbul",
|
||||
"prepublish": "npm run generate-browser-core && npm run generate-browser-full",
|
||||
"generate-browser-full": "node tools/build.js --no-clean --no-debug --release --browser --minify",
|
||||
"generate-browser-core": "node tools/build.js --features=core --no-debug --release --zalgo --browser --minify && mv js/browser/bluebird.js js/browser/bluebird.core.js && mv js/browser/bluebird.min.js js/browser/bluebird.core.min.js"
|
||||
},
|
||||
"homepage": "https://github.com/petkaantonov/bluebird",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/petkaantonov/bluebird.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/petkaantonov/bluebird/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Petka Antonov",
|
||||
"email": "petka_antonov@hotmail.com",
|
||||
"url": "http://github.com/petkaantonov/"
|
||||
},
|
||||
"devDependencies": {
|
||||
"acorn": "~0.6.0",
|
||||
"baconjs": "^0.7.43",
|
||||
"bluebird": "^2.9.2",
|
||||
"body-parser": "^1.10.2",
|
||||
"browserify": "^8.1.1",
|
||||
"cli-table": "~0.3.1",
|
||||
"co": "^4.2.0",
|
||||
"cross-spawn": "^0.2.3",
|
||||
"glob": "^4.3.2",
|
||||
"grunt-saucelabs": "~8.4.1",
|
||||
"highland": "^2.3.0",
|
||||
"istanbul": "^0.3.5",
|
||||
"jshint": "^2.6.0",
|
||||
"jshint-stylish": "~0.2.0",
|
||||
"mkdirp": "~0.5.0",
|
||||
"mocha": "~2.1",
|
||||
"open": "~0.0.5",
|
||||
"optimist": "~0.6.1",
|
||||
"rimraf": "~2.2.6",
|
||||
"rx": "^2.3.25",
|
||||
"serve-static": "^1.7.1",
|
||||
"sinon": "~1.7.3",
|
||||
"uglify-js": "~2.4.16",
|
||||
"kefir": "^2.4.1"
|
||||
},
|
||||
"main": "./js/release/bluebird.js",
|
||||
"browser": "./js/browser/bluebird.js",
|
||||
"files": [
|
||||
"js/browser",
|
||||
"js/release",
|
||||
"LICENSE"
|
||||
],
|
||||
"gitHead": "fa5752d31ed3329631af4eebbcaa26c73b0407b8",
|
||||
"_id": "bluebird@3.4.1",
|
||||
"_shasum": "b731ddf48e2dd3bedac2e75e1215a11bcb91fa07",
|
||||
"_from": "bluebird@>=3.1.5 <4.0.0",
|
||||
"_npmVersion": "3.6.0",
|
||||
"_nodeVersion": "5.6.0",
|
||||
"_npmUser": {
|
||||
"name": "esailija",
|
||||
"email": "petka_antonov@hotmail.com"
|
||||
},
|
||||
"dist": {
|
||||
"shasum": "b731ddf48e2dd3bedac2e75e1215a11bcb91fa07",
|
||||
"tarball": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.1.tgz"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "esailija",
|
||||
"email": "petka_antonov@hotmail.com"
|
||||
}
|
||||
],
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-16-east.internal.npmjs.com",
|
||||
"tmp": "tmp/bluebird-3.4.1.tgz_1466192624169_0.8191918630618602"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.1.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
||||
0
node_modules/twit/node_modules/mime/.npmignore
generated
vendored
Normal file
0
node_modules/twit/node_modules/mime/.npmignore
generated
vendored
Normal file
19
node_modules/twit/node_modules/mime/LICENSE
generated
vendored
Normal file
19
node_modules/twit/node_modules/mime/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2010 Benjamin Thomas, Robert Kieffer
|
||||
|
||||
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.
|
||||
90
node_modules/twit/node_modules/mime/README.md
generated
vendored
Normal file
90
node_modules/twit/node_modules/mime/README.md
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
# mime
|
||||
|
||||
Comprehensive MIME type mapping API based on mime-db module.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](http://github.com/isaacs/npm):
|
||||
|
||||
npm install mime
|
||||
|
||||
## Contributing / Testing
|
||||
|
||||
npm run test
|
||||
|
||||
## Command Line
|
||||
|
||||
mime [path_string]
|
||||
|
||||
E.g.
|
||||
|
||||
> mime scripts/jquery.js
|
||||
application/javascript
|
||||
|
||||
## API - Queries
|
||||
|
||||
### mime.lookup(path)
|
||||
Get the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g.
|
||||
|
||||
```js
|
||||
var mime = require('mime');
|
||||
|
||||
mime.lookup('/path/to/file.txt'); // => 'text/plain'
|
||||
mime.lookup('file.txt'); // => 'text/plain'
|
||||
mime.lookup('.TXT'); // => 'text/plain'
|
||||
mime.lookup('htm'); // => 'text/html'
|
||||
```
|
||||
|
||||
### mime.default_type
|
||||
Sets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.)
|
||||
|
||||
### mime.extension(type)
|
||||
Get the default extension for `type`
|
||||
|
||||
```js
|
||||
mime.extension('text/html'); // => 'html'
|
||||
mime.extension('application/octet-stream'); // => 'bin'
|
||||
```
|
||||
|
||||
### mime.charsets.lookup()
|
||||
|
||||
Map mime-type to charset
|
||||
|
||||
```js
|
||||
mime.charsets.lookup('text/plain'); // => 'UTF-8'
|
||||
```
|
||||
|
||||
(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)
|
||||
|
||||
## API - Defining Custom Types
|
||||
|
||||
Custom type mappings can be added on a per-project basis via the following APIs.
|
||||
|
||||
### mime.define()
|
||||
|
||||
Add custom mime/extension mappings
|
||||
|
||||
```js
|
||||
mime.define({
|
||||
'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],
|
||||
'application/x-my-type': ['x-mt', 'x-mtt'],
|
||||
// etc ...
|
||||
});
|
||||
|
||||
mime.lookup('x-sft'); // => 'text/x-some-format'
|
||||
```
|
||||
|
||||
The first entry in the extensions array is returned by `mime.extension()`. E.g.
|
||||
|
||||
```js
|
||||
mime.extension('text/x-some-format'); // => 'x-sf'
|
||||
```
|
||||
|
||||
### mime.load(filepath)
|
||||
|
||||
Load mappings from an Apache ".types" format file
|
||||
|
||||
```js
|
||||
mime.load('./my_project.types');
|
||||
```
|
||||
The .types file format is simple - See the `types` dir for examples.
|
||||
11
node_modules/twit/node_modules/mime/build/build.js
generated
vendored
Normal file
11
node_modules/twit/node_modules/mime/build/build.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
var db = require('mime-db');
|
||||
|
||||
var mapByType = {};
|
||||
Object.keys(db).forEach(function(key) {
|
||||
var extensions = db[key].extensions;
|
||||
if (extensions) {
|
||||
mapByType[key] = extensions;
|
||||
}
|
||||
});
|
||||
|
||||
console.log(JSON.stringify(mapByType));
|
||||
57
node_modules/twit/node_modules/mime/build/test.js
generated
vendored
Normal file
57
node_modules/twit/node_modules/mime/build/test.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Usage: node test.js
|
||||
*/
|
||||
|
||||
var mime = require('../mime');
|
||||
var assert = require('assert');
|
||||
var path = require('path');
|
||||
|
||||
//
|
||||
// Test mime lookups
|
||||
//
|
||||
|
||||
assert.equal('text/plain', mime.lookup('text.txt')); // normal file
|
||||
assert.equal('text/plain', mime.lookup('TEXT.TXT')); // uppercase
|
||||
assert.equal('text/plain', mime.lookup('dir/text.txt')); // dir + file
|
||||
assert.equal('text/plain', mime.lookup('.text.txt')); // hidden file
|
||||
assert.equal('text/plain', mime.lookup('.txt')); // nameless
|
||||
assert.equal('text/plain', mime.lookup('txt')); // extension-only
|
||||
assert.equal('text/plain', mime.lookup('/txt')); // extension-less ()
|
||||
assert.equal('text/plain', mime.lookup('\\txt')); // Windows, extension-less
|
||||
assert.equal('application/octet-stream', mime.lookup('text.nope')); // unrecognized
|
||||
assert.equal('fallback', mime.lookup('text.fallback', 'fallback')); // alternate default
|
||||
|
||||
//
|
||||
// Test extensions
|
||||
//
|
||||
|
||||
assert.equal('txt', mime.extension(mime.types.text));
|
||||
assert.equal('html', mime.extension(mime.types.htm));
|
||||
assert.equal('bin', mime.extension('application/octet-stream'));
|
||||
assert.equal('bin', mime.extension('application/octet-stream '));
|
||||
assert.equal('html', mime.extension(' text/html; charset=UTF-8'));
|
||||
assert.equal('html', mime.extension('text/html; charset=UTF-8 '));
|
||||
assert.equal('html', mime.extension('text/html; charset=UTF-8'));
|
||||
assert.equal('html', mime.extension('text/html ; charset=UTF-8'));
|
||||
assert.equal('html', mime.extension('text/html;charset=UTF-8'));
|
||||
assert.equal('html', mime.extension('text/Html;charset=UTF-8'));
|
||||
assert.equal(undefined, mime.extension('unrecognized'));
|
||||
|
||||
//
|
||||
// Test node.types lookups
|
||||
//
|
||||
|
||||
assert.equal('application/font-woff', mime.lookup('file.woff'));
|
||||
assert.equal('application/octet-stream', mime.lookup('file.buffer'));
|
||||
assert.equal('audio/mp4', mime.lookup('file.m4a'));
|
||||
assert.equal('font/opentype', mime.lookup('file.otf'));
|
||||
|
||||
//
|
||||
// Test charsets
|
||||
//
|
||||
|
||||
assert.equal('UTF-8', mime.charsets.lookup('text/plain'));
|
||||
assert.equal(undefined, mime.charsets.lookup(mime.types.js));
|
||||
assert.equal('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));
|
||||
|
||||
console.log('\nAll tests passed');
|
||||
8
node_modules/twit/node_modules/mime/cli.js
generated
vendored
Executable file
8
node_modules/twit/node_modules/mime/cli.js
generated
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var mime = require('./mime.js');
|
||||
var file = process.argv[2];
|
||||
var type = mime.lookup(file);
|
||||
|
||||
process.stdout.write(type + '\n');
|
||||
|
||||
108
node_modules/twit/node_modules/mime/mime.js
generated
vendored
Normal file
108
node_modules/twit/node_modules/mime/mime.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
function Mime() {
|
||||
// Map of extension -> mime type
|
||||
this.types = Object.create(null);
|
||||
|
||||
// Map of mime type -> extension
|
||||
this.extensions = Object.create(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define mimetype -> extension mappings. Each key is a mime-type that maps
|
||||
* to an array of extensions associated with the type. The first extension is
|
||||
* used as the default extension for the type.
|
||||
*
|
||||
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
|
||||
*
|
||||
* @param map (Object) type definitions
|
||||
*/
|
||||
Mime.prototype.define = function (map) {
|
||||
for (var type in map) {
|
||||
var exts = map[type];
|
||||
for (var i = 0; i < exts.length; i++) {
|
||||
if (process.env.DEBUG_MIME && this.types[exts]) {
|
||||
console.warn(this._loading.replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' +
|
||||
this.types[exts] + ' to ' + type);
|
||||
}
|
||||
|
||||
this.types[exts[i]] = type;
|
||||
}
|
||||
|
||||
// Default extension is the first one we encounter
|
||||
if (!this.extensions[type]) {
|
||||
this.extensions[type] = exts[0];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Load an Apache2-style ".types" file
|
||||
*
|
||||
* This may be called multiple times (it's expected). Where files declare
|
||||
* overlapping types/extensions, the last file wins.
|
||||
*
|
||||
* @param file (String) path of file to load.
|
||||
*/
|
||||
Mime.prototype.load = function(file) {
|
||||
this._loading = file;
|
||||
// Read file and split into lines
|
||||
var map = {},
|
||||
content = fs.readFileSync(file, 'ascii'),
|
||||
lines = content.split(/[\r\n]+/);
|
||||
|
||||
lines.forEach(function(line) {
|
||||
// Clean up whitespace/comments, and split into fields
|
||||
var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/);
|
||||
map[fields.shift()] = fields;
|
||||
});
|
||||
|
||||
this.define(map);
|
||||
|
||||
this._loading = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Lookup a mime type based on extension
|
||||
*/
|
||||
Mime.prototype.lookup = function(path, fallback) {
|
||||
var ext = path.replace(/.*[\.\/\\]/, '').toLowerCase();
|
||||
|
||||
return this.types[ext] || fallback || this.default_type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return file extension associated with a mime type
|
||||
*/
|
||||
Mime.prototype.extension = function(mimeType) {
|
||||
var type = mimeType.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase();
|
||||
return this.extensions[type];
|
||||
};
|
||||
|
||||
// Default instance
|
||||
var mime = new Mime();
|
||||
|
||||
// Define built-in types
|
||||
mime.define(require('./types.json'));
|
||||
|
||||
// Default type
|
||||
mime.default_type = mime.lookup('bin');
|
||||
|
||||
//
|
||||
// Additional API specific to the default instance
|
||||
//
|
||||
|
||||
mime.Mime = Mime;
|
||||
|
||||
/**
|
||||
* Lookup a charset based on mime type.
|
||||
*/
|
||||
mime.charsets = {
|
||||
lookup: function(mimeType, fallback) {
|
||||
// Assume text types are utf8
|
||||
return (/^text\//).test(mimeType) ? 'UTF-8' : fallback;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = mime;
|
||||
73
node_modules/twit/node_modules/mime/package.json
generated
vendored
Normal file
73
node_modules/twit/node_modules/mime/package.json
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Robert Kieffer",
|
||||
"email": "robert@broofa.com",
|
||||
"url": "http://github.com/broofa"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "node build/build.js > types.json",
|
||||
"test": "node build/test.js"
|
||||
},
|
||||
"bin": {
|
||||
"mime": "cli.js"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Benjamin Thomas",
|
||||
"email": "benjamin@benjaminthomas.org",
|
||||
"url": "http://github.com/bentomas"
|
||||
}
|
||||
],
|
||||
"description": "A comprehensive library for mime-type mapping",
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://raw.github.com/broofa/node-mime/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"mime-db": "^1.2.0"
|
||||
},
|
||||
"keywords": [
|
||||
"util",
|
||||
"mime"
|
||||
],
|
||||
"main": "mime.js",
|
||||
"name": "mime",
|
||||
"repository": {
|
||||
"url": "git+https://github.com/broofa/node-mime.git",
|
||||
"type": "git"
|
||||
},
|
||||
"version": "1.3.4",
|
||||
"gitHead": "1628f6e0187095009dcef4805c3a49706f137974",
|
||||
"bugs": {
|
||||
"url": "https://github.com/broofa/node-mime/issues"
|
||||
},
|
||||
"homepage": "https://github.com/broofa/node-mime",
|
||||
"_id": "mime@1.3.4",
|
||||
"_shasum": "115f9e3b6b3daf2959983cb38f149a2d40eb5d53",
|
||||
"_from": "mime@>=1.3.4 <2.0.0",
|
||||
"_npmVersion": "1.4.28",
|
||||
"_npmUser": {
|
||||
"name": "broofa",
|
||||
"email": "robert@broofa.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "broofa",
|
||||
"email": "robert@broofa.com"
|
||||
},
|
||||
{
|
||||
"name": "bentomas",
|
||||
"email": "benjamin@benjaminthomas.org"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "115f9e3b6b3daf2959983cb38f149a2d40eb5d53",
|
||||
"tarball": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
||||
1
node_modules/twit/node_modules/mime/types.json
generated
vendored
Normal file
1
node_modules/twit/node_modules/mime/types.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
45
node_modules/twit/node_modules/request/.eslintrc
generated
vendored
Normal file
45
node_modules/twit/node_modules/request/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"rules": {
|
||||
// 2-space indentation
|
||||
"indent": [2, 2],
|
||||
// Disallow semi-colons, unless needed to disambiguate statement
|
||||
"semi": [2, "never"],
|
||||
// Require strings to use single quotes
|
||||
"quotes": [2, "single"],
|
||||
// Require curly braces for all control statements
|
||||
"curly": 2,
|
||||
// Disallow using variables and functions before they've been defined
|
||||
"no-use-before-define": 2,
|
||||
// Allow any case for variable naming
|
||||
"camelcase": 0,
|
||||
// Disallow unused variables, except as function arguments
|
||||
"no-unused-vars": [2, {"args":"none"}],
|
||||
// Allow leading underscores for method names
|
||||
// REASON: we use underscores to denote private methods
|
||||
"no-underscore-dangle": 0,
|
||||
// Allow multi spaces around operators since they are
|
||||
// used for alignment. This is not consistent in the
|
||||
// code.
|
||||
"no-multi-spaces": 0,
|
||||
// Style rule is: most objects use { beforeColon: false, afterColon: true }, unless aligning which uses:
|
||||
//
|
||||
// {
|
||||
// beforeColon : true,
|
||||
// afterColon : true
|
||||
// }
|
||||
//
|
||||
// eslint can't handle this, so the check is disabled.
|
||||
"key-spacing": 0,
|
||||
// Allow shadowing vars in outer scope (needs discussion)
|
||||
"no-shadow": 0,
|
||||
// Use if () { }
|
||||
// ^ space
|
||||
"space-after-keywords": [2, "always"],
|
||||
// Use if () { }
|
||||
// ^ space
|
||||
"space-before-blocks": [2, "always"]
|
||||
}
|
||||
}
|
||||
3
node_modules/twit/node_modules/request/.npmignore
generated
vendored
Normal file
3
node_modules/twit/node_modules/request/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
coverage
|
||||
tests
|
||||
node_modules
|
||||
14
node_modules/twit/node_modules/request/.travis.yml
generated
vendored
Normal file
14
node_modules/twit/node_modules/request/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "io.js"
|
||||
- "0.12"
|
||||
- "0.10"
|
||||
sudo: false
|
||||
|
||||
after_script: "npm run test-cov && cat ./coverage/lcov.info | codecov && cat ./coverage/lcov.info | coveralls"
|
||||
|
||||
webhooks:
|
||||
urls: https://webhooks.gitter.im/e/237280ed4796c19cc626
|
||||
on_success: change # options: [always|never|change] default: always
|
||||
on_failure: always # options: [always|never|change] default: always
|
||||
on_start: false # default: false
|
||||
499
node_modules/twit/node_modules/request/CHANGELOG.md
generated
vendored
Normal file
499
node_modules/twit/node_modules/request/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,499 @@
|
||||
## Change Log
|
||||
|
||||
### v2.58.0 (2015/06/16)
|
||||
- [#1638](https://github.com/request/request/pull/1638) Use the `extend` module to deep extend in the defaults method (@simov)
|
||||
- [#1631](https://github.com/request/request/pull/1631) Move tunnel logic into separate module (@simov)
|
||||
- [#1634](https://github.com/request/request/pull/1634) Fix OAuth query transport_method (@simov)
|
||||
- [#1603](https://github.com/request/request/pull/1603) Add codecov (@simov)
|
||||
|
||||
### v2.57.0 (2015/05/31)
|
||||
- [#1615](https://github.com/request/request/pull/1615) Replace '.client' with '.socket' as the former was deprecated in 2.2.0. (@ChALkeR)
|
||||
|
||||
### v2.56.0 (2015/05/28)
|
||||
- [#1610](https://github.com/request/request/pull/1610) Bump module dependencies (@simov)
|
||||
- [#1600](https://github.com/request/request/pull/1600) Extract the querystring logic into separate module (@simov)
|
||||
- [#1607](https://github.com/request/request/pull/1607) Re-generate certificates (@simov)
|
||||
- [#1599](https://github.com/request/request/pull/1599) Move getProxyFromURI logic below the check for Invaild URI (#1595) (@simov)
|
||||
- [#1598](https://github.com/request/request/pull/1598) Fix the way http verbs are defined in order to please intellisense IDEs (@simov, @flannelJesus)
|
||||
- [#1591](https://github.com/request/request/pull/1591) A few minor fixes: (@simov)
|
||||
- [#1584](https://github.com/request/request/pull/1584) Refactor test-default tests (according to comments in #1430) (@simov)
|
||||
- [#1585](https://github.com/request/request/pull/1585) Fixing documentation regarding TLS options (#1583) (@mainakae)
|
||||
- [#1574](https://github.com/request/request/pull/1574) Refresh the oauth_nonce on redirect (#1573) (@simov)
|
||||
- [#1570](https://github.com/request/request/pull/1570) Discovered tests that weren't properly running (@seanstrom)
|
||||
- [#1569](https://github.com/request/request/pull/1569) Fix pause before response arrives (@kevinoid)
|
||||
- [#1558](https://github.com/request/request/pull/1558) Emit error instead of throw (@simov)
|
||||
- [#1568](https://github.com/request/request/pull/1568) Fix stall when piping gzipped response (@kevinoid)
|
||||
- [#1560](https://github.com/request/request/pull/1560) Update combined-stream (@apechimp)
|
||||
- [#1543](https://github.com/request/request/pull/1543) Initial support for oauth_body_hash on json payloads (@simov, @aesopwolf)
|
||||
- [#1541](https://github.com/request/request/pull/1541) Fix coveralls (@simov)
|
||||
- [#1540](https://github.com/request/request/pull/1540) Fix recursive defaults for convenience methods (@simov)
|
||||
- [#1536](https://github.com/request/request/pull/1536) More eslint style rules (@froatsnook)
|
||||
- [#1533](https://github.com/request/request/pull/1533) Adding dependency status bar to README.md (@YasharF)
|
||||
- [#1539](https://github.com/request/request/pull/1539) ensure the latest version of har-validator is included (@ahmadnassri)
|
||||
- [#1516](https://github.com/request/request/pull/1516) forever+pool test (@devTristan)
|
||||
|
||||
### v2.55.0 (2015/04/05)
|
||||
- [#1520](https://github.com/request/request/pull/1520) Refactor defaults (@simov)
|
||||
- [#1525](https://github.com/request/request/pull/1525) Delete request headers with undefined value. (@froatsnook)
|
||||
- [#1521](https://github.com/request/request/pull/1521) Add promise tests (@simov)
|
||||
- [#1518](https://github.com/request/request/pull/1518) Fix defaults (@simov)
|
||||
- [#1515](https://github.com/request/request/pull/1515) Allow static invoking of convenience methods (@simov)
|
||||
- [#1505](https://github.com/request/request/pull/1505) Fix multipart boundary extraction regexp (@simov)
|
||||
- [#1510](https://github.com/request/request/pull/1510) Fix basic auth form data (@simov)
|
||||
|
||||
### v2.54.0 (2015/03/24)
|
||||
- [#1501](https://github.com/request/request/pull/1501) HTTP Archive 1.2 support (@ahmadnassri)
|
||||
- [#1486](https://github.com/request/request/pull/1486) Add a test for the forever agent (@akshayp)
|
||||
- [#1500](https://github.com/request/request/pull/1500) Adding handling for no auth method and null bearer (@philberg)
|
||||
- [#1498](https://github.com/request/request/pull/1498) Add table of contents in readme (@simov)
|
||||
- [#1477](https://github.com/request/request/pull/1477) Add support for qs options via qsOptions key (@simov)
|
||||
- [#1496](https://github.com/request/request/pull/1496) Parameters encoded to base 64 should be decoded as UTF-8, not ASCII. (@albanm)
|
||||
- [#1494](https://github.com/request/request/pull/1494) Update eslint (@froatsnook)
|
||||
- [#1474](https://github.com/request/request/pull/1474) Require Colon in Basic Auth (@erykwalder)
|
||||
- [#1481](https://github.com/request/request/pull/1481) Fix baseUrl and redirections. (@burningtree)
|
||||
- [#1469](https://github.com/request/request/pull/1469) Feature/base url (@froatsnook)
|
||||
- [#1459](https://github.com/request/request/pull/1459) Add option to time request/response cycle (including rollup of redirects) (@aaron-em)
|
||||
- [#1468](https://github.com/request/request/pull/1468) Re-enable io.js/node 0.12 build (@simov, @mikeal, @BBB)
|
||||
- [#1442](https://github.com/request/request/pull/1442) Fixed the issue with strictSSL tests on 0.12 & io.js by explicitly setting a cipher that matches the cert. (@BBB, @nicolasmccurdy, @simov, @0x4139)
|
||||
- [#1460](https://github.com/request/request/pull/1460) localAddress or proxy config is lost when redirecting (@simov, @0x4139)
|
||||
- [#1453](https://github.com/request/request/pull/1453) Test on Node.js 0.12 and io.js with allowed failures (@nicolasmccurdy)
|
||||
- [#1426](https://github.com/request/request/pull/1426) Fixing tests to pass on io.js and node 0.12 (only test-https.js stiff failing) (@mikeal)
|
||||
- [#1446](https://github.com/request/request/pull/1446) Missing HTTP referer header with redirects Fixes #1038 (@simov, @guimonz)
|
||||
- [#1428](https://github.com/request/request/pull/1428) Deprecate Node v0.8.x (@nylen)
|
||||
- [#1436](https://github.com/request/request/pull/1436) Add ability to set a requester without setting default options (@tikotzky)
|
||||
- [#1435](https://github.com/request/request/pull/1435) dry up verb methods (@sethpollack)
|
||||
- [#1423](https://github.com/request/request/pull/1423) Allow fully qualified multipart content-type header (@simov)
|
||||
- [#1430](https://github.com/request/request/pull/1430) Fix recursive requester (@tikotzky)
|
||||
- [#1429](https://github.com/request/request/pull/1429) Throw error when making HEAD request with a body (@tikotzky)
|
||||
- [#1419](https://github.com/request/request/pull/1419) Add note that the project is broken in 0.12.x (@nylen)
|
||||
- [#1413](https://github.com/request/request/pull/1413) Fix basic auth (@simov)
|
||||
- [#1397](https://github.com/request/request/pull/1397) Improve pipe-from-file tests (@nylen)
|
||||
|
||||
### v2.53.0 (2015/02/02)
|
||||
- [#1396](https://github.com/request/request/pull/1396) Do not rfc3986 escape JSON bodies (@nylen, @simov)
|
||||
- [#1392](https://github.com/request/request/pull/1392) Improve `timeout` option description (@watson)
|
||||
|
||||
### v2.52.0 (2015/02/02)
|
||||
- [#1383](https://github.com/request/request/pull/1383) Add missing HTTPS options that were not being passed to tunnel (@brichard19) (@nylen, @brichard19)
|
||||
- [#1388](https://github.com/request/request/pull/1388) Upgrade mime-types package version (@roderickhsiao)
|
||||
- [#1389](https://github.com/request/request/pull/1389) Revise Setup Tunnel Function (@seanstrom)
|
||||
- [#1374](https://github.com/request/request/pull/1374) Allow explicitly disabling tunneling for proxied https destinations (@nylen)
|
||||
- [#1376](https://github.com/request/request/pull/1376) Use karma-browserify for tests. Add browser test coverage reporter. (@eiriksm)
|
||||
- [#1366](https://github.com/request/request/pull/1366) Refactor OAuth into separate module (@simov)
|
||||
- [#1373](https://github.com/request/request/pull/1373) Rewrite tunnel test to be pure Node.js (@nylen)
|
||||
- [#1371](https://github.com/request/request/pull/1371) Upgrade test reporter (@nylen)
|
||||
- [#1360](https://github.com/request/request/pull/1360) Refactor basic, bearer, digest auth logic into separate class (@simov)
|
||||
- [#1354](https://github.com/request/request/pull/1354) Remove circular dependency from debugging code (@nylen)
|
||||
- [#1351](https://github.com/request/request/pull/1351) Move digest auth into private prototype method (@simov)
|
||||
- [#1352](https://github.com/request/request/pull/1352) Update hawk dependency to ~2.3.0 (@mridgway)
|
||||
- [#1353](https://github.com/request/request/pull/1353) Correct travis-ci badge (@dogancelik)
|
||||
- [#1349](https://github.com/request/request/pull/1349) Make sure we return on errored browser requests. (@eiriksm)
|
||||
- [#1346](https://github.com/request/request/pull/1346) getProxyFromURI Extraction Refactor (@seanstrom)
|
||||
- [#1337](https://github.com/request/request/pull/1337) Standardize test ports on 6767 (@nylen)
|
||||
- [#1341](https://github.com/request/request/pull/1341) Emit FormData error events as Request error events (@nylen, @rwky)
|
||||
- [#1343](https://github.com/request/request/pull/1343) Clean up readme badges, and add Travis and Coveralls badges (@nylen)
|
||||
- [#1345](https://github.com/request/request/pull/1345) Update README.md (@Aaron-Hartwig)
|
||||
- [#1338](https://github.com/request/request/pull/1338) Always wait for server.close() callback in tests (@nylen)
|
||||
- [#1342](https://github.com/request/request/pull/1342) Add mock https server and redo start of browser tests for this purpose. (@eiriksm)
|
||||
- [#1339](https://github.com/request/request/pull/1339) Improve auth docs (@nylen)
|
||||
- [#1335](https://github.com/request/request/pull/1335) Add support for OAuth plaintext signature method (@simov)
|
||||
- [#1332](https://github.com/request/request/pull/1332) Add clean script to remove test-browser.js after the tests run (@seanstrom)
|
||||
- [#1327](https://github.com/request/request/pull/1327) Fix errors generating coverage reports. (@nylen)
|
||||
- [#1330](https://github.com/request/request/pull/1330) Return empty buffer upon empty response body and encoding is set to null (@seanstrom)
|
||||
- [#1326](https://github.com/request/request/pull/1326) Use faster container-based infrastructure on Travis (@nylen)
|
||||
- [#1315](https://github.com/request/request/pull/1315) Implement rfc3986 option (@simov, @nylen, @apoco, @DullReferenceException, @mmalecki, @oliamb, @cliffcrosland, @LewisJEllis, @eiriksm, @poislagarde)
|
||||
- [#1314](https://github.com/request/request/pull/1314) Detect urlencoded form data header via regex (@simov)
|
||||
- [#1317](https://github.com/request/request/pull/1317) Improve OAuth1.0 server side flow example (@simov)
|
||||
|
||||
### v2.51.0 (2014/12/10)
|
||||
- [#1310](https://github.com/request/request/pull/1310) Revert changes introduced in https://github.com/request/request/pull/1282 (@simov)
|
||||
|
||||
### v2.50.0 (2014/12/09)
|
||||
- [#1308](https://github.com/request/request/pull/1308) Add browser test to keep track of browserify compability. (@eiriksm)
|
||||
- [#1299](https://github.com/request/request/pull/1299) Add optional support for jsonReviver (@poislagarde)
|
||||
- [#1277](https://github.com/request/request/pull/1277) Add Coveralls configuration (@simov)
|
||||
- [#1307](https://github.com/request/request/pull/1307) Upgrade form-data, add back browserify compability. Fixes #455. (@eiriksm)
|
||||
- [#1305](https://github.com/request/request/pull/1305) Fix typo in README.md (@LewisJEllis)
|
||||
- [#1288](https://github.com/request/request/pull/1288) Update README.md to explain custom file use case (@cliffcrosland)
|
||||
|
||||
### v2.49.0 (2014/11/28)
|
||||
- [#1295](https://github.com/request/request/pull/1295) fix(proxy): no-proxy false positive (@oliamb)
|
||||
- [#1292](https://github.com/request/request/pull/1292) Upgrade `caseless` to 0.8.1 (@mmalecki)
|
||||
- [#1276](https://github.com/request/request/pull/1276) Set transfer encoding for multipart/related to chunked by default (@simov)
|
||||
- [#1275](https://github.com/request/request/pull/1275) Fix multipart content-type headers detection (@simov)
|
||||
- [#1269](https://github.com/request/request/pull/1269) adds streams example for review (@tbuchok)
|
||||
- [#1238](https://github.com/request/request/pull/1238) Add examples README.md (@simov)
|
||||
|
||||
### v2.48.0 (2014/11/12)
|
||||
- [#1263](https://github.com/request/request/pull/1263) Fixed a syntax error / typo in README.md (@xna2)
|
||||
- [#1253](https://github.com/request/request/pull/1253) Add multipart chunked flag (@simov, @nylen)
|
||||
- [#1251](https://github.com/request/request/pull/1251) Clarify that defaults() does not modify global defaults (@nylen)
|
||||
- [#1250](https://github.com/request/request/pull/1250) Improve documentation for pool and maxSockets options (@nylen)
|
||||
- [#1237](https://github.com/request/request/pull/1237) Documenting error handling when using streams (@vmattos)
|
||||
- [#1244](https://github.com/request/request/pull/1244) Finalize changelog command (@nylen)
|
||||
- [#1241](https://github.com/request/request/pull/1241) Fix typo (@alexanderGugel)
|
||||
- [#1223](https://github.com/request/request/pull/1223) Show latest version number instead of "upcoming" in changelog (@nylen)
|
||||
- [#1236](https://github.com/request/request/pull/1236) Document how to use custom CA in README (#1229) (@hypesystem)
|
||||
- [#1228](https://github.com/request/request/pull/1228) Support for oauth with RSA-SHA1 signing (@nylen)
|
||||
- [#1216](https://github.com/request/request/pull/1216) Made json and multipart options coexist (@nylen, @simov)
|
||||
- [#1225](https://github.com/request/request/pull/1225) Allow header white/exclusive lists in any case. (@RReverser)
|
||||
|
||||
### v2.47.0 (2014/10/26)
|
||||
- [#1222](https://github.com/request/request/pull/1222) Move from mikeal/request to request/request (@nylen)
|
||||
- [#1220](https://github.com/request/request/pull/1220) update qs dependency to 2.3.1 (@FredKSchott)
|
||||
- [#1212](https://github.com/request/request/pull/1212) Improve tests/test-timeout.js (@nylen)
|
||||
- [#1219](https://github.com/request/request/pull/1219) remove old globalAgent workaround for node 0.4 (@request)
|
||||
- [#1214](https://github.com/request/request/pull/1214) Remove cruft left over from optional dependencies (@nylen)
|
||||
- [#1215](https://github.com/request/request/pull/1215) Add proxyHeaderExclusiveList option for proxy-only headers. (@RReverser)
|
||||
- [#1211](https://github.com/request/request/pull/1211) Allow 'Host' header instead of 'host' and remember case across redirects (@nylen)
|
||||
- [#1208](https://github.com/request/request/pull/1208) Improve release script (@nylen)
|
||||
- [#1213](https://github.com/request/request/pull/1213) Support for custom cookie store (@nylen, @mitsuru)
|
||||
- [#1197](https://github.com/request/request/pull/1197) Clean up some code around setting the agent (@FredKSchott)
|
||||
- [#1209](https://github.com/request/request/pull/1209) Improve multipart form append test (@simov)
|
||||
- [#1207](https://github.com/request/request/pull/1207) Update changelog (@nylen)
|
||||
- [#1185](https://github.com/request/request/pull/1185) Stream multipart/related bodies (@simov)
|
||||
|
||||
### v2.46.0 (2014/10/23)
|
||||
- [#1198](https://github.com/request/request/pull/1198) doc for TLS/SSL protocol options (@shawnzhu)
|
||||
- [#1200](https://github.com/request/request/pull/1200) Add a Gitter chat badge to README.md (@gitter-badger)
|
||||
- [#1196](https://github.com/request/request/pull/1196) Upgrade taper test reporter to v0.3.0 (@nylen)
|
||||
- [#1199](https://github.com/request/request/pull/1199) Fix lint error: undeclared var i (@nylen)
|
||||
- [#1191](https://github.com/request/request/pull/1191) Move self.proxy decision logic out of init and into a helper (@FredKSchott)
|
||||
- [#1190](https://github.com/request/request/pull/1190) Move _buildRequest() logic back into init (@FredKSchott)
|
||||
- [#1186](https://github.com/request/request/pull/1186) Support Smarter Unix URL Scheme (@FredKSchott)
|
||||
- [#1178](https://github.com/request/request/pull/1178) update form documentation for new usage (@FredKSchott)
|
||||
- [#1180](https://github.com/request/request/pull/1180) Enable no-mixed-requires linting rule (@nylen)
|
||||
- [#1184](https://github.com/request/request/pull/1184) Don't forward authorization header across redirects to different hosts (@nylen)
|
||||
- [#1183](https://github.com/request/request/pull/1183) Correct README about pre and postamble CRLF using multipart and not mult... (@netpoetica)
|
||||
- [#1179](https://github.com/request/request/pull/1179) Lint tests directory (@nylen)
|
||||
- [#1169](https://github.com/request/request/pull/1169) add metadata for form-data file field (@dotcypress)
|
||||
- [#1173](https://github.com/request/request/pull/1173) remove optional dependencies (@seanstrom)
|
||||
- [#1165](https://github.com/request/request/pull/1165) Cleanup event listeners and remove function creation from init (@FredKSchott)
|
||||
- [#1174](https://github.com/request/request/pull/1174) update the request.cookie docs to have a valid cookie example (@seanstrom)
|
||||
- [#1168](https://github.com/request/request/pull/1168) create a detach helper and use detach helper in replace of nextTick (@seanstrom)
|
||||
- [#1171](https://github.com/request/request/pull/1171) in post can send form data and use callback (@MiroRadenovic)
|
||||
- [#1159](https://github.com/request/request/pull/1159) accept charset for x-www-form-urlencoded content-type (@seanstrom)
|
||||
- [#1157](https://github.com/request/request/pull/1157) Update README.md: body with json=true (@Rob--W)
|
||||
- [#1164](https://github.com/request/request/pull/1164) Disable tests/test-timeout.js on Travis (@nylen)
|
||||
- [#1153](https://github.com/request/request/pull/1153) Document how to run a single test (@nylen)
|
||||
- [#1144](https://github.com/request/request/pull/1144) adds documentation for the "response" event within the streaming section (@tbuchok)
|
||||
- [#1162](https://github.com/request/request/pull/1162) Update eslintrc file to no longer allow past errors (@FredKSchott)
|
||||
- [#1155](https://github.com/request/request/pull/1155) Support/use self everywhere (@seanstrom)
|
||||
- [#1161](https://github.com/request/request/pull/1161) fix no-use-before-define lint warnings (@emkay)
|
||||
- [#1156](https://github.com/request/request/pull/1156) adding curly brackets to get rid of lint errors (@emkay)
|
||||
- [#1151](https://github.com/request/request/pull/1151) Fix localAddress test on OS X (@nylen)
|
||||
- [#1145](https://github.com/request/request/pull/1145) documentation: fix outdated reference to setCookieSync old name in README (@FredKSchott)
|
||||
- [#1131](https://github.com/request/request/pull/1131) Update pool documentation (@FredKSchott)
|
||||
- [#1143](https://github.com/request/request/pull/1143) Rewrite all tests to use tape (@nylen)
|
||||
- [#1137](https://github.com/request/request/pull/1137) Add ability to specifiy querystring lib in options. (@jgrund)
|
||||
- [#1138](https://github.com/request/request/pull/1138) allow hostname and port in place of host on uri (@cappslock)
|
||||
- [#1134](https://github.com/request/request/pull/1134) Fix multiple redirects and `self.followRedirect` (@blakeembrey)
|
||||
- [#1130](https://github.com/request/request/pull/1130) documentation fix: add note about npm test for contributing (@FredKSchott)
|
||||
- [#1120](https://github.com/request/request/pull/1120) Support/refactor request setup tunnel (@seanstrom)
|
||||
- [#1129](https://github.com/request/request/pull/1129) linting fix: convert double quote strings to use single quotes (@FredKSchott)
|
||||
- [#1124](https://github.com/request/request/pull/1124) linting fix: remove unneccesary semi-colons (@FredKSchott)
|
||||
|
||||
### v2.45.0 (2014/10/06)
|
||||
- [#1128](https://github.com/request/request/pull/1128) Add test for setCookie regression (@nylen)
|
||||
- [#1127](https://github.com/request/request/pull/1127) added tests around using objects as values in a query string (@bcoe)
|
||||
- [#1103](https://github.com/request/request/pull/1103) Support/refactor request constructor (@nylen, @seanstrom)
|
||||
- [#1119](https://github.com/request/request/pull/1119) add basic linting to request library (@FredKSchott)
|
||||
- [#1121](https://github.com/request/request/pull/1121) Revert "Explicitly use sync versions of cookie functions" (@nylen)
|
||||
- [#1118](https://github.com/request/request/pull/1118) linting fix: Restructure bad empty if statement (@FredKSchott)
|
||||
- [#1117](https://github.com/request/request/pull/1117) Fix a bad check for valid URIs (@FredKSchott)
|
||||
- [#1113](https://github.com/request/request/pull/1113) linting fix: space out operators (@FredKSchott)
|
||||
- [#1116](https://github.com/request/request/pull/1116) Fix typo in `noProxyHost` definition (@FredKSchott)
|
||||
- [#1114](https://github.com/request/request/pull/1114) linting fix: Added a `new` operator that was missing when creating and throwing a new error (@FredKSchott)
|
||||
- [#1096](https://github.com/request/request/pull/1096) No_proxy support (@samcday)
|
||||
- [#1107](https://github.com/request/request/pull/1107) linting-fix: remove unused variables (@FredKSchott)
|
||||
- [#1112](https://github.com/request/request/pull/1112) linting fix: Make return values consistent and more straitforward (@FredKSchott)
|
||||
- [#1111](https://github.com/request/request/pull/1111) linting fix: authPieces was getting redeclared (@FredKSchott)
|
||||
- [#1105](https://github.com/request/request/pull/1105) Use strict mode in request (@FredKSchott)
|
||||
- [#1110](https://github.com/request/request/pull/1110) linting fix: replace lazy '==' with more strict '===' (@FredKSchott)
|
||||
- [#1109](https://github.com/request/request/pull/1109) linting fix: remove function call from if-else conditional statement (@FredKSchott)
|
||||
- [#1102](https://github.com/request/request/pull/1102) Fix to allow setting a `requester` on recursive calls to `request.defaults` (@tikotzky)
|
||||
- [#1095](https://github.com/request/request/pull/1095) Tweaking engines in package.json (@pdehaan)
|
||||
- [#1082](https://github.com/request/request/pull/1082) Forward the socket event from the httpModule request (@seanstrom)
|
||||
- [#972](https://github.com/request/request/pull/972) Clarify gzip handling in the README (@kevinoid)
|
||||
- [#1089](https://github.com/request/request/pull/1089) Mention that encoding defaults to utf8, not Buffer (@stuartpb)
|
||||
- [#1088](https://github.com/request/request/pull/1088) Fix cookie example in README.md and make it more clear (@pipi32167)
|
||||
- [#1027](https://github.com/request/request/pull/1027) Add support for multipart form data in request options. (@crocket)
|
||||
- [#1076](https://github.com/request/request/pull/1076) use Request.abort() to abort the request when the request has timed-out (@seanstrom)
|
||||
- [#1068](https://github.com/request/request/pull/1068) add optional postamble required by .NET multipart requests (@netpoetica)
|
||||
|
||||
### v2.43.0 (2014/09/18)
|
||||
- [#1057](https://github.com/request/request/pull/1057) Defaults should not overwrite defined options (@davidwood)
|
||||
- [#1046](https://github.com/request/request/pull/1046) Propagate datastream errors, useful in case gzip fails. (@ZJONSSON, @Janpot)
|
||||
- [#1063](https://github.com/request/request/pull/1063) copy the input headers object #1060 (@finnp)
|
||||
- [#1031](https://github.com/request/request/pull/1031) Explicitly use sync versions of cookie functions (@ZJONSSON)
|
||||
- [#1056](https://github.com/request/request/pull/1056) Fix redirects when passing url.parse(x) as URL to convenience method (@nylen)
|
||||
|
||||
### v2.42.0 (2014/09/04)
|
||||
- [#1053](https://github.com/request/request/pull/1053) Fix #1051 Parse auth properly when using non-tunneling proxy (@isaacs)
|
||||
|
||||
### v2.41.0 (2014/09/04)
|
||||
- [#1050](https://github.com/request/request/pull/1050) Pass whitelisted headers to tunneling proxy. Organize all tunneling logic. (@isaacs, @Feldhacker)
|
||||
- [#1035](https://github.com/request/request/pull/1035) souped up nodei.co badge (@rvagg)
|
||||
- [#1048](https://github.com/request/request/pull/1048) Aws is now possible over a proxy (@steven-aerts)
|
||||
- [#1039](https://github.com/request/request/pull/1039) extract out helper functions to a helper file (@seanstrom)
|
||||
- [#1021](https://github.com/request/request/pull/1021) Support/refactor indexjs (@seanstrom)
|
||||
- [#1033](https://github.com/request/request/pull/1033) Improve and document debug options (@nylen)
|
||||
- [#1034](https://github.com/request/request/pull/1034) Fix readme headings (@nylen)
|
||||
- [#1030](https://github.com/request/request/pull/1030) Allow recursive request.defaults (@tikotzky)
|
||||
- [#1029](https://github.com/request/request/pull/1029) Fix a couple of typos (@nylen)
|
||||
- [#675](https://github.com/request/request/pull/675) Checking for SSL fault on connection before reading SSL properties (@VRMink)
|
||||
- [#989](https://github.com/request/request/pull/989) Added allowRedirect function. Should return true if redirect is allowed or false otherwise (@doronin)
|
||||
- [#1025](https://github.com/request/request/pull/1025) [fixes #1023] Set self._ended to true once response has ended (@mridgway)
|
||||
- [#1020](https://github.com/request/request/pull/1020) Add back removed debug metadata (@FredKSchott)
|
||||
- [#1008](https://github.com/request/request/pull/1008) Moving to module instead of cutomer buffer concatenation. (@mikeal)
|
||||
- [#770](https://github.com/request/request/pull/770) Added dependency badge for README file; (@timgluz, @mafintosh, @lalitkapoor, @stash, @bobyrizov)
|
||||
- [#1016](https://github.com/request/request/pull/1016) toJSON no longer results in an infinite loop, returns simple objects (@FredKSchott)
|
||||
- [#1018](https://github.com/request/request/pull/1018) Remove pre-0.4.4 HTTPS fix (@mmalecki)
|
||||
- [#1006](https://github.com/request/request/pull/1006) Migrate to caseless, fixes #1001 (@mikeal)
|
||||
- [#995](https://github.com/request/request/pull/995) Fix parsing array of objects (@sjonnet19)
|
||||
- [#999](https://github.com/request/request/pull/999) Fix fallback for browserify for optional modules. (@eiriksm)
|
||||
- [#996](https://github.com/request/request/pull/996) Wrong oauth signature when multiple same param keys exist [updated] (@bengl, @hyjin)
|
||||
|
||||
### v2.40.0 (2014/08/06)
|
||||
- [#992](https://github.com/request/request/pull/992) Fix security vulnerability. Update qs (@poeticninja)
|
||||
- [#988](https://github.com/request/request/pull/988) “--” -> “—” (@upisfree)
|
||||
- [#987](https://github.com/request/request/pull/987) Show optional modules as being loaded by the module that reqeusted them (@iarna)
|
||||
|
||||
### v2.39.0 (2014/07/24)
|
||||
- [#976](https://github.com/request/request/pull/976) Update README.md (@pvoznenko)
|
||||
|
||||
### v2.38.0 (2014/07/22)
|
||||
- [#952](https://github.com/request/request/pull/952) Adding support to client certificate with proxy use case (@ofirshaked)
|
||||
- [#884](https://github.com/request/request/pull/884) Documented tough-cookie installation. (@wbyoung)
|
||||
- [#935](https://github.com/request/request/pull/935) Correct repository url (@fritx)
|
||||
- [#963](https://github.com/request/request/pull/963) Update changelog (@nylen)
|
||||
- [#960](https://github.com/request/request/pull/960) Support gzip with encoding on node pre-v0.9.4 (@kevinoid)
|
||||
- [#953](https://github.com/request/request/pull/953) Add async Content-Length computation when using form-data (@LoicMahieu)
|
||||
- [#844](https://github.com/request/request/pull/844) Add support for HTTP[S]_PROXY environment variables. Fixes #595. (@jvmccarthy)
|
||||
- [#946](https://github.com/request/request/pull/946) defaults: merge headers (@aj0strow)
|
||||
|
||||
### v2.37.0 (2014/07/07)
|
||||
- [#957](https://github.com/request/request/pull/957) Silence EventEmitter memory leak warning #311 (@watson)
|
||||
- [#955](https://github.com/request/request/pull/955) check for content-length header before setting it in nextTick (@camilleanne)
|
||||
- [#951](https://github.com/request/request/pull/951) Add support for gzip content decoding (@kevinoid)
|
||||
- [#949](https://github.com/request/request/pull/949) Manually enter querystring in form option (@charlespwd)
|
||||
- [#944](https://github.com/request/request/pull/944) Make request work with browserify (@eiriksm)
|
||||
- [#943](https://github.com/request/request/pull/943) New mime module (@eiriksm)
|
||||
- [#927](https://github.com/request/request/pull/927) Bump version of hawk dep. (@samccone)
|
||||
- [#907](https://github.com/request/request/pull/907) append secureOptions to poolKey (@medovob)
|
||||
|
||||
### v2.35.0 (2014/05/17)
|
||||
- [#901](https://github.com/request/request/pull/901) Fixes #555 (@pigulla)
|
||||
- [#897](https://github.com/request/request/pull/897) merge with default options (@vohof)
|
||||
- [#891](https://github.com/request/request/pull/891) fixes 857 - options object is mutated by calling request (@lalitkapoor)
|
||||
- [#869](https://github.com/request/request/pull/869) Pipefilter test (@tgohn)
|
||||
- [#866](https://github.com/request/request/pull/866) Fix typo (@dandv)
|
||||
- [#861](https://github.com/request/request/pull/861) Add support for RFC 6750 Bearer Tokens (@phedny)
|
||||
- [#809](https://github.com/request/request/pull/809) upgrade tunnel-proxy to 0.4.0 (@ksato9700)
|
||||
- [#850](https://github.com/request/request/pull/850) Fix word consistency in readme (@0xNobody)
|
||||
- [#810](https://github.com/request/request/pull/810) add some exposition to mpu example in README.md (@mikermcneil)
|
||||
- [#840](https://github.com/request/request/pull/840) improve error reporting for invalid protocols (@FND)
|
||||
- [#821](https://github.com/request/request/pull/821) added secureOptions back (@nw)
|
||||
- [#815](https://github.com/request/request/pull/815) Create changelog based on pull requests (@lalitkapoor)
|
||||
|
||||
### v2.34.0 (2014/02/18)
|
||||
- [#516](https://github.com/request/request/pull/516) UNIX Socket URL Support (@lyuzashi)
|
||||
- [#801](https://github.com/request/request/pull/801) 794 ignore cookie parsing and domain errors (@lalitkapoor)
|
||||
- [#802](https://github.com/request/request/pull/802) Added the Apache license to the package.json. (@keskival)
|
||||
- [#793](https://github.com/request/request/pull/793) Adds content-length calculation when submitting forms using form-data li... (@Juul)
|
||||
- [#785](https://github.com/request/request/pull/785) Provide ability to override content-type when `json` option used (@vvo)
|
||||
- [#781](https://github.com/request/request/pull/781) simpler isReadStream function (@joaojeronimo)
|
||||
|
||||
### v2.32.0 (2014/01/16)
|
||||
- [#767](https://github.com/request/request/pull/767) Use tough-cookie CookieJar sync API (@stash)
|
||||
- [#764](https://github.com/request/request/pull/764) Case-insensitive authentication scheme (@bobyrizov)
|
||||
- [#763](https://github.com/request/request/pull/763) Upgrade tough-cookie to 0.10.0 (@stash)
|
||||
- [#744](https://github.com/request/request/pull/744) Use Cookie.parse (@lalitkapoor)
|
||||
- [#757](https://github.com/request/request/pull/757) require aws-sign2 (@mafintosh)
|
||||
|
||||
### v2.31.0 (2014/01/08)
|
||||
- [#645](https://github.com/request/request/pull/645) update twitter api url to v1.1 (@mick)
|
||||
- [#746](https://github.com/request/request/pull/746) README: Markdown code highlight (@weakish)
|
||||
- [#745](https://github.com/request/request/pull/745) updating setCookie example to make it clear that the callback is required (@emkay)
|
||||
- [#742](https://github.com/request/request/pull/742) Add note about JSON output body type (@iansltx)
|
||||
- [#741](https://github.com/request/request/pull/741) README example is using old cookie jar api (@emkay)
|
||||
- [#736](https://github.com/request/request/pull/736) Fix callback arguments documentation (@mmalecki)
|
||||
|
||||
### v2.30.0 (2013/12/13)
|
||||
- [#732](https://github.com/request/request/pull/732) JSHINT: Creating global 'for' variable. Should be 'for (var ...'. (@Fritz-Lium)
|
||||
- [#730](https://github.com/request/request/pull/730) better HTTP DIGEST support (@dai-shi)
|
||||
- [#728](https://github.com/request/request/pull/728) Fix TypeError when calling request.cookie (@scarletmeow)
|
||||
|
||||
### v2.29.0 (2013/12/06)
|
||||
- [#727](https://github.com/request/request/pull/727) fix requester bug (@jchris)
|
||||
|
||||
### v2.28.0 (2013/12/04)
|
||||
- [#724](https://github.com/request/request/pull/724) README.md: add custom HTTP Headers example. (@tcort)
|
||||
- [#719](https://github.com/request/request/pull/719) Made a comment gender neutral. (@unsetbit)
|
||||
- [#715](https://github.com/request/request/pull/715) Request.multipart no longer crashes when header 'Content-type' present (@pastaclub)
|
||||
- [#710](https://github.com/request/request/pull/710) Fixing listing in callback part of docs. (@lukasz-zak)
|
||||
- [#696](https://github.com/request/request/pull/696) Edited README.md for formatting and clarity of phrasing (@Zearin)
|
||||
- [#694](https://github.com/request/request/pull/694) Typo in README (@VRMink)
|
||||
- [#690](https://github.com/request/request/pull/690) Handle blank password in basic auth. (@diversario)
|
||||
- [#682](https://github.com/request/request/pull/682) Optional dependencies (@Turbo87)
|
||||
- [#683](https://github.com/request/request/pull/683) Travis CI support (@Turbo87)
|
||||
- [#674](https://github.com/request/request/pull/674) change cookie module,to tough-cookie.please check it . (@sxyizhiren)
|
||||
- [#666](https://github.com/request/request/pull/666) make `ciphers` and `secureProtocol` to work in https request (@richarddong)
|
||||
- [#656](https://github.com/request/request/pull/656) Test case for #304. (@diversario)
|
||||
- [#662](https://github.com/request/request/pull/662) option.tunnel to explicitly disable tunneling (@seanmonstar)
|
||||
- [#659](https://github.com/request/request/pull/659) fix failure when running with NODE_DEBUG=request, and a test for that (@jrgm)
|
||||
- [#630](https://github.com/request/request/pull/630) Send random cnonce for HTTP Digest requests (@wprl)
|
||||
|
||||
### v2.27.0 (2013/08/15)
|
||||
- [#619](https://github.com/request/request/pull/619) decouple things a bit (@joaojeronimo)
|
||||
|
||||
### v2.26.0 (2013/08/07)
|
||||
- [#613](https://github.com/request/request/pull/613) Fixes #583, moved initialization of self.uri.pathname (@lexander)
|
||||
- [#605](https://github.com/request/request/pull/605) Only include ":" + pass in Basic Auth if it's defined (fixes #602) (@bendrucker)
|
||||
|
||||
### v2.24.0 (2013/07/23)
|
||||
- [#596](https://github.com/request/request/pull/596) Global agent is being used when pool is specified (@Cauldrath)
|
||||
- [#594](https://github.com/request/request/pull/594) Emit complete event when there is no callback (@RomainLK)
|
||||
- [#601](https://github.com/request/request/pull/601) Fixed a small typo (@michalstanko)
|
||||
|
||||
### v2.23.0 (2013/07/23)
|
||||
- [#589](https://github.com/request/request/pull/589) Prevent setting headers after they are sent (@geek)
|
||||
- [#587](https://github.com/request/request/pull/587) Global cookie jar disabled by default (@threepointone)
|
||||
|
||||
### v2.22.0 (2013/07/05)
|
||||
- [#544](https://github.com/request/request/pull/544) Update http-signature version. (@davidlehn)
|
||||
- [#581](https://github.com/request/request/pull/581) Fix spelling of "ignoring." (@bigeasy)
|
||||
- [#568](https://github.com/request/request/pull/568) use agentOptions to create agent when specified in request (@SamPlacette)
|
||||
- [#564](https://github.com/request/request/pull/564) Fix redirections (@criloz)
|
||||
- [#541](https://github.com/request/request/pull/541) The exported request function doesn't have an auth method (@tschaub)
|
||||
- [#542](https://github.com/request/request/pull/542) Expose Request class (@regality)
|
||||
|
||||
### v2.21.0 (2013/04/30)
|
||||
- [#536](https://github.com/request/request/pull/536) Allow explicitly empty user field for basic authentication. (@mikeando)
|
||||
- [#532](https://github.com/request/request/pull/532) fix typo (@fredericosilva)
|
||||
- [#497](https://github.com/request/request/pull/497) Added redirect event (@Cauldrath)
|
||||
- [#503](https://github.com/request/request/pull/503) Fix basic auth for passwords that contain colons (@tonistiigi)
|
||||
- [#521](https://github.com/request/request/pull/521) Improving test-localAddress.js (@noway421)
|
||||
- [#529](https://github.com/request/request/pull/529) dependencies versions bump (@jodaka)
|
||||
|
||||
### v2.17.0 (2013/04/22)
|
||||
- [#523](https://github.com/request/request/pull/523) Updating dependencies (@noway421)
|
||||
- [#520](https://github.com/request/request/pull/520) Fixing test-tunnel.js (@noway421)
|
||||
- [#519](https://github.com/request/request/pull/519) Update internal path state on post-creation QS changes (@jblebrun)
|
||||
- [#510](https://github.com/request/request/pull/510) Add HTTP Signature support. (@davidlehn)
|
||||
- [#502](https://github.com/request/request/pull/502) Fix POST (and probably other) requests that are retried after 401 Unauthorized (@nylen)
|
||||
- [#508](https://github.com/request/request/pull/508) Honor the .strictSSL option when using proxies (tunnel-agent) (@jhs)
|
||||
- [#512](https://github.com/request/request/pull/512) Make password optional to support the format: http://username@hostname/ (@pajato1)
|
||||
- [#513](https://github.com/request/request/pull/513) add 'localAddress' support (@yyfrankyy)
|
||||
- [#498](https://github.com/request/request/pull/498) Moving response emit above setHeaders on destination streams (@kenperkins)
|
||||
- [#490](https://github.com/request/request/pull/490) Empty response body (3-rd argument) must be passed to callback as an empty string (@Olegas)
|
||||
- [#479](https://github.com/request/request/pull/479) Changing so if Accept header is explicitly set, sending json does not ov... (@RoryH)
|
||||
- [#475](https://github.com/request/request/pull/475) Use `unescape` from `querystring` (@shimaore)
|
||||
- [#473](https://github.com/request/request/pull/473) V0.10 compat (@isaacs)
|
||||
- [#471](https://github.com/request/request/pull/471) Using querystring library from visionmedia (@kbackowski)
|
||||
- [#461](https://github.com/request/request/pull/461) Strip the UTF8 BOM from a UTF encoded response (@kppullin)
|
||||
- [#460](https://github.com/request/request/pull/460) hawk 0.10.0 (@hueniverse)
|
||||
- [#462](https://github.com/request/request/pull/462) if query params are empty, then request path shouldn't end with a '?' (merges cleanly now) (@jaipandya)
|
||||
- [#456](https://github.com/request/request/pull/456) hawk 0.9.0 (@hueniverse)
|
||||
- [#429](https://github.com/request/request/pull/429) Copy options before adding callback. (@nrn, @nfriedly, @youurayy, @jplock, @kapetan, @landeiro, @othiym23, @mmalecki)
|
||||
- [#454](https://github.com/request/request/pull/454) Destroy the response if present when destroying the request (clean merge) (@mafintosh)
|
||||
- [#310](https://github.com/request/request/pull/310) Twitter Oauth Stuff Out of Date; Now Updated (@joemccann, @isaacs, @mscdex)
|
||||
- [#413](https://github.com/request/request/pull/413) rename googledoodle.png to .jpg (@nfriedly, @youurayy, @jplock, @kapetan, @landeiro, @othiym23, @mmalecki)
|
||||
- [#448](https://github.com/request/request/pull/448) Convenience method for PATCH (@mloar)
|
||||
- [#444](https://github.com/request/request/pull/444) protect against double callbacks on error path (@spollack)
|
||||
- [#433](https://github.com/request/request/pull/433) Added support for HTTPS cert & key (@mmalecki)
|
||||
- [#430](https://github.com/request/request/pull/430) Respect specified {Host,host} headers, not just {host} (@andrewschaaf)
|
||||
- [#415](https://github.com/request/request/pull/415) Fixed a typo. (@jerem)
|
||||
- [#338](https://github.com/request/request/pull/338) Add more auth options, including digest support (@nylen)
|
||||
- [#403](https://github.com/request/request/pull/403) Optimize environment lookup to happen once only (@mmalecki)
|
||||
- [#398](https://github.com/request/request/pull/398) Add more reporting to tests (@mmalecki)
|
||||
- [#388](https://github.com/request/request/pull/388) Ensure "safe" toJSON doesn't break EventEmitters (@othiym23)
|
||||
- [#381](https://github.com/request/request/pull/381) Resolving "Invalid signature. Expected signature base string: " (@landeiro)
|
||||
- [#380](https://github.com/request/request/pull/380) Fixes missing host header on retried request when using forever agent (@mac-)
|
||||
- [#376](https://github.com/request/request/pull/376) Headers lost on redirect (@kapetan)
|
||||
- [#375](https://github.com/request/request/pull/375) Fix for missing oauth_timestamp parameter (@jplock)
|
||||
- [#374](https://github.com/request/request/pull/374) Correct Host header for proxy tunnel CONNECT (@youurayy)
|
||||
- [#370](https://github.com/request/request/pull/370) Twitter reverse auth uses x_auth_mode not x_auth_type (@drudge)
|
||||
- [#369](https://github.com/request/request/pull/369) Don't remove x_auth_mode for Twitter reverse auth (@drudge)
|
||||
- [#344](https://github.com/request/request/pull/344) Make AWS auth signing find headers correctly (@nlf)
|
||||
- [#363](https://github.com/request/request/pull/363) rfc3986 on base_uri, now passes tests (@jeffmarshall)
|
||||
- [#362](https://github.com/request/request/pull/362) Running `rfc3986` on `base_uri` in `oauth.hmacsign` instead of just `encodeURIComponent` (@jeffmarshall)
|
||||
- [#361](https://github.com/request/request/pull/361) Don't create a Content-Length header if we already have it set (@danjenkins)
|
||||
- [#360](https://github.com/request/request/pull/360) Delete self._form along with everything else on redirect (@jgautier)
|
||||
- [#355](https://github.com/request/request/pull/355) stop sending erroneous headers on redirected requests (@azylman)
|
||||
- [#332](https://github.com/request/request/pull/332) Fix #296 - Only set Content-Type if body exists (@Marsup)
|
||||
- [#343](https://github.com/request/request/pull/343) Allow AWS to work in more situations, added a note in the README on its usage (@nlf)
|
||||
- [#320](https://github.com/request/request/pull/320) request.defaults() doesn't need to wrap jar() (@StuartHarris)
|
||||
- [#322](https://github.com/request/request/pull/322) Fix + test for piped into request bumped into redirect. #321 (@alexindigo)
|
||||
- [#326](https://github.com/request/request/pull/326) Do not try to remove listener from an undefined connection (@strk)
|
||||
- [#318](https://github.com/request/request/pull/318) Pass servername to tunneling secure socket creation (@isaacs)
|
||||
- [#317](https://github.com/request/request/pull/317) Workaround for #313 (@isaacs)
|
||||
- [#293](https://github.com/request/request/pull/293) Allow parser errors to bubble up to request (@mscdex)
|
||||
- [#290](https://github.com/request/request/pull/290) A test for #289 (@isaacs)
|
||||
- [#280](https://github.com/request/request/pull/280) Like in node.js print options if NODE_DEBUG contains the word request (@Filirom1)
|
||||
- [#207](https://github.com/request/request/pull/207) Fix #206 Change HTTP/HTTPS agent when redirecting between protocols (@isaacs)
|
||||
- [#214](https://github.com/request/request/pull/214) documenting additional behavior of json option (@jphaas)
|
||||
- [#272](https://github.com/request/request/pull/272) Boundary begins with CRLF? (@elspoono, @timshadel, @naholyr, @nanodocumet, @TehShrike)
|
||||
- [#284](https://github.com/request/request/pull/284) Remove stray `console.log()` call in multipart generator. (@bcherry)
|
||||
- [#241](https://github.com/request/request/pull/241) Composability updates suggested by issue #239 (@polotek)
|
||||
- [#282](https://github.com/request/request/pull/282) OAuth Authorization header contains non-"oauth_" parameters (@jplock)
|
||||
- [#279](https://github.com/request/request/pull/279) fix tests with boundary by injecting boundry from header (@benatkin)
|
||||
- [#273](https://github.com/request/request/pull/273) Pipe back pressure issue (@mafintosh)
|
||||
- [#268](https://github.com/request/request/pull/268) I'm not OCD seriously (@TehShrike)
|
||||
- [#263](https://github.com/request/request/pull/263) Bug in OAuth key generation for sha1 (@nanodocumet)
|
||||
- [#265](https://github.com/request/request/pull/265) uncaughtException when redirected to invalid URI (@naholyr)
|
||||
- [#262](https://github.com/request/request/pull/262) JSON test should check for equality (@timshadel)
|
||||
- [#261](https://github.com/request/request/pull/261) Setting 'pool' to 'false' does NOT disable Agent pooling (@timshadel)
|
||||
- [#249](https://github.com/request/request/pull/249) Fix for the fix of your (closed) issue #89 where self.headers[content-length] is set to 0 for all methods (@sethbridges, @polotek, @zephrax, @jeromegn)
|
||||
- [#255](https://github.com/request/request/pull/255) multipart allow body === '' ( the empty string ) (@Filirom1)
|
||||
- [#260](https://github.com/request/request/pull/260) fixed just another leak of 'i' (@sreuter)
|
||||
- [#246](https://github.com/request/request/pull/246) Fixing the set-cookie header (@jeromegn)
|
||||
- [#243](https://github.com/request/request/pull/243) Dynamic boundary (@zephrax)
|
||||
- [#240](https://github.com/request/request/pull/240) don't error when null is passed for options (@polotek)
|
||||
- [#211](https://github.com/request/request/pull/211) Replace all occurrences of special chars in RFC3986 (@chriso)
|
||||
- [#224](https://github.com/request/request/pull/224) Multipart content-type change (@janjongboom)
|
||||
- [#217](https://github.com/request/request/pull/217) need to use Authorization (titlecase) header with Tumblr OAuth (@visnup)
|
||||
- [#203](https://github.com/request/request/pull/203) Fix cookie and redirect bugs and add auth support for HTTPS tunnel (@milewise)
|
||||
- [#199](https://github.com/request/request/pull/199) Tunnel (@isaacs)
|
||||
- [#198](https://github.com/request/request/pull/198) Bugfix on forever usage of util.inherits (@isaacs)
|
||||
- [#197](https://github.com/request/request/pull/197) Make ForeverAgent work with HTTPS (@isaacs)
|
||||
- [#193](https://github.com/request/request/pull/193) Fixes GH-119 (@goatslacker)
|
||||
- [#188](https://github.com/request/request/pull/188) Add abort support to the returned request (@itay)
|
||||
- [#176](https://github.com/request/request/pull/176) Querystring option (@csainty)
|
||||
- [#182](https://github.com/request/request/pull/182) Fix request.defaults to support (uri, options, callback) api (@twilson63)
|
||||
- [#180](https://github.com/request/request/pull/180) Modified the post, put, head and del shortcuts to support uri optional param (@twilson63)
|
||||
- [#179](https://github.com/request/request/pull/179) fix to add opts in .pipe(stream, opts) (@substack)
|
||||
- [#177](https://github.com/request/request/pull/177) Issue #173 Support uri as first and optional config as second argument (@twilson63)
|
||||
- [#170](https://github.com/request/request/pull/170) can't create a cookie in a wrapped request (defaults) (@fabianonunes)
|
||||
- [#168](https://github.com/request/request/pull/168) Picking off an EasyFix by adding some missing mimetypes. (@serby)
|
||||
- [#161](https://github.com/request/request/pull/161) Fix cookie jar/headers.cookie collision (#125) (@papandreou)
|
||||
- [#162](https://github.com/request/request/pull/162) Fix issue #159 (@dpetukhov)
|
||||
- [#90](https://github.com/request/request/pull/90) add option followAllRedirects to follow post/put redirects (@jroes)
|
||||
- [#148](https://github.com/request/request/pull/148) Retry Agent (@thejh)
|
||||
- [#146](https://github.com/request/request/pull/146) Multipart should respect content-type if previously set (@apeace)
|
||||
- [#144](https://github.com/request/request/pull/144) added "form" option to readme (@petejkim)
|
||||
- [#133](https://github.com/request/request/pull/133) Fixed cookies parsing (@afanasy)
|
||||
- [#135](https://github.com/request/request/pull/135) host vs hostname (@iangreenleaf)
|
||||
- [#132](https://github.com/request/request/pull/132) return the body as a Buffer when encoding is set to null (@jahewson)
|
||||
- [#112](https://github.com/request/request/pull/112) Support using a custom http-like module (@jhs)
|
||||
- [#104](https://github.com/request/request/pull/104) Cookie handling contains bugs (@janjongboom)
|
||||
- [#121](https://github.com/request/request/pull/121) Another patch for cookie handling regression (@jhurliman)
|
||||
- [#117](https://github.com/request/request/pull/117) Remove the global `i` (@3rd-Eden)
|
||||
- [#110](https://github.com/request/request/pull/110) Update to Iris Couch URL (@jhs)
|
||||
- [#86](https://github.com/request/request/pull/86) Can't post binary to multipart requests (@developmentseed)
|
||||
- [#105](https://github.com/request/request/pull/105) added test for proxy option. (@dominictarr)
|
||||
- [#102](https://github.com/request/request/pull/102) Implemented cookies - closes issue 82: https://github.com/mikeal/request/issues/82 (@alessioalex)
|
||||
- [#97](https://github.com/request/request/pull/97) Typo in previous pull causes TypeError in non-0.5.11 versions (@isaacs)
|
||||
- [#96](https://github.com/request/request/pull/96) Authless parsed url host support (@isaacs)
|
||||
- [#81](https://github.com/request/request/pull/81) Enhance redirect handling (@danmactough)
|
||||
- [#78](https://github.com/request/request/pull/78) Don't try to do strictSSL for non-ssl connections (@isaacs)
|
||||
- [#76](https://github.com/request/request/pull/76) Bug when a request fails and a timeout is set (@Marsup)
|
||||
- [#70](https://github.com/request/request/pull/70) add test script to package.json (@isaacs, @aheckmann)
|
||||
- [#73](https://github.com/request/request/pull/73) Fix #71 Respect the strictSSL flag (@isaacs)
|
||||
- [#69](https://github.com/request/request/pull/69) Flatten chunked requests properly (@isaacs)
|
||||
- [#67](https://github.com/request/request/pull/67) fixed global variable leaks (@aheckmann)
|
||||
- [#66](https://github.com/request/request/pull/66) Do not overwrite established content-type headers for read stream deliver (@voodootikigod)
|
||||
- [#53](https://github.com/request/request/pull/53) Parse json: Issue #51 (@benatkin)
|
||||
- [#45](https://github.com/request/request/pull/45) Added timeout option (@mbrevoort)
|
||||
- [#35](https://github.com/request/request/pull/35) The "end" event isn't emitted for some responses (@voxpelli)
|
||||
- [#31](https://github.com/request/request/pull/31) Error on piping a request to a destination (@tobowers)
|
||||
44
node_modules/twit/node_modules/request/CONTRIBUTING.md
generated
vendored
Normal file
44
node_modules/twit/node_modules/request/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# This is an OPEN Open Source Project
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
## What?
|
||||
|
||||
Individuals making significant and valuable contributions are given
|
||||
commit-access to the project to contribute as they see fit. This project is
|
||||
more like an open wiki than a standard guarded open source project.
|
||||
|
||||
## Rules
|
||||
|
||||
There are a few basic ground-rules for contributors:
|
||||
|
||||
1. **No `--force` pushes** or modifying the Git history in any way.
|
||||
1. **Non-master branches** ought to be used for ongoing work.
|
||||
1. **External API changes and significant modifications** ought to be subject
|
||||
to an **internal pull-request** to solicit feedback from other contributors.
|
||||
1. Internal pull-requests to solicit feedback are *encouraged* for any other
|
||||
non-trivial contribution but left to the discretion of the contributor.
|
||||
1. For significant changes wait a full 24 hours before merging so that active
|
||||
contributors who are distributed throughout the world have a chance to weigh
|
||||
in.
|
||||
1. Contributors should attempt to adhere to the prevailing code-style.
|
||||
1. Run `npm test` locally before submitting your PR, to catch any easy to miss
|
||||
style & testing issues. To diagnose test failures, there are two ways to
|
||||
run a single test file:
|
||||
- `node_modules/.bin/taper tests/test-file.js` - run using the default
|
||||
[`taper`](https://github.com/nylen/taper) test reporter.
|
||||
- `node tests/test-file.js` - view the raw
|
||||
[tap](https://testanything.org/) output.
|
||||
|
||||
|
||||
## Releases
|
||||
|
||||
Declaring formal releases remains the prerogative of the project maintainer.
|
||||
|
||||
## Changes to this arrangement
|
||||
|
||||
This is an experiment and feedback is welcome! This document may also be
|
||||
subject to pull-requests or changes by contributors where you believe you have
|
||||
something valuable to add or change.
|
||||
|
||||
-----------------------------------------
|
||||
55
node_modules/twit/node_modules/request/LICENSE
generated
vendored
Normal file
55
node_modules/twit/node_modules/request/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
Apache License
|
||||
|
||||
Version 2.0, January 2004
|
||||
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
1059
node_modules/twit/node_modules/request/README.md
generated
vendored
Normal file
1059
node_modules/twit/node_modules/request/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
36
node_modules/twit/node_modules/request/disabled.appveyor.yml
generated
vendored
Normal file
36
node_modules/twit/node_modules/request/disabled.appveyor.yml
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
|
||||
# Fix line endings in Windows. (runs before repo cloning)
|
||||
init:
|
||||
- git config --global core.autocrlf input
|
||||
|
||||
# Test against these versions of Node.js.
|
||||
environment:
|
||||
matrix:
|
||||
- nodejs_version: "0.10"
|
||||
- nodejs_version: "0.8"
|
||||
- nodejs_version: "0.11"
|
||||
|
||||
# Allow failing jobs for bleeding-edge Node.js versions.
|
||||
matrix:
|
||||
allow_failures:
|
||||
- nodejs_version: "0.11"
|
||||
|
||||
# Install scripts. (runs after repo cloning)
|
||||
install:
|
||||
# Get the latest stable version of Node 0.STABLE.latest
|
||||
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
|
||||
# Typical npm stuff.
|
||||
- npm install
|
||||
|
||||
# Post-install test scripts.
|
||||
test_script:
|
||||
# Output useful info for debugging.
|
||||
- ps: "npm test # PowerShell" # Pass comment to PS for easier debugging
|
||||
- cmd: npm test
|
||||
|
||||
# Don't actually build.
|
||||
build: off
|
||||
|
||||
# Set build version format here instead of in the admin panel.
|
||||
version: "{build}"
|
||||
115
node_modules/twit/node_modules/request/examples/README.md
generated
vendored
Normal file
115
node_modules/twit/node_modules/request/examples/README.md
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
|
||||
# Authentication
|
||||
|
||||
## OAuth
|
||||
|
||||
### OAuth1.0 Refresh Token
|
||||
|
||||
- http://oauth.googlecode.com/svn/spec/ext/session/1.0/drafts/1/spec.html#anchor4
|
||||
- https://developer.yahoo.com/oauth/guide/oauth-refreshaccesstoken.html
|
||||
|
||||
```js
|
||||
request.post('https://api.login.yahoo.com/oauth/v2/get_token', {
|
||||
oauth: {
|
||||
consumer_key: '...',
|
||||
consumer_secret: '...',
|
||||
token: '...',
|
||||
token_secret: '...',
|
||||
session_handle: '...'
|
||||
}
|
||||
}, function (err, res, body) {
|
||||
var result = require('querystring').parse(body)
|
||||
// assert.equal(typeof result, 'object')
|
||||
})
|
||||
```
|
||||
|
||||
### OAuth2 Refresh Token
|
||||
|
||||
- https://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-6
|
||||
|
||||
```js
|
||||
request.post('https://accounts.google.com/o/oauth2/token', {
|
||||
form: {
|
||||
grant_type: 'refresh_token',
|
||||
client_id: '...',
|
||||
client_secret: '...',
|
||||
refresh_token: '...'
|
||||
},
|
||||
json: true
|
||||
}, function (err, res, body) {
|
||||
// assert.equal(typeof body, 'object')
|
||||
})
|
||||
```
|
||||
|
||||
# Multipart
|
||||
|
||||
## multipart/form-data
|
||||
|
||||
### Flickr Image Upload
|
||||
|
||||
- https://www.flickr.com/services/api/upload.api.html
|
||||
|
||||
```js
|
||||
request.post('https://up.flickr.com/services/upload', {
|
||||
oauth: {
|
||||
consumer_key: '...',
|
||||
consumer_secret: '...',
|
||||
token: '...',
|
||||
token_secret: '...'
|
||||
},
|
||||
// all meta data should be included here for proper signing
|
||||
qs: {
|
||||
title: 'My cat is awesome',
|
||||
description: 'Sent on ' + new Date(),
|
||||
is_public: 1
|
||||
},
|
||||
// again the same meta data + the actual photo
|
||||
formData: {
|
||||
title: 'My cat is awesome',
|
||||
description: 'Sent on ' + new Date(),
|
||||
is_public: 1,
|
||||
photo:fs.createReadStream('cat.png')
|
||||
},
|
||||
json: true
|
||||
}, function (err, res, body) {
|
||||
// assert.equal(typeof body, 'object')
|
||||
})
|
||||
```
|
||||
|
||||
# Streams
|
||||
|
||||
## `POST` data
|
||||
|
||||
Use Request as a Writable stream to easily `POST` Readable streams (like files, other HTTP requests, or otherwise).
|
||||
|
||||
TL;DR: Pipe a Readable Stream onto Request via:
|
||||
|
||||
```
|
||||
READABLE.pipe(request.post(URL));
|
||||
```
|
||||
|
||||
A more detailed example:
|
||||
|
||||
```js
|
||||
var fs = require('fs')
|
||||
, path = require('path')
|
||||
, http = require('http')
|
||||
, request = require('request')
|
||||
, TMP_FILE_PATH = path.join(path.sep, 'tmp', 'foo')
|
||||
;
|
||||
|
||||
// write a temporary file:
|
||||
fs.writeFileSync(TMP_FILE_PATH, 'foo bar baz quk\n');
|
||||
|
||||
http.createServer(function(req, res) {
|
||||
console.log('the server is receiving data!\n');
|
||||
req
|
||||
.on('end', res.end.bind(res))
|
||||
.pipe(process.stdout)
|
||||
;
|
||||
}).listen(3000).unref();
|
||||
|
||||
fs.createReadStream(TMP_FILE_PATH)
|
||||
.pipe(request.post('http://127.0.0.1:3000'))
|
||||
;
|
||||
```
|
||||
152
node_modules/twit/node_modules/request/index.js
generated
vendored
Executable file
152
node_modules/twit/node_modules/request/index.js
generated
vendored
Executable file
@@ -0,0 +1,152 @@
|
||||
// Copyright 2010-2012 Mikeal Rogers
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
'use strict'
|
||||
|
||||
var extend = require('extend')
|
||||
, cookies = require('./lib/cookies')
|
||||
, helpers = require('./lib/helpers')
|
||||
|
||||
var isFunction = helpers.isFunction
|
||||
, paramsHaveRequestBody = helpers.paramsHaveRequestBody
|
||||
|
||||
|
||||
// organize params for patch, post, put, head, del
|
||||
function initParams(uri, options, callback) {
|
||||
if (typeof options === 'function') {
|
||||
callback = options
|
||||
}
|
||||
|
||||
var params = {}
|
||||
if (typeof options === 'object') {
|
||||
extend(params, options, {uri: uri})
|
||||
} else if (typeof uri === 'string') {
|
||||
extend(params, {uri: uri})
|
||||
} else {
|
||||
extend(params, uri)
|
||||
}
|
||||
|
||||
params.callback = callback
|
||||
return params
|
||||
}
|
||||
|
||||
function request (uri, options, callback) {
|
||||
if (typeof uri === 'undefined') {
|
||||
throw new Error('undefined is not a valid uri or options object.')
|
||||
}
|
||||
|
||||
var params = initParams(uri, options, callback)
|
||||
|
||||
if (params.method === 'HEAD' && paramsHaveRequestBody(params)) {
|
||||
throw new Error('HTTP HEAD requests MUST NOT include a request body.')
|
||||
}
|
||||
|
||||
return new request.Request(params)
|
||||
}
|
||||
|
||||
function verbFunc (verb) {
|
||||
var method = verb === 'del' ? 'DELETE' : verb.toUpperCase()
|
||||
return function (uri, options, callback) {
|
||||
var params = initParams(uri, options, callback)
|
||||
params.method = method
|
||||
return request(params, params.callback)
|
||||
}
|
||||
}
|
||||
|
||||
// define like this to please codeintel/intellisense IDEs
|
||||
request.get = verbFunc('get')
|
||||
request.head = verbFunc('head')
|
||||
request.post = verbFunc('post')
|
||||
request.put = verbFunc('put')
|
||||
request.patch = verbFunc('patch')
|
||||
request.del = verbFunc('del')
|
||||
|
||||
request.jar = function (store) {
|
||||
return cookies.jar(store)
|
||||
}
|
||||
|
||||
request.cookie = function (str) {
|
||||
return cookies.parse(str)
|
||||
}
|
||||
|
||||
function wrapRequestMethod (method, options, requester, verb) {
|
||||
|
||||
return function (uri, opts, callback) {
|
||||
var params = initParams(uri, opts, callback)
|
||||
|
||||
var target = {}
|
||||
extend(true, target, options, params)
|
||||
|
||||
if (verb) {
|
||||
target.method = (verb === 'del' ? 'DELETE' : verb.toUpperCase())
|
||||
}
|
||||
|
||||
if (isFunction(requester)) {
|
||||
method = requester
|
||||
}
|
||||
|
||||
return method(target, target.callback)
|
||||
}
|
||||
}
|
||||
|
||||
request.defaults = function (options, requester) {
|
||||
var self = this
|
||||
|
||||
if (typeof options === 'function') {
|
||||
requester = options
|
||||
options = {}
|
||||
}
|
||||
|
||||
var defaults = wrapRequestMethod(self, options, requester)
|
||||
|
||||
var verbs = ['get', 'head', 'post', 'put', 'patch', 'del']
|
||||
verbs.forEach(function(verb) {
|
||||
defaults[verb] = wrapRequestMethod(self[verb], options, requester, verb)
|
||||
})
|
||||
|
||||
defaults.cookie = wrapRequestMethod(self.cookie, options, requester)
|
||||
defaults.jar = self.jar
|
||||
defaults.defaults = self.defaults
|
||||
return defaults
|
||||
}
|
||||
|
||||
request.forever = function (agentOptions, optionsArg) {
|
||||
var options = {}
|
||||
if (optionsArg) {
|
||||
extend(options, optionsArg)
|
||||
}
|
||||
if (agentOptions) {
|
||||
options.agentOptions = agentOptions
|
||||
}
|
||||
|
||||
options.forever = true
|
||||
return request.defaults(options)
|
||||
}
|
||||
|
||||
// Exports
|
||||
|
||||
module.exports = request
|
||||
request.Request = require('./request')
|
||||
request.initParams = initParams
|
||||
|
||||
// Backwards compatibility for request.debug
|
||||
Object.defineProperty(request, 'debug', {
|
||||
enumerable : true,
|
||||
get : function() {
|
||||
return request.Request.debug
|
||||
},
|
||||
set : function(debug) {
|
||||
request.Request.debug = debug
|
||||
}
|
||||
})
|
||||
153
node_modules/twit/node_modules/request/lib/auth.js
generated
vendored
Normal file
153
node_modules/twit/node_modules/request/lib/auth.js
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
'use strict'
|
||||
|
||||
var caseless = require('caseless')
|
||||
, uuid = require('node-uuid')
|
||||
, helpers = require('./helpers')
|
||||
|
||||
var md5 = helpers.md5
|
||||
, toBase64 = helpers.toBase64
|
||||
|
||||
|
||||
function Auth (request) {
|
||||
// define all public properties here
|
||||
this.request = request
|
||||
this.hasAuth = false
|
||||
this.sentAuth = false
|
||||
this.bearerToken = null
|
||||
this.user = null
|
||||
this.pass = null
|
||||
}
|
||||
|
||||
Auth.prototype.basic = function (user, pass, sendImmediately) {
|
||||
var self = this
|
||||
if (typeof user !== 'string' || (pass !== undefined && typeof pass !== 'string')) {
|
||||
self.request.emit('error', new Error('auth() received invalid user or password'))
|
||||
}
|
||||
self.user = user
|
||||
self.pass = pass
|
||||
self.hasAuth = true
|
||||
var header = user + ':' + (pass || '')
|
||||
if (sendImmediately || typeof sendImmediately === 'undefined') {
|
||||
var authHeader = 'Basic ' + toBase64(header)
|
||||
self.sentAuth = true
|
||||
return authHeader
|
||||
}
|
||||
}
|
||||
|
||||
Auth.prototype.bearer = function (bearer, sendImmediately) {
|
||||
var self = this
|
||||
self.bearerToken = bearer
|
||||
self.hasAuth = true
|
||||
if (sendImmediately || typeof sendImmediately === 'undefined') {
|
||||
if (typeof bearer === 'function') {
|
||||
bearer = bearer()
|
||||
}
|
||||
var authHeader = 'Bearer ' + (bearer || '')
|
||||
self.sentAuth = true
|
||||
return authHeader
|
||||
}
|
||||
}
|
||||
|
||||
Auth.prototype.digest = function (method, path, authHeader) {
|
||||
// TODO: More complete implementation of RFC 2617.
|
||||
// - check challenge.algorithm
|
||||
// - support algorithm="MD5-sess"
|
||||
// - handle challenge.domain
|
||||
// - support qop="auth-int" only
|
||||
// - handle Authentication-Info (not necessarily?)
|
||||
// - check challenge.stale (not necessarily?)
|
||||
// - increase nc (not necessarily?)
|
||||
// For reference:
|
||||
// http://tools.ietf.org/html/rfc2617#section-3
|
||||
// https://github.com/bagder/curl/blob/master/lib/http_digest.c
|
||||
|
||||
var self = this
|
||||
|
||||
var challenge = {}
|
||||
var re = /([a-z0-9_-]+)=(?:"([^"]+)"|([a-z0-9_-]+))/gi
|
||||
for (;;) {
|
||||
var match = re.exec(authHeader)
|
||||
if (!match) {
|
||||
break
|
||||
}
|
||||
challenge[match[1]] = match[2] || match[3]
|
||||
}
|
||||
|
||||
var ha1 = md5(self.user + ':' + challenge.realm + ':' + self.pass)
|
||||
var ha2 = md5(method + ':' + path)
|
||||
var qop = /(^|,)\s*auth\s*($|,)/.test(challenge.qop) && 'auth'
|
||||
var nc = qop && '00000001'
|
||||
var cnonce = qop && uuid().replace(/-/g, '')
|
||||
var digestResponse = qop
|
||||
? md5(ha1 + ':' + challenge.nonce + ':' + nc + ':' + cnonce + ':' + qop + ':' + ha2)
|
||||
: md5(ha1 + ':' + challenge.nonce + ':' + ha2)
|
||||
var authValues = {
|
||||
username: self.user,
|
||||
realm: challenge.realm,
|
||||
nonce: challenge.nonce,
|
||||
uri: path,
|
||||
qop: qop,
|
||||
response: digestResponse,
|
||||
nc: nc,
|
||||
cnonce: cnonce,
|
||||
algorithm: challenge.algorithm,
|
||||
opaque: challenge.opaque
|
||||
}
|
||||
|
||||
authHeader = []
|
||||
for (var k in authValues) {
|
||||
if (authValues[k]) {
|
||||
if (k === 'qop' || k === 'nc' || k === 'algorithm') {
|
||||
authHeader.push(k + '=' + authValues[k])
|
||||
} else {
|
||||
authHeader.push(k + '="' + authValues[k] + '"')
|
||||
}
|
||||
}
|
||||
}
|
||||
authHeader = 'Digest ' + authHeader.join(', ')
|
||||
self.sentAuth = true
|
||||
return authHeader
|
||||
}
|
||||
|
||||
Auth.prototype.onRequest = function (user, pass, sendImmediately, bearer) {
|
||||
var self = this
|
||||
, request = self.request
|
||||
|
||||
var authHeader
|
||||
if (bearer === undefined && user === undefined) {
|
||||
self.request.emit('error', new Error('no auth mechanism defined'))
|
||||
} else if (bearer !== undefined) {
|
||||
authHeader = self.bearer(bearer, sendImmediately)
|
||||
} else {
|
||||
authHeader = self.basic(user, pass, sendImmediately)
|
||||
}
|
||||
if (authHeader) {
|
||||
request.setHeader('authorization', authHeader)
|
||||
}
|
||||
}
|
||||
|
||||
Auth.prototype.onResponse = function (response) {
|
||||
var self = this
|
||||
, request = self.request
|
||||
|
||||
if (!self.hasAuth || self.sentAuth) { return null }
|
||||
|
||||
var c = caseless(response.headers)
|
||||
|
||||
var authHeader = c.get('www-authenticate')
|
||||
var authVerb = authHeader && authHeader.split(' ')[0].toLowerCase()
|
||||
request.debug('reauth', authVerb)
|
||||
|
||||
switch (authVerb) {
|
||||
case 'basic':
|
||||
return self.basic(self.user, self.pass, true)
|
||||
|
||||
case 'bearer':
|
||||
return self.bearer(self.bearerToken, true)
|
||||
|
||||
case 'digest':
|
||||
return self.digest(request.method, request.path, authHeader)
|
||||
}
|
||||
}
|
||||
|
||||
exports.Auth = Auth
|
||||
39
node_modules/twit/node_modules/request/lib/cookies.js
generated
vendored
Normal file
39
node_modules/twit/node_modules/request/lib/cookies.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict'
|
||||
|
||||
var tough = require('tough-cookie')
|
||||
|
||||
var Cookie = tough.Cookie
|
||||
, CookieJar = tough.CookieJar
|
||||
|
||||
|
||||
exports.parse = function(str) {
|
||||
if (str && str.uri) {
|
||||
str = str.uri
|
||||
}
|
||||
if (typeof str !== 'string') {
|
||||
throw new Error('The cookie function only accepts STRING as param')
|
||||
}
|
||||
return Cookie.parse(str)
|
||||
}
|
||||
|
||||
// Adapt the sometimes-Async api of tough.CookieJar to our requirements
|
||||
function RequestJar(store) {
|
||||
var self = this
|
||||
self._jar = new CookieJar(store)
|
||||
}
|
||||
RequestJar.prototype.setCookie = function(cookieOrStr, uri, options) {
|
||||
var self = this
|
||||
return self._jar.setCookieSync(cookieOrStr, uri, options || {})
|
||||
}
|
||||
RequestJar.prototype.getCookieString = function(uri) {
|
||||
var self = this
|
||||
return self._jar.getCookieStringSync(uri)
|
||||
}
|
||||
RequestJar.prototype.getCookies = function(uri) {
|
||||
var self = this
|
||||
return self._jar.getCookiesSync(uri)
|
||||
}
|
||||
|
||||
exports.jar = function(store) {
|
||||
return new RequestJar(store)
|
||||
}
|
||||
79
node_modules/twit/node_modules/request/lib/getProxyFromURI.js
generated
vendored
Normal file
79
node_modules/twit/node_modules/request/lib/getProxyFromURI.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
'use strict'
|
||||
|
||||
function formatHostname(hostname) {
|
||||
// canonicalize the hostname, so that 'oogle.com' won't match 'google.com'
|
||||
return hostname.replace(/^\.*/, '.').toLowerCase()
|
||||
}
|
||||
|
||||
function parseNoProxyZone(zone) {
|
||||
zone = zone.trim().toLowerCase()
|
||||
|
||||
var zoneParts = zone.split(':', 2)
|
||||
, zoneHost = formatHostname(zoneParts[0])
|
||||
, zonePort = zoneParts[1]
|
||||
, hasPort = zone.indexOf(':') > -1
|
||||
|
||||
return {hostname: zoneHost, port: zonePort, hasPort: hasPort}
|
||||
}
|
||||
|
||||
function uriInNoProxy(uri, noProxy) {
|
||||
var port = uri.port || (uri.protocol === 'https:' ? '443' : '80')
|
||||
, hostname = formatHostname(uri.hostname)
|
||||
, noProxyList = noProxy.split(',')
|
||||
|
||||
// iterate through the noProxyList until it finds a match.
|
||||
return noProxyList.map(parseNoProxyZone).some(function(noProxyZone) {
|
||||
var isMatchedAt = hostname.indexOf(noProxyZone.hostname)
|
||||
, hostnameMatched = (
|
||||
isMatchedAt > -1 &&
|
||||
(isMatchedAt === hostname.length - noProxyZone.hostname.length)
|
||||
)
|
||||
|
||||
if (noProxyZone.hasPort) {
|
||||
return (port === noProxyZone.port) && hostnameMatched
|
||||
}
|
||||
|
||||
return hostnameMatched
|
||||
})
|
||||
}
|
||||
|
||||
function getProxyFromURI(uri) {
|
||||
// Decide the proper request proxy to use based on the request URI object and the
|
||||
// environmental variables (NO_PROXY, HTTP_PROXY, etc.)
|
||||
// respect NO_PROXY environment variables (see: http://lynx.isc.org/current/breakout/lynx_help/keystrokes/environments.html)
|
||||
|
||||
var noProxy = process.env.NO_PROXY || process.env.no_proxy || ''
|
||||
|
||||
// if the noProxy is a wildcard then return null
|
||||
|
||||
if (noProxy === '*') {
|
||||
return null
|
||||
}
|
||||
|
||||
// if the noProxy is not empty and the uri is found return null
|
||||
|
||||
if (noProxy !== '' && uriInNoProxy(uri, noProxy)) {
|
||||
return null
|
||||
}
|
||||
|
||||
// Check for HTTP or HTTPS Proxy in environment Else default to null
|
||||
|
||||
if (uri.protocol === 'http:') {
|
||||
return process.env.HTTP_PROXY ||
|
||||
process.env.http_proxy || null
|
||||
}
|
||||
|
||||
if (uri.protocol === 'https:') {
|
||||
return process.env.HTTPS_PROXY ||
|
||||
process.env.https_proxy ||
|
||||
process.env.HTTP_PROXY ||
|
||||
process.env.http_proxy || null
|
||||
}
|
||||
|
||||
// if none of that works, return null
|
||||
// (What uri protocol are you using then?)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
module.exports = getProxyFromURI
|
||||
205
node_modules/twit/node_modules/request/lib/har.js
generated
vendored
Normal file
205
node_modules/twit/node_modules/request/lib/har.js
generated
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
'use strict'
|
||||
|
||||
var fs = require('fs')
|
||||
var qs = require('querystring')
|
||||
var validate = require('har-validator')
|
||||
var util = require('util')
|
||||
|
||||
function Har (request) {
|
||||
this.request = request
|
||||
}
|
||||
|
||||
Har.prototype.reducer = function (obj, pair) {
|
||||
// new property ?
|
||||
if (obj[pair.name] === undefined) {
|
||||
obj[pair.name] = pair.value
|
||||
return obj
|
||||
}
|
||||
|
||||
// existing? convert to array
|
||||
var arr = [
|
||||
obj[pair.name],
|
||||
pair.value
|
||||
]
|
||||
|
||||
obj[pair.name] = arr
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
Har.prototype.prep = function (data) {
|
||||
// construct utility properties
|
||||
data.queryObj = {}
|
||||
data.headersObj = {}
|
||||
data.postData.jsonObj = false
|
||||
data.postData.paramsObj = false
|
||||
|
||||
// construct query objects
|
||||
if (data.queryString && data.queryString.length) {
|
||||
data.queryObj = data.queryString.reduce(this.reducer, {})
|
||||
}
|
||||
|
||||
// construct headers objects
|
||||
if (data.headers && data.headers.length) {
|
||||
// loweCase header keys
|
||||
data.headersObj = data.headers.reduceRight(function (headers, header) {
|
||||
headers[header.name] = header.value
|
||||
return headers
|
||||
}, {})
|
||||
}
|
||||
|
||||
// construct Cookie header
|
||||
if (data.cookies && data.cookies.length) {
|
||||
var cookies = data.cookies.map(function (cookie) {
|
||||
return cookie.name + '=' + cookie.value
|
||||
})
|
||||
|
||||
if (cookies.length) {
|
||||
data.headersObj.cookie = cookies.join('; ')
|
||||
}
|
||||
}
|
||||
|
||||
// prep body
|
||||
switch (data.postData.mimeType) {
|
||||
case 'multipart/mixed':
|
||||
case 'multipart/related':
|
||||
case 'multipart/form-data':
|
||||
case 'multipart/alternative':
|
||||
// reset values
|
||||
data.postData.mimeType = 'multipart/form-data'
|
||||
break
|
||||
|
||||
case 'application/x-www-form-urlencoded':
|
||||
if (!data.postData.params) {
|
||||
data.postData.text = ''
|
||||
} else {
|
||||
data.postData.paramsObj = data.postData.params.reduce(this.reducer, {})
|
||||
|
||||
// always overwrite
|
||||
data.postData.text = qs.stringify(data.postData.paramsObj)
|
||||
}
|
||||
break
|
||||
|
||||
case 'text/json':
|
||||
case 'text/x-json':
|
||||
case 'application/json':
|
||||
case 'application/x-json':
|
||||
data.postData.mimeType = 'application/json'
|
||||
|
||||
if (data.postData.text) {
|
||||
try {
|
||||
data.postData.jsonObj = JSON.parse(data.postData.text)
|
||||
} catch (e) {
|
||||
this.request.debug(e)
|
||||
|
||||
// force back to text/plain
|
||||
data.postData.mimeType = 'text/plain'
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
Har.prototype.options = function (options) {
|
||||
// skip if no har property defined
|
||||
if (!options.har) {
|
||||
return options
|
||||
}
|
||||
|
||||
var har = util._extend({}, options.har)
|
||||
|
||||
// only process the first entry
|
||||
if (har.log && har.log.entries) {
|
||||
har = har.log.entries[0]
|
||||
}
|
||||
|
||||
// add optional properties to make validation successful
|
||||
har.url = har.url || options.url || options.uri || options.baseUrl || '/'
|
||||
har.httpVersion = har.httpVersion || 'HTTP/1.1'
|
||||
har.queryString = har.queryString || []
|
||||
har.headers = har.headers || []
|
||||
har.cookies = har.cookies || []
|
||||
har.postData = har.postData || {}
|
||||
har.postData.mimeType = har.postData.mimeType || 'application/octet-stream'
|
||||
|
||||
har.bodySize = 0
|
||||
har.headersSize = 0
|
||||
har.postData.size = 0
|
||||
|
||||
if (!validate.request(har)) {
|
||||
return options
|
||||
}
|
||||
|
||||
// clean up and get some utility properties
|
||||
var req = this.prep(har)
|
||||
|
||||
// construct new options
|
||||
if (req.url) {
|
||||
options.url = req.url
|
||||
}
|
||||
|
||||
if (req.method) {
|
||||
options.method = req.method
|
||||
}
|
||||
|
||||
if (Object.keys(req.queryObj).length) {
|
||||
options.qs = req.queryObj
|
||||
}
|
||||
|
||||
if (Object.keys(req.headersObj).length) {
|
||||
options.headers = req.headersObj
|
||||
}
|
||||
|
||||
switch (req.postData.mimeType) {
|
||||
case 'application/x-www-form-urlencoded':
|
||||
options.form = req.postData.paramsObj
|
||||
break
|
||||
|
||||
case 'application/json':
|
||||
if (req.postData.jsonObj) {
|
||||
options.body = req.postData.jsonObj
|
||||
options.json = true
|
||||
}
|
||||
break
|
||||
|
||||
case 'multipart/form-data':
|
||||
options.formData = {}
|
||||
|
||||
req.postData.params.forEach(function (param) {
|
||||
var attachment = {}
|
||||
|
||||
if (!param.fileName && !param.fileName && !param.contentType) {
|
||||
options.formData[param.name] = param.value
|
||||
return
|
||||
}
|
||||
|
||||
// attempt to read from disk!
|
||||
if (param.fileName && !param.value) {
|
||||
attachment.value = fs.createReadStream(param.fileName)
|
||||
} else if (param.value) {
|
||||
attachment.value = param.value
|
||||
}
|
||||
|
||||
if (param.fileName) {
|
||||
attachment.options = {
|
||||
filename: param.fileName,
|
||||
contentType: param.contentType ? param.contentType : null
|
||||
}
|
||||
}
|
||||
|
||||
options.formData[param.name] = attachment
|
||||
})
|
||||
break
|
||||
|
||||
default:
|
||||
if (req.postData.text) {
|
||||
options.body = req.postData.text
|
||||
}
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
exports.Har = Har
|
||||
64
node_modules/twit/node_modules/request/lib/helpers.js
generated
vendored
Normal file
64
node_modules/twit/node_modules/request/lib/helpers.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
'use strict'
|
||||
|
||||
var jsonSafeStringify = require('json-stringify-safe')
|
||||
, crypto = require('crypto')
|
||||
|
||||
function deferMethod() {
|
||||
if (typeof setImmediate === 'undefined') {
|
||||
return process.nextTick
|
||||
}
|
||||
|
||||
return setImmediate
|
||||
}
|
||||
|
||||
function isFunction(value) {
|
||||
return typeof value === 'function'
|
||||
}
|
||||
|
||||
function paramsHaveRequestBody(params) {
|
||||
return (
|
||||
params.body ||
|
||||
params.requestBodyStream ||
|
||||
(params.json && typeof params.json !== 'boolean') ||
|
||||
params.multipart
|
||||
)
|
||||
}
|
||||
|
||||
function safeStringify (obj) {
|
||||
var ret
|
||||
try {
|
||||
ret = JSON.stringify(obj)
|
||||
} catch (e) {
|
||||
ret = jsonSafeStringify(obj)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
function md5 (str) {
|
||||
return crypto.createHash('md5').update(str).digest('hex')
|
||||
}
|
||||
|
||||
function isReadStream (rs) {
|
||||
return rs.readable && rs.path && rs.mode
|
||||
}
|
||||
|
||||
function toBase64 (str) {
|
||||
return (new Buffer(str || '', 'utf8')).toString('base64')
|
||||
}
|
||||
|
||||
function copy (obj) {
|
||||
var o = {}
|
||||
Object.keys(obj).forEach(function (i) {
|
||||
o[i] = obj[i]
|
||||
})
|
||||
return o
|
||||
}
|
||||
|
||||
exports.isFunction = isFunction
|
||||
exports.paramsHaveRequestBody = paramsHaveRequestBody
|
||||
exports.safeStringify = safeStringify
|
||||
exports.md5 = md5
|
||||
exports.isReadStream = isReadStream
|
||||
exports.toBase64 = toBase64
|
||||
exports.copy = copy
|
||||
exports.defer = deferMethod()
|
||||
109
node_modules/twit/node_modules/request/lib/multipart.js
generated
vendored
Normal file
109
node_modules/twit/node_modules/request/lib/multipart.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
'use strict'
|
||||
|
||||
var uuid = require('node-uuid')
|
||||
, CombinedStream = require('combined-stream')
|
||||
, isstream = require('isstream')
|
||||
|
||||
|
||||
function Multipart (request) {
|
||||
this.request = request
|
||||
this.boundary = uuid()
|
||||
this.chunked = false
|
||||
this.body = null
|
||||
}
|
||||
|
||||
Multipart.prototype.isChunked = function (options) {
|
||||
var self = this
|
||||
, chunked = false
|
||||
, parts = options.data || options
|
||||
|
||||
if (!parts.forEach) {
|
||||
self.request.emit('error', new Error('Argument error, options.multipart.'))
|
||||
}
|
||||
|
||||
if (options.chunked !== undefined) {
|
||||
chunked = options.chunked
|
||||
}
|
||||
|
||||
if (self.request.getHeader('transfer-encoding') === 'chunked') {
|
||||
chunked = true
|
||||
}
|
||||
|
||||
if (!chunked) {
|
||||
parts.forEach(function (part) {
|
||||
if (typeof part.body === 'undefined') {
|
||||
self.request.emit('error', new Error('Body attribute missing in multipart.'))
|
||||
}
|
||||
if (isstream(part.body)) {
|
||||
chunked = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return chunked
|
||||
}
|
||||
|
||||
Multipart.prototype.setHeaders = function (chunked) {
|
||||
var self = this
|
||||
|
||||
if (chunked && !self.request.hasHeader('transfer-encoding')) {
|
||||
self.request.setHeader('transfer-encoding', 'chunked')
|
||||
}
|
||||
|
||||
var header = self.request.getHeader('content-type')
|
||||
|
||||
if (!header || header.indexOf('multipart') === -1) {
|
||||
self.request.setHeader('content-type', 'multipart/related; boundary=' + self.boundary)
|
||||
} else {
|
||||
if (header.indexOf('boundary') !== -1) {
|
||||
self.boundary = header.replace(/.*boundary=([^\s;]+).*/, '$1')
|
||||
} else {
|
||||
self.request.setHeader('content-type', header + '; boundary=' + self.boundary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Multipart.prototype.build = function (parts, chunked) {
|
||||
var self = this
|
||||
var body = chunked ? new CombinedStream() : []
|
||||
|
||||
function add (part) {
|
||||
return chunked ? body.append(part) : body.push(new Buffer(part))
|
||||
}
|
||||
|
||||
if (self.request.preambleCRLF) {
|
||||
add('\r\n')
|
||||
}
|
||||
|
||||
parts.forEach(function (part) {
|
||||
var preamble = '--' + self.boundary + '\r\n'
|
||||
Object.keys(part).forEach(function (key) {
|
||||
if (key === 'body') { return }
|
||||
preamble += key + ': ' + part[key] + '\r\n'
|
||||
})
|
||||
preamble += '\r\n'
|
||||
add(preamble)
|
||||
add(part.body)
|
||||
add('\r\n')
|
||||
})
|
||||
add('--' + self.boundary + '--')
|
||||
|
||||
if (self.request.postambleCRLF) {
|
||||
add('\r\n')
|
||||
}
|
||||
|
||||
return body
|
||||
}
|
||||
|
||||
Multipart.prototype.onRequest = function (options) {
|
||||
var self = this
|
||||
|
||||
var chunked = self.isChunked(options)
|
||||
, parts = options.data || options
|
||||
|
||||
self.setHeaders(chunked)
|
||||
self.chunked = chunked
|
||||
self.body = self.build(parts, chunked)
|
||||
}
|
||||
|
||||
exports.Multipart = Multipart
|
||||
147
node_modules/twit/node_modules/request/lib/oauth.js
generated
vendored
Normal file
147
node_modules/twit/node_modules/request/lib/oauth.js
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
'use strict'
|
||||
|
||||
var url = require('url')
|
||||
, qs = require('qs')
|
||||
, caseless = require('caseless')
|
||||
, uuid = require('node-uuid')
|
||||
, oauth = require('oauth-sign')
|
||||
, crypto = require('crypto')
|
||||
|
||||
|
||||
function OAuth (request) {
|
||||
this.request = request
|
||||
this.params = null
|
||||
}
|
||||
|
||||
OAuth.prototype.buildParams = function (_oauth, uri, method, query, form, qsLib) {
|
||||
var oa = {}
|
||||
for (var i in _oauth) {
|
||||
oa['oauth_' + i] = _oauth[i]
|
||||
}
|
||||
if (!oa.oauth_version) {
|
||||
oa.oauth_version = '1.0'
|
||||
}
|
||||
if (!oa.oauth_timestamp) {
|
||||
oa.oauth_timestamp = Math.floor( Date.now() / 1000 ).toString()
|
||||
}
|
||||
if (!oa.oauth_nonce) {
|
||||
oa.oauth_nonce = uuid().replace(/-/g, '')
|
||||
}
|
||||
if (!oa.oauth_signature_method) {
|
||||
oa.oauth_signature_method = 'HMAC-SHA1'
|
||||
}
|
||||
|
||||
var consumer_secret_or_private_key = oa.oauth_consumer_secret || oa.oauth_private_key
|
||||
delete oa.oauth_consumer_secret
|
||||
delete oa.oauth_private_key
|
||||
|
||||
var token_secret = oa.oauth_token_secret
|
||||
delete oa.oauth_token_secret
|
||||
|
||||
var realm = oa.oauth_realm
|
||||
delete oa.oauth_realm
|
||||
delete oa.oauth_transport_method
|
||||
|
||||
var baseurl = uri.protocol + '//' + uri.host + uri.pathname
|
||||
var params = qsLib.parse([].concat(query, form, qsLib.stringify(oa)).join('&'))
|
||||
|
||||
oa.oauth_signature = oauth.sign(
|
||||
oa.oauth_signature_method,
|
||||
method,
|
||||
baseurl,
|
||||
params,
|
||||
consumer_secret_or_private_key,
|
||||
token_secret)
|
||||
|
||||
if (realm) {
|
||||
oa.realm = realm
|
||||
}
|
||||
|
||||
return oa
|
||||
}
|
||||
|
||||
OAuth.prototype.buildBodyHash = function(_oauth, body) {
|
||||
if (['HMAC-SHA1', 'RSA-SHA1'].indexOf(_oauth.signature_method || 'HMAC-SHA1') < 0) {
|
||||
this.request.emit('error', new Error('oauth: ' + _oauth.signature_method +
|
||||
' signature_method not supported with body_hash signing.'))
|
||||
}
|
||||
|
||||
var shasum = crypto.createHash('sha1')
|
||||
shasum.update(body || '')
|
||||
var sha1 = shasum.digest('hex')
|
||||
|
||||
return new Buffer(sha1).toString('base64')
|
||||
}
|
||||
|
||||
OAuth.prototype.concatParams = function (oa, sep, wrap) {
|
||||
wrap = wrap || ''
|
||||
|
||||
var params = Object.keys(oa).filter(function (i) {
|
||||
return i !== 'realm' && i !== 'oauth_signature'
|
||||
}).sort()
|
||||
|
||||
if (oa.realm) {
|
||||
params.splice(0, 1, 'realm')
|
||||
}
|
||||
params.push('oauth_signature')
|
||||
|
||||
return params.map(function (i) {
|
||||
return i + '=' + wrap + oauth.rfc3986(oa[i]) + wrap
|
||||
}).join(sep)
|
||||
}
|
||||
|
||||
OAuth.prototype.onRequest = function (_oauth) {
|
||||
var self = this
|
||||
self.params = _oauth
|
||||
|
||||
var uri = self.request.uri || {}
|
||||
, method = self.request.method || ''
|
||||
, headers = caseless(self.request.headers)
|
||||
, body = self.request.body || ''
|
||||
, qsLib = self.request.qsLib || qs
|
||||
|
||||
var form
|
||||
, query
|
||||
, contentType = headers.get('content-type') || ''
|
||||
, formContentType = 'application/x-www-form-urlencoded'
|
||||
, transport = _oauth.transport_method || 'header'
|
||||
|
||||
if (contentType.slice(0, formContentType.length) === formContentType) {
|
||||
contentType = formContentType
|
||||
form = body
|
||||
}
|
||||
if (uri.query) {
|
||||
query = uri.query
|
||||
}
|
||||
if (transport === 'body' && (method !== 'POST' || contentType !== formContentType)) {
|
||||
self.request.emit('error', new Error('oauth: transport_method of body requires POST ' +
|
||||
'and content-type ' + formContentType))
|
||||
}
|
||||
|
||||
if (!form && typeof _oauth.body_hash === 'boolean') {
|
||||
_oauth.body_hash = self.buildBodyHash(_oauth, self.request.body.toString())
|
||||
}
|
||||
|
||||
var oa = self.buildParams(_oauth, uri, method, query, form, qsLib)
|
||||
|
||||
switch (transport) {
|
||||
case 'header':
|
||||
self.request.setHeader('Authorization', 'OAuth ' + self.concatParams(oa, ',', '"'))
|
||||
break
|
||||
|
||||
case 'query':
|
||||
var href = self.request.uri.href += (query ? '&' : '?') + self.concatParams(oa, '&')
|
||||
self.request.uri = url.parse(href)
|
||||
self.request.path = self.request.uri.path
|
||||
break
|
||||
|
||||
case 'body':
|
||||
self.request.body = (form ? form + '&' : '') + self.concatParams(oa, '&')
|
||||
break
|
||||
|
||||
default:
|
||||
self.request.emit('error', new Error('oauth: transport_method invalid'))
|
||||
}
|
||||
}
|
||||
|
||||
exports.OAuth = OAuth
|
||||
51
node_modules/twit/node_modules/request/lib/querystring.js
generated
vendored
Normal file
51
node_modules/twit/node_modules/request/lib/querystring.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict'
|
||||
|
||||
var qs = require('qs')
|
||||
, querystring = require('querystring')
|
||||
|
||||
|
||||
function Querystring (request) {
|
||||
this.request = request
|
||||
this.lib = null
|
||||
this.useQuerystring = null
|
||||
this.parseOptions = null
|
||||
this.stringifyOptions = null
|
||||
}
|
||||
|
||||
Querystring.prototype.init = function (options) {
|
||||
if (this.lib) {return}
|
||||
|
||||
this.useQuerystring = options.useQuerystring
|
||||
this.lib = (this.useQuerystring ? querystring : qs)
|
||||
|
||||
this.parseOptions = options.qsParseOptions || {}
|
||||
this.stringifyOptions = options.qsStringifyOptions || {}
|
||||
}
|
||||
|
||||
Querystring.prototype.stringify = function (obj) {
|
||||
return (this.useQuerystring)
|
||||
? this.rfc3986(this.lib.stringify(obj,
|
||||
this.stringifyOptions.sep || null,
|
||||
this.stringifyOptions.eq || null,
|
||||
this.stringifyOptions))
|
||||
: this.lib.stringify(obj, this.stringifyOptions)
|
||||
}
|
||||
|
||||
Querystring.prototype.parse = function (str) {
|
||||
return (this.useQuerystring)
|
||||
? this.lib.parse(str,
|
||||
this.parseOptions.sep || null,
|
||||
this.parseOptions.eq || null,
|
||||
this.parseOptions)
|
||||
: this.lib.parse(str, this.parseOptions)
|
||||
}
|
||||
|
||||
Querystring.prototype.rfc3986 = function (str) {
|
||||
return str.replace(/[!'()*]/g, function (c) {
|
||||
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
|
||||
})
|
||||
}
|
||||
|
||||
Querystring.prototype.unescape = querystring.unescape
|
||||
|
||||
exports.Querystring = Querystring
|
||||
153
node_modules/twit/node_modules/request/lib/redirect.js
generated
vendored
Normal file
153
node_modules/twit/node_modules/request/lib/redirect.js
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
'use strict'
|
||||
|
||||
var url = require('url')
|
||||
var isUrl = /^https?:/
|
||||
|
||||
function Redirect (request) {
|
||||
this.request = request
|
||||
this.followRedirect = true
|
||||
this.followRedirects = true
|
||||
this.followAllRedirects = false
|
||||
this.allowRedirect = function () {return true}
|
||||
this.maxRedirects = 10
|
||||
this.redirects = []
|
||||
this.redirectsFollowed = 0
|
||||
this.removeRefererHeader = false
|
||||
}
|
||||
|
||||
Redirect.prototype.onRequest = function (options) {
|
||||
var self = this
|
||||
|
||||
if (options.maxRedirects !== undefined) {
|
||||
self.maxRedirects = options.maxRedirects
|
||||
}
|
||||
if (typeof options.followRedirect === 'function') {
|
||||
self.allowRedirect = options.followRedirect
|
||||
}
|
||||
if (options.followRedirect !== undefined) {
|
||||
self.followRedirects = !!options.followRedirect
|
||||
}
|
||||
if (options.followAllRedirects !== undefined) {
|
||||
self.followAllRedirects = options.followAllRedirects
|
||||
}
|
||||
if (self.followRedirects || self.followAllRedirects) {
|
||||
self.redirects = self.redirects || []
|
||||
}
|
||||
if (options.removeRefererHeader !== undefined) {
|
||||
self.removeRefererHeader = options.removeRefererHeader
|
||||
}
|
||||
}
|
||||
|
||||
Redirect.prototype.redirectTo = function (response) {
|
||||
var self = this
|
||||
, request = self.request
|
||||
|
||||
var redirectTo = null
|
||||
if (response.statusCode >= 300 && response.statusCode < 400 && response.caseless.has('location')) {
|
||||
var location = response.caseless.get('location')
|
||||
request.debug('redirect', location)
|
||||
|
||||
if (self.followAllRedirects) {
|
||||
redirectTo = location
|
||||
} else if (self.followRedirects) {
|
||||
switch (request.method) {
|
||||
case 'PATCH':
|
||||
case 'PUT':
|
||||
case 'POST':
|
||||
case 'DELETE':
|
||||
// Do not follow redirects
|
||||
break
|
||||
default:
|
||||
redirectTo = location
|
||||
break
|
||||
}
|
||||
}
|
||||
} else if (response.statusCode === 401) {
|
||||
var authHeader = request._auth.onResponse(response)
|
||||
if (authHeader) {
|
||||
request.setHeader('authorization', authHeader)
|
||||
redirectTo = request.uri
|
||||
}
|
||||
}
|
||||
return redirectTo
|
||||
}
|
||||
|
||||
Redirect.prototype.onResponse = function (response) {
|
||||
var self = this
|
||||
, request = self.request
|
||||
|
||||
var redirectTo = self.redirectTo(response)
|
||||
if (!redirectTo || !self.allowRedirect.call(request, response)) {
|
||||
return false
|
||||
}
|
||||
|
||||
request.debug('redirect to', redirectTo)
|
||||
|
||||
// ignore any potential response body. it cannot possibly be useful
|
||||
// to us at this point.
|
||||
// response.resume should be defined, but check anyway before calling. Workaround for browserify.
|
||||
if (response.resume) {
|
||||
response.resume()
|
||||
}
|
||||
|
||||
if (self.redirectsFollowed >= self.maxRedirects) {
|
||||
request.emit('error', new Error('Exceeded maxRedirects. Probably stuck in a redirect loop ' + request.uri.href))
|
||||
return false
|
||||
}
|
||||
self.redirectsFollowed += 1
|
||||
|
||||
if (!isUrl.test(redirectTo)) {
|
||||
redirectTo = url.resolve(request.uri.href, redirectTo)
|
||||
}
|
||||
|
||||
var uriPrev = request.uri
|
||||
request.uri = url.parse(redirectTo)
|
||||
|
||||
// handle the case where we change protocol from https to http or vice versa
|
||||
if (request.uri.protocol !== uriPrev.protocol) {
|
||||
request._updateProtocol()
|
||||
}
|
||||
|
||||
self.redirects.push(
|
||||
{ statusCode : response.statusCode
|
||||
, redirectUri: redirectTo
|
||||
}
|
||||
)
|
||||
if (self.followAllRedirects && response.statusCode !== 401 && response.statusCode !== 307) {
|
||||
request.method = 'GET'
|
||||
}
|
||||
// request.method = 'GET' // Force all redirects to use GET || commented out fixes #215
|
||||
delete request.src
|
||||
delete request.req
|
||||
delete request.agent
|
||||
delete request._started
|
||||
if (response.statusCode !== 401 && response.statusCode !== 307) {
|
||||
// Remove parameters from the previous response, unless this is the second request
|
||||
// for a server that requires digest authentication.
|
||||
delete request.body
|
||||
delete request._form
|
||||
if (request.headers) {
|
||||
request.removeHeader('host')
|
||||
request.removeHeader('content-type')
|
||||
request.removeHeader('content-length')
|
||||
if (request.uri.hostname !== request.originalHost.split(':')[0]) {
|
||||
// Remove authorization if changing hostnames (but not if just
|
||||
// changing ports or protocols). This matches the behavior of curl:
|
||||
// https://github.com/bagder/curl/blob/6beb0eee/lib/http.c#L710
|
||||
request.removeHeader('authorization')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!self.removeRefererHeader) {
|
||||
request.setHeader('referer', request.uri.href)
|
||||
}
|
||||
|
||||
request.emit('redirect')
|
||||
|
||||
request.init()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
exports.Redirect = Redirect
|
||||
183
node_modules/twit/node_modules/request/lib/tunnel.js
generated
vendored
Normal file
183
node_modules/twit/node_modules/request/lib/tunnel.js
generated
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
'use strict'
|
||||
|
||||
var url = require('url')
|
||||
, tunnel = require('tunnel-agent')
|
||||
|
||||
var defaultProxyHeaderWhiteList = [
|
||||
'accept',
|
||||
'accept-charset',
|
||||
'accept-encoding',
|
||||
'accept-language',
|
||||
'accept-ranges',
|
||||
'cache-control',
|
||||
'content-encoding',
|
||||
'content-language',
|
||||
'content-length',
|
||||
'content-location',
|
||||
'content-md5',
|
||||
'content-range',
|
||||
'content-type',
|
||||
'connection',
|
||||
'date',
|
||||
'expect',
|
||||
'max-forwards',
|
||||
'pragma',
|
||||
'referer',
|
||||
'te',
|
||||
'transfer-encoding',
|
||||
'user-agent',
|
||||
'via'
|
||||
]
|
||||
|
||||
var defaultProxyHeaderExclusiveList = [
|
||||
'proxy-authorization'
|
||||
]
|
||||
|
||||
function constructProxyHost(uriObject) {
|
||||
var port = uriObject.portA
|
||||
, protocol = uriObject.protocol
|
||||
, proxyHost = uriObject.hostname + ':'
|
||||
|
||||
if (port) {
|
||||
proxyHost += port
|
||||
} else if (protocol === 'https:') {
|
||||
proxyHost += '443'
|
||||
} else {
|
||||
proxyHost += '80'
|
||||
}
|
||||
|
||||
return proxyHost
|
||||
}
|
||||
|
||||
function constructProxyHeaderWhiteList(headers, proxyHeaderWhiteList) {
|
||||
var whiteList = proxyHeaderWhiteList
|
||||
.reduce(function (set, header) {
|
||||
set[header.toLowerCase()] = true
|
||||
return set
|
||||
}, {})
|
||||
|
||||
return Object.keys(headers)
|
||||
.filter(function (header) {
|
||||
return whiteList[header.toLowerCase()]
|
||||
})
|
||||
.reduce(function (set, header) {
|
||||
set[header] = headers[header]
|
||||
return set
|
||||
}, {})
|
||||
}
|
||||
|
||||
function constructTunnelOptions (request, proxyHeaders) {
|
||||
var proxy = request.proxy
|
||||
|
||||
var tunnelOptions = {
|
||||
proxy : {
|
||||
host : proxy.hostname,
|
||||
port : +proxy.port,
|
||||
proxyAuth : proxy.auth,
|
||||
headers : proxyHeaders
|
||||
},
|
||||
headers : request.headers,
|
||||
ca : request.ca,
|
||||
cert : request.cert,
|
||||
key : request.key,
|
||||
passphrase : request.passphrase,
|
||||
pfx : request.pfx,
|
||||
ciphers : request.ciphers,
|
||||
rejectUnauthorized : request.rejectUnauthorized,
|
||||
secureOptions : request.secureOptions,
|
||||
secureProtocol : request.secureProtocol
|
||||
}
|
||||
|
||||
return tunnelOptions
|
||||
}
|
||||
|
||||
function constructTunnelFnName(uri, proxy) {
|
||||
var uriProtocol = (uri.protocol === 'https:' ? 'https' : 'http')
|
||||
var proxyProtocol = (proxy.protocol === 'https:' ? 'Https' : 'Http')
|
||||
return [uriProtocol, proxyProtocol].join('Over')
|
||||
}
|
||||
|
||||
function getTunnelFn(request) {
|
||||
var uri = request.uri
|
||||
var proxy = request.proxy
|
||||
var tunnelFnName = constructTunnelFnName(uri, proxy)
|
||||
return tunnel[tunnelFnName]
|
||||
}
|
||||
|
||||
|
||||
function Tunnel (request) {
|
||||
this.request = request
|
||||
this.proxyHeaderWhiteList = defaultProxyHeaderWhiteList
|
||||
this.proxyHeaderExclusiveList = []
|
||||
}
|
||||
|
||||
Tunnel.prototype.isEnabled = function (options) {
|
||||
var request = this.request
|
||||
// Tunnel HTTPS by default, or if a previous request in the redirect chain
|
||||
// was tunneled. Allow the user to override this setting.
|
||||
|
||||
// If self.tunnel is already set (because this is a redirect), use the
|
||||
// existing value.
|
||||
if (typeof request.tunnel !== 'undefined') {
|
||||
return request.tunnel
|
||||
}
|
||||
|
||||
// If options.tunnel is set (the user specified a value), use it.
|
||||
if (typeof options.tunnel !== 'undefined') {
|
||||
return options.tunnel
|
||||
}
|
||||
|
||||
// If the destination is HTTPS, tunnel.
|
||||
if (request.uri.protocol === 'https:') {
|
||||
return true
|
||||
}
|
||||
|
||||
// Otherwise, leave tunnel unset, because if a later request in the redirect
|
||||
// chain is HTTPS then that request (and any subsequent ones) should be
|
||||
// tunneled.
|
||||
return undefined
|
||||
}
|
||||
|
||||
Tunnel.prototype.setup = function (options) {
|
||||
var self = this
|
||||
, request = self.request
|
||||
|
||||
options = options || {}
|
||||
|
||||
if (typeof request.proxy === 'string') {
|
||||
request.proxy = url.parse(request.proxy)
|
||||
}
|
||||
|
||||
if (!request.proxy || !request.tunnel) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Setup Proxy Header Exclusive List and White List
|
||||
if (options.proxyHeaderWhiteList) {
|
||||
self.proxyHeaderWhiteList = options.proxyHeaderWhiteList
|
||||
}
|
||||
if (options.proxyHeaderExclusiveList) {
|
||||
self.proxyHeaderExclusiveList = options.proxyHeaderExclusiveList
|
||||
}
|
||||
|
||||
var proxyHeaderExclusiveList = self.proxyHeaderExclusiveList.concat(defaultProxyHeaderExclusiveList)
|
||||
var proxyHeaderWhiteList = self.proxyHeaderWhiteList.concat(proxyHeaderExclusiveList)
|
||||
|
||||
// Setup Proxy Headers and Proxy Headers Host
|
||||
// Only send the Proxy White Listed Header names
|
||||
var proxyHeaders = constructProxyHeaderWhiteList(request.headers, proxyHeaderWhiteList)
|
||||
proxyHeaders.host = constructProxyHost(request.uri)
|
||||
|
||||
proxyHeaderExclusiveList.forEach(request.removeHeader, request)
|
||||
|
||||
// Set Agent from Tunnel Data
|
||||
var tunnelFn = getTunnelFn(request)
|
||||
var tunnelOptions = constructTunnelOptions(request, proxyHeaders)
|
||||
request.agent = tunnelFn(tunnelOptions)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
Tunnel.defaultProxyHeaderWhiteList = defaultProxyHeaderWhiteList
|
||||
Tunnel.defaultProxyHeaderExclusiveList = defaultProxyHeaderExclusiveList
|
||||
exports.Tunnel = Tunnel
|
||||
1
node_modules/twit/node_modules/request/node_modules/.bin/har-validator
generated
vendored
Symbolic link
1
node_modules/twit/node_modules/request/node_modules/.bin/har-validator
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../har-validator/bin/har-validator
|
||||
1
node_modules/twit/node_modules/request/node_modules/.bin/uuid
generated
vendored
Symbolic link
1
node_modules/twit/node_modules/request/node_modules/.bin/uuid
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../node-uuid/bin/uuid
|
||||
55
node_modules/twit/node_modules/request/node_modules/aws-sign2/LICENSE
generated
vendored
Normal file
55
node_modules/twit/node_modules/request/node_modules/aws-sign2/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
Apache License
|
||||
|
||||
Version 2.0, January 2004
|
||||
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
4
node_modules/twit/node_modules/request/node_modules/aws-sign2/README.md
generated
vendored
Normal file
4
node_modules/twit/node_modules/request/node_modules/aws-sign2/README.md
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
aws-sign
|
||||
========
|
||||
|
||||
AWS signing. Originally pulled from LearnBoost/knox, maintained as vendor in request, now a standalone module.
|
||||
202
node_modules/twit/node_modules/request/node_modules/aws-sign2/index.js
generated
vendored
Normal file
202
node_modules/twit/node_modules/request/node_modules/aws-sign2/index.js
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
/*!
|
||||
* knox - auth
|
||||
* Copyright(c) 2010 LearnBoost <dev@learnboost.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var crypto = require('crypto')
|
||||
, parse = require('url').parse
|
||||
;
|
||||
|
||||
/**
|
||||
* Valid keys.
|
||||
*/
|
||||
|
||||
var keys =
|
||||
[ 'acl'
|
||||
, 'location'
|
||||
, 'logging'
|
||||
, 'notification'
|
||||
, 'partNumber'
|
||||
, 'policy'
|
||||
, 'requestPayment'
|
||||
, 'torrent'
|
||||
, 'uploadId'
|
||||
, 'uploads'
|
||||
, 'versionId'
|
||||
, 'versioning'
|
||||
, 'versions'
|
||||
, 'website'
|
||||
]
|
||||
|
||||
/**
|
||||
* Return an "Authorization" header value with the given `options`
|
||||
* in the form of "AWS <key>:<signature>"
|
||||
*
|
||||
* @param {Object} options
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function authorization (options) {
|
||||
return 'AWS ' + options.key + ':' + sign(options)
|
||||
}
|
||||
|
||||
module.exports = authorization
|
||||
module.exports.authorization = authorization
|
||||
|
||||
/**
|
||||
* Simple HMAC-SHA1 Wrapper
|
||||
*
|
||||
* @param {Object} options
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function hmacSha1 (options) {
|
||||
return crypto.createHmac('sha1', options.secret).update(options.message).digest('base64')
|
||||
}
|
||||
|
||||
module.exports.hmacSha1 = hmacSha1
|
||||
|
||||
/**
|
||||
* Create a base64 sha1 HMAC for `options`.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function sign (options) {
|
||||
options.message = stringToSign(options)
|
||||
return hmacSha1(options)
|
||||
}
|
||||
module.exports.sign = sign
|
||||
|
||||
/**
|
||||
* Create a base64 sha1 HMAC for `options`.
|
||||
*
|
||||
* Specifically to be used with S3 presigned URLs
|
||||
*
|
||||
* @param {Object} options
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function signQuery (options) {
|
||||
options.message = queryStringToSign(options)
|
||||
return hmacSha1(options)
|
||||
}
|
||||
module.exports.signQuery= signQuery
|
||||
|
||||
/**
|
||||
* Return a string for sign() with the given `options`.
|
||||
*
|
||||
* Spec:
|
||||
*
|
||||
* <verb>\n
|
||||
* <md5>\n
|
||||
* <content-type>\n
|
||||
* <date>\n
|
||||
* [headers\n]
|
||||
* <resource>
|
||||
*
|
||||
* @param {Object} options
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function stringToSign (options) {
|
||||
var headers = options.amazonHeaders || ''
|
||||
if (headers) headers += '\n'
|
||||
var r =
|
||||
[ options.verb
|
||||
, options.md5
|
||||
, options.contentType
|
||||
, options.date ? options.date.toUTCString() : ''
|
||||
, headers + options.resource
|
||||
]
|
||||
return r.join('\n')
|
||||
}
|
||||
module.exports.queryStringToSign = stringToSign
|
||||
|
||||
/**
|
||||
* Return a string for sign() with the given `options`, but is meant exclusively
|
||||
* for S3 presigned URLs
|
||||
*
|
||||
* Spec:
|
||||
*
|
||||
* <date>\n
|
||||
* <resource>
|
||||
*
|
||||
* @param {Object} options
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function queryStringToSign (options){
|
||||
return 'GET\n\n\n' + options.date + '\n' + options.resource
|
||||
}
|
||||
module.exports.queryStringToSign = queryStringToSign
|
||||
|
||||
/**
|
||||
* Perform the following:
|
||||
*
|
||||
* - ignore non-amazon headers
|
||||
* - lowercase fields
|
||||
* - sort lexicographically
|
||||
* - trim whitespace between ":"
|
||||
* - join with newline
|
||||
*
|
||||
* @param {Object} headers
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function canonicalizeHeaders (headers) {
|
||||
var buf = []
|
||||
, fields = Object.keys(headers)
|
||||
;
|
||||
for (var i = 0, len = fields.length; i < len; ++i) {
|
||||
var field = fields[i]
|
||||
, val = headers[field]
|
||||
, field = field.toLowerCase()
|
||||
;
|
||||
if (0 !== field.indexOf('x-amz')) continue
|
||||
buf.push(field + ':' + val)
|
||||
}
|
||||
return buf.sort().join('\n')
|
||||
}
|
||||
module.exports.canonicalizeHeaders = canonicalizeHeaders
|
||||
|
||||
/**
|
||||
* Perform the following:
|
||||
*
|
||||
* - ignore non sub-resources
|
||||
* - sort lexicographically
|
||||
*
|
||||
* @param {String} resource
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function canonicalizeResource (resource) {
|
||||
var url = parse(resource, true)
|
||||
, path = url.pathname
|
||||
, buf = []
|
||||
;
|
||||
|
||||
Object.keys(url.query).forEach(function(key){
|
||||
if (!~keys.indexOf(key)) return
|
||||
var val = '' == url.query[key] ? '' : '=' + encodeURIComponent(url.query[key])
|
||||
buf.push(key + val)
|
||||
})
|
||||
|
||||
return path + (buf.length ? '?' + buf.sort().join('&') : '')
|
||||
}
|
||||
module.exports.canonicalizeResource = canonicalizeResource
|
||||
45
node_modules/twit/node_modules/request/node_modules/aws-sign2/package.json
generated
vendored
Normal file
45
node_modules/twit/node_modules/request/node_modules/aws-sign2/package.json
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Mikeal Rogers",
|
||||
"email": "mikeal.rogers@gmail.com",
|
||||
"url": "http://www.futurealoof.com"
|
||||
},
|
||||
"name": "aws-sign2",
|
||||
"description": "AWS signing. Originally pulled from LearnBoost/knox, maintained as vendor in request, now a standalone module.",
|
||||
"version": "0.5.0",
|
||||
"repository": {
|
||||
"url": "git+https://github.com/mikeal/aws-sign.git"
|
||||
},
|
||||
"main": "index.js",
|
||||
"dependencies": {},
|
||||
"devDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mikeal/aws-sign/issues"
|
||||
},
|
||||
"_id": "aws-sign2@0.5.0",
|
||||
"dist": {
|
||||
"shasum": "c57103f7a17fc037f02d7c2e64b602ea223f7d63",
|
||||
"tarball": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz"
|
||||
},
|
||||
"_from": "aws-sign2@>=0.5.0 <0.6.0",
|
||||
"_npmVersion": "1.3.2",
|
||||
"_npmUser": {
|
||||
"name": "mikeal",
|
||||
"email": "mikeal.rogers@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "mikeal",
|
||||
"email": "mikeal.rogers@gmail.com"
|
||||
}
|
||||
],
|
||||
"directories": {},
|
||||
"_shasum": "c57103f7a17fc037f02d7c2e64b602ea223f7d63",
|
||||
"_resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz",
|
||||
"readme": "ERROR: No README data found!",
|
||||
"homepage": "https://github.com/mikeal/aws-sign#readme"
|
||||
}
|
||||
59
node_modules/twit/node_modules/request/node_modules/bl/.jshintrc
generated
vendored
Normal file
59
node_modules/twit/node_modules/request/node_modules/bl/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"predef": [ ]
|
||||
, "bitwise": false
|
||||
, "camelcase": false
|
||||
, "curly": false
|
||||
, "eqeqeq": false
|
||||
, "forin": false
|
||||
, "immed": false
|
||||
, "latedef": false
|
||||
, "noarg": true
|
||||
, "noempty": true
|
||||
, "nonew": true
|
||||
, "plusplus": false
|
||||
, "quotmark": true
|
||||
, "regexp": false
|
||||
, "undef": true
|
||||
, "unused": true
|
||||
, "strict": false
|
||||
, "trailing": true
|
||||
, "maxlen": 120
|
||||
, "asi": true
|
||||
, "boss": true
|
||||
, "debug": true
|
||||
, "eqnull": true
|
||||
, "esnext": true
|
||||
, "evil": true
|
||||
, "expr": true
|
||||
, "funcscope": false
|
||||
, "globalstrict": false
|
||||
, "iterator": false
|
||||
, "lastsemic": true
|
||||
, "laxbreak": true
|
||||
, "laxcomma": true
|
||||
, "loopfunc": true
|
||||
, "multistr": false
|
||||
, "onecase": false
|
||||
, "proto": false
|
||||
, "regexdash": false
|
||||
, "scripturl": true
|
||||
, "smarttabs": false
|
||||
, "shadow": false
|
||||
, "sub": true
|
||||
, "supernew": false
|
||||
, "validthis": true
|
||||
, "browser": true
|
||||
, "couch": false
|
||||
, "devel": false
|
||||
, "dojo": false
|
||||
, "mootools": false
|
||||
, "node": true
|
||||
, "nonstandard": true
|
||||
, "prototypejs": false
|
||||
, "rhino": false
|
||||
, "worker": true
|
||||
, "wsh": false
|
||||
, "nomen": false
|
||||
, "onevar": false
|
||||
, "passfail": false
|
||||
}
|
||||
1
node_modules/twit/node_modules/request/node_modules/bl/.npmignore
generated
vendored
Normal file
1
node_modules/twit/node_modules/request/node_modules/bl/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules/
|
||||
11
node_modules/twit/node_modules/request/node_modules/bl/.travis.yml
generated
vendored
Normal file
11
node_modules/twit/node_modules/request/node_modules/bl/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
- "0.10"
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
notifications:
|
||||
email:
|
||||
- rod@vagg.org
|
||||
script: npm test
|
||||
13
node_modules/twit/node_modules/request/node_modules/bl/LICENSE.md
generated
vendored
Normal file
13
node_modules/twit/node_modules/request/node_modules/bl/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
The MIT License (MIT)
|
||||
=====================
|
||||
|
||||
Copyright (c) 2014 bl contributors
|
||||
----------------------------------
|
||||
|
||||
*bl contributors listed at <https://github.com/rvagg/bl#contributors>*
|
||||
|
||||
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.
|
||||
198
node_modules/twit/node_modules/request/node_modules/bl/README.md
generated
vendored
Normal file
198
node_modules/twit/node_modules/request/node_modules/bl/README.md
generated
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
# bl *(BufferList)*
|
||||
|
||||
**A Node.js Buffer list collector, reader and streamer thingy.**
|
||||
|
||||
[](https://nodei.co/npm/bl/)
|
||||
[](https://nodei.co/npm/bl/)
|
||||
|
||||
**bl** is a storage object for collections of Node Buffers, exposing them with the main Buffer readable API. Also works as a duplex stream so you can collect buffers from a stream that emits them and emit buffers to a stream that consumes them!
|
||||
|
||||
The original buffers are kept intact and copies are only done as necessary. Any reads that require the use of a single original buffer will return a slice of that buffer only (which references the same memory as the original buffer). Reads that span buffers perform concatenation as required and return the results transparently.
|
||||
|
||||
```js
|
||||
const BufferList = require('bl')
|
||||
|
||||
var bl = new BufferList()
|
||||
bl.append(new Buffer('abcd'))
|
||||
bl.append(new Buffer('efg'))
|
||||
bl.append('hi') // bl will also accept & convert Strings
|
||||
bl.append(new Buffer('j'))
|
||||
bl.append(new Buffer([ 0x3, 0x4 ]))
|
||||
|
||||
console.log(bl.length) // 12
|
||||
|
||||
console.log(bl.slice(0, 10).toString('ascii')) // 'abcdefghij'
|
||||
console.log(bl.slice(3, 10).toString('ascii')) // 'defghij'
|
||||
console.log(bl.slice(3, 6).toString('ascii')) // 'def'
|
||||
console.log(bl.slice(3, 8).toString('ascii')) // 'defgh'
|
||||
console.log(bl.slice(5, 10).toString('ascii')) // 'fghij'
|
||||
|
||||
// or just use toString!
|
||||
console.log(bl.toString()) // 'abcdefghij\u0003\u0004'
|
||||
console.log(bl.toString('ascii', 3, 8)) // 'defgh'
|
||||
console.log(bl.toString('ascii', 5, 10)) // 'fghij'
|
||||
|
||||
// other standard Buffer readables
|
||||
console.log(bl.readUInt16BE(10)) // 0x0304
|
||||
console.log(bl.readUInt16LE(10)) // 0x0403
|
||||
```
|
||||
|
||||
Give it a callback in the constructor and use it just like **[concat-stream](https://github.com/maxogden/node-concat-stream)**:
|
||||
|
||||
```js
|
||||
const bl = require('bl')
|
||||
, fs = require('fs')
|
||||
|
||||
fs.createReadStream('README.md')
|
||||
.pipe(bl(function (err, data) { // note 'new' isn't strictly required
|
||||
// `data` is a complete Buffer object containing the full data
|
||||
console.log(data.toString())
|
||||
}))
|
||||
```
|
||||
|
||||
Note that when you use the *callback* method like this, the resulting `data` parameter is a concatenation of all `Buffer` objects in the list. If you want to avoid the overhead of this concatenation (in cases of extreme performance consciousness), then avoid the *callback* method and just listen to `'end'` instead, like a standard Stream.
|
||||
|
||||
Or to fetch a URL using [hyperquest](https://github.com/substack/hyperquest) (should work with [request](http://github.com/mikeal/request) and even plain Node http too!):
|
||||
```js
|
||||
const hyperquest = require('hyperquest')
|
||||
, bl = require('bl')
|
||||
, url = 'https://raw.github.com/rvagg/bl/master/README.md'
|
||||
|
||||
hyperquest(url).pipe(bl(function (err, data) {
|
||||
console.log(data.toString())
|
||||
}))
|
||||
```
|
||||
|
||||
Or, use it as a readable stream to recompose a list of Buffers to an output source:
|
||||
|
||||
```js
|
||||
const BufferList = require('bl')
|
||||
, fs = require('fs')
|
||||
|
||||
var bl = new BufferList()
|
||||
bl.append(new Buffer('abcd'))
|
||||
bl.append(new Buffer('efg'))
|
||||
bl.append(new Buffer('hi'))
|
||||
bl.append(new Buffer('j'))
|
||||
|
||||
bl.pipe(fs.createWriteStream('gibberish.txt'))
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
* <a href="#ctor"><code><b>new BufferList([ callback ])</b></code></a>
|
||||
* <a href="#length"><code>bl.<b>length</b></code></a>
|
||||
* <a href="#append"><code>bl.<b>append(buffer)</b></code></a>
|
||||
* <a href="#get"><code>bl.<b>get(index)</b></code></a>
|
||||
* <a href="#slice"><code>bl.<b>slice([ start[, end ] ])</b></code></a>
|
||||
* <a href="#copy"><code>bl.<b>copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])</b></code></a>
|
||||
* <a href="#duplicate"><code>bl.<b>duplicate()</b></code></a>
|
||||
* <a href="#consume"><code>bl.<b>consume(bytes)</b></code></a>
|
||||
* <a href="#toString"><code>bl.<b>toString([encoding, [ start, [ end ]]])</b></code></a>
|
||||
* <a href="#readXX"><code>bl.<b>readDoubleBE()</b></code>, <code>bl.<b>readDoubleLE()</b></code>, <code>bl.<b>readFloatBE()</b></code>, <code>bl.<b>readFloatLE()</b></code>, <code>bl.<b>readInt32BE()</b></code>, <code>bl.<b>readInt32LE()</b></code>, <code>bl.<b>readUInt32BE()</b></code>, <code>bl.<b>readUInt32LE()</b></code>, <code>bl.<b>readInt16BE()</b></code>, <code>bl.<b>readInt16LE()</b></code>, <code>bl.<b>readUInt16BE()</b></code>, <code>bl.<b>readUInt16LE()</b></code>, <code>bl.<b>readInt8()</b></code>, <code>bl.<b>readUInt8()</b></code></a>
|
||||
* <a href="#streams">Streams</a>
|
||||
|
||||
--------------------------------------------------------
|
||||
<a name="ctor"></a>
|
||||
### new BufferList([ callback | buffer | buffer array ])
|
||||
The constructor takes an optional callback, if supplied, the callback will be called with an error argument followed by a reference to the **bl** instance, when `bl.end()` is called (i.e. from a piped stream). This is a convenient method of collecting the entire contents of a stream, particularly when the stream is *chunky*, such as a network stream.
|
||||
|
||||
Normally, no arguments are required for the constructor, but you can initialise the list by passing in a single `Buffer` object or an array of `Buffer` object.
|
||||
|
||||
`new` is not strictly required, if you don't instantiate a new object, it will be done automatically for you so you can create a new instance simply with:
|
||||
|
||||
```js
|
||||
var bl = require('bl')
|
||||
var myinstance = bl()
|
||||
|
||||
// equivilant to:
|
||||
|
||||
var BufferList = require('bl')
|
||||
var myinstance = new BufferList()
|
||||
```
|
||||
|
||||
--------------------------------------------------------
|
||||
<a name="length"></a>
|
||||
### bl.length
|
||||
Get the length of the list in bytes. This is the sum of the lengths of all of the buffers contained in the list, minus any initial offset for a semi-consumed buffer at the beginning. Should accurately represent the total number of bytes that can be read from the list.
|
||||
|
||||
--------------------------------------------------------
|
||||
<a name="append"></a>
|
||||
### bl.append(buffer)
|
||||
`append(buffer)` adds an additional buffer or BufferList to the internal list.
|
||||
|
||||
--------------------------------------------------------
|
||||
<a name="get"></a>
|
||||
### bl.get(index)
|
||||
`get()` will return the byte at the specified index.
|
||||
|
||||
--------------------------------------------------------
|
||||
<a name="slice"></a>
|
||||
### bl.slice([ start, [ end ] ])
|
||||
`slice()` returns a new `Buffer` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively.
|
||||
|
||||
If the requested range spans a single internal buffer then a slice of that buffer will be returned which shares the original memory range of that Buffer. If the range spans multiple buffers then copy operations will likely occur to give you a uniform Buffer.
|
||||
|
||||
--------------------------------------------------------
|
||||
<a name="copy"></a>
|
||||
### bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])
|
||||
`copy()` copies the content of the list in the `dest` buffer, starting from `destStart` and containing the bytes within the range specified with `srcStart` to `srcEnd`. `destStart`, `start` and `end` are optional and will default to the beginning of the `dest` buffer, and the beginning and end of the list respectively.
|
||||
|
||||
--------------------------------------------------------
|
||||
<a name="duplicate"></a>
|
||||
### bl.duplicate()
|
||||
`duplicate()` performs a **shallow-copy** of the list. The internal Buffers remains the same, so if you change the underlying Buffers, the change will be reflected in both the original and the duplicate. This method is needed if you want to call `consume()` or `pipe()` and still keep the original list.Example:
|
||||
|
||||
```js
|
||||
var bl = new BufferList()
|
||||
|
||||
bl.append('hello')
|
||||
bl.append(' world')
|
||||
bl.append('\n')
|
||||
|
||||
bl.duplicate().pipe(process.stdout, { end: false })
|
||||
|
||||
console.log(bl.toString())
|
||||
```
|
||||
|
||||
--------------------------------------------------------
|
||||
<a name="consume"></a>
|
||||
### bl.consume(bytes)
|
||||
`consume()` will shift bytes *off the start of the list*. The number of bytes consumed don't need to line up with the sizes of the internal Buffers—initial offsets will be calculated accordingly in order to give you a consistent view of the data.
|
||||
|
||||
--------------------------------------------------------
|
||||
<a name="toString"></a>
|
||||
### bl.toString([encoding, [ start, [ end ]]])
|
||||
`toString()` will return a string representation of the buffer. The optional `start` and `end` arguments are passed on to `slice()`, while the `encoding` is passed on to `toString()` of the resulting Buffer. See the [Buffer#toString()](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end) documentation for more information.
|
||||
|
||||
--------------------------------------------------------
|
||||
<a name="readXX"></a>
|
||||
### bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8()
|
||||
|
||||
All of the standard byte-reading methods of the `Buffer` interface are implemented and will operate across internal Buffer boundaries transparently.
|
||||
|
||||
See the <b><code>[Buffer](http://nodejs.org/docs/latest/api/buffer.html)</code></b> documentation for how these work.
|
||||
|
||||
--------------------------------------------------------
|
||||
<a name="streams"></a>
|
||||
### Streams
|
||||
**bl** is a Node **[Duplex Stream](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_duplex)**, so it can be read from and written to like a standard Node stream. You can also `pipe()` to and from a **bl** instance.
|
||||
|
||||
--------------------------------------------------------
|
||||
|
||||
## Contributors
|
||||
|
||||
**bl** is brought to you by the following hackers:
|
||||
|
||||
* [Rod Vagg](https://github.com/rvagg)
|
||||
* [Matteo Collina](https://github.com/mcollina)
|
||||
* [Jarett Cruger](https://github.com/jcrugzz)
|
||||
|
||||
=======
|
||||
|
||||
<a name="license"></a>
|
||||
## License & copyright
|
||||
|
||||
Copyright (c) 2013-2014 bl contributors (listed above).
|
||||
|
||||
bl is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.
|
||||
221
node_modules/twit/node_modules/request/node_modules/bl/bl.js
generated
vendored
Normal file
221
node_modules/twit/node_modules/request/node_modules/bl/bl.js
generated
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
var DuplexStream = require('readable-stream/duplex')
|
||||
, util = require('util')
|
||||
|
||||
function BufferList (callback) {
|
||||
if (!(this instanceof BufferList))
|
||||
return new BufferList(callback)
|
||||
|
||||
this._bufs = []
|
||||
this.length = 0
|
||||
|
||||
if (typeof callback == 'function') {
|
||||
this._callback = callback
|
||||
|
||||
var piper = function (err) {
|
||||
if (this._callback) {
|
||||
this._callback(err)
|
||||
this._callback = null
|
||||
}
|
||||
}.bind(this)
|
||||
|
||||
this.on('pipe', function (src) {
|
||||
src.on('error', piper)
|
||||
})
|
||||
this.on('unpipe', function (src) {
|
||||
src.removeListener('error', piper)
|
||||
})
|
||||
}
|
||||
else if (Buffer.isBuffer(callback))
|
||||
this.append(callback)
|
||||
else if (Array.isArray(callback)) {
|
||||
callback.forEach(function (b) {
|
||||
Buffer.isBuffer(b) && this.append(b)
|
||||
}.bind(this))
|
||||
}
|
||||
|
||||
DuplexStream.call(this)
|
||||
}
|
||||
|
||||
util.inherits(BufferList, DuplexStream)
|
||||
|
||||
BufferList.prototype._offset = function (offset) {
|
||||
var tot = 0, i = 0, _t
|
||||
for (; i < this._bufs.length; i++) {
|
||||
_t = tot + this._bufs[i].length
|
||||
if (offset < _t)
|
||||
return [ i, offset - tot ]
|
||||
tot = _t
|
||||
}
|
||||
}
|
||||
|
||||
BufferList.prototype.append = function (buf) {
|
||||
var isBuffer = Buffer.isBuffer(buf) ||
|
||||
buf instanceof BufferList
|
||||
|
||||
// coerce number arguments to strings, since Buffer(number) does
|
||||
// uninitialized memory allocation
|
||||
if (typeof buf == 'number')
|
||||
buf = buf.toString()
|
||||
|
||||
this._bufs.push(isBuffer ? buf : new Buffer(buf))
|
||||
this.length += buf.length
|
||||
return this
|
||||
}
|
||||
|
||||
BufferList.prototype._write = function (buf, encoding, callback) {
|
||||
this.append(buf)
|
||||
if (callback)
|
||||
callback()
|
||||
}
|
||||
|
||||
BufferList.prototype._read = function (size) {
|
||||
if (!this.length)
|
||||
return this.push(null)
|
||||
size = Math.min(size, this.length)
|
||||
this.push(this.slice(0, size))
|
||||
this.consume(size)
|
||||
}
|
||||
|
||||
BufferList.prototype.end = function (chunk) {
|
||||
DuplexStream.prototype.end.call(this, chunk)
|
||||
|
||||
if (this._callback) {
|
||||
this._callback(null, this.slice())
|
||||
this._callback = null
|
||||
}
|
||||
}
|
||||
|
||||
BufferList.prototype.get = function (index) {
|
||||
return this.slice(index, index + 1)[0]
|
||||
}
|
||||
|
||||
BufferList.prototype.slice = function (start, end) {
|
||||
return this.copy(null, 0, start, end)
|
||||
}
|
||||
|
||||
BufferList.prototype.copy = function (dst, dstStart, srcStart, srcEnd) {
|
||||
if (typeof srcStart != 'number' || srcStart < 0)
|
||||
srcStart = 0
|
||||
if (typeof srcEnd != 'number' || srcEnd > this.length)
|
||||
srcEnd = this.length
|
||||
if (srcStart >= this.length)
|
||||
return dst || new Buffer(0)
|
||||
if (srcEnd <= 0)
|
||||
return dst || new Buffer(0)
|
||||
|
||||
var copy = !!dst
|
||||
, off = this._offset(srcStart)
|
||||
, len = srcEnd - srcStart
|
||||
, bytes = len
|
||||
, bufoff = (copy && dstStart) || 0
|
||||
, start = off[1]
|
||||
, l
|
||||
, i
|
||||
|
||||
// copy/slice everything
|
||||
if (srcStart === 0 && srcEnd == this.length) {
|
||||
if (!copy) // slice, just return a full concat
|
||||
return Buffer.concat(this._bufs)
|
||||
|
||||
// copy, need to copy individual buffers
|
||||
for (i = 0; i < this._bufs.length; i++) {
|
||||
this._bufs[i].copy(dst, bufoff)
|
||||
bufoff += this._bufs[i].length
|
||||
}
|
||||
|
||||
return dst
|
||||
}
|
||||
|
||||
// easy, cheap case where it's a subset of one of the buffers
|
||||
if (bytes <= this._bufs[off[0]].length - start) {
|
||||
return copy
|
||||
? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
|
||||
: this._bufs[off[0]].slice(start, start + bytes)
|
||||
}
|
||||
|
||||
if (!copy) // a slice, we need something to copy in to
|
||||
dst = new Buffer(len)
|
||||
|
||||
for (i = off[0]; i < this._bufs.length; i++) {
|
||||
l = this._bufs[i].length - start
|
||||
|
||||
if (bytes > l) {
|
||||
this._bufs[i].copy(dst, bufoff, start)
|
||||
} else {
|
||||
this._bufs[i].copy(dst, bufoff, start, start + bytes)
|
||||
break
|
||||
}
|
||||
|
||||
bufoff += l
|
||||
bytes -= l
|
||||
|
||||
if (start)
|
||||
start = 0
|
||||
}
|
||||
|
||||
return dst
|
||||
}
|
||||
|
||||
BufferList.prototype.toString = function (encoding, start, end) {
|
||||
return this.slice(start, end).toString(encoding)
|
||||
}
|
||||
|
||||
BufferList.prototype.consume = function (bytes) {
|
||||
while (this._bufs.length) {
|
||||
if (bytes > this._bufs[0].length) {
|
||||
bytes -= this._bufs[0].length
|
||||
this.length -= this._bufs[0].length
|
||||
this._bufs.shift()
|
||||
} else {
|
||||
this._bufs[0] = this._bufs[0].slice(bytes)
|
||||
this.length -= bytes
|
||||
break
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
BufferList.prototype.duplicate = function () {
|
||||
var i = 0
|
||||
, copy = new BufferList()
|
||||
|
||||
for (; i < this._bufs.length; i++)
|
||||
copy.append(this._bufs[i])
|
||||
|
||||
return copy
|
||||
}
|
||||
|
||||
BufferList.prototype.destroy = function () {
|
||||
this._bufs.length = 0;
|
||||
this.length = 0;
|
||||
this.push(null);
|
||||
}
|
||||
|
||||
;(function () {
|
||||
var methods = {
|
||||
'readDoubleBE' : 8
|
||||
, 'readDoubleLE' : 8
|
||||
, 'readFloatBE' : 4
|
||||
, 'readFloatLE' : 4
|
||||
, 'readInt32BE' : 4
|
||||
, 'readInt32LE' : 4
|
||||
, 'readUInt32BE' : 4
|
||||
, 'readUInt32LE' : 4
|
||||
, 'readInt16BE' : 2
|
||||
, 'readInt16LE' : 2
|
||||
, 'readUInt16BE' : 2
|
||||
, 'readUInt16LE' : 2
|
||||
, 'readInt8' : 1
|
||||
, 'readUInt8' : 1
|
||||
}
|
||||
|
||||
for (var m in methods) {
|
||||
(function (m) {
|
||||
BufferList.prototype[m] = function (offset) {
|
||||
return this.slice(offset, offset + methods[m])[m](0)
|
||||
}
|
||||
}(m))
|
||||
}
|
||||
}())
|
||||
|
||||
module.exports = BufferList
|
||||
5
node_modules/twit/node_modules/request/node_modules/bl/node_modules/readable-stream/.npmignore
generated
vendored
Normal file
5
node_modules/twit/node_modules/request/node_modules/bl/node_modules/readable-stream/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
build/
|
||||
test/
|
||||
examples/
|
||||
fs.js
|
||||
zlib.js
|
||||
18
node_modules/twit/node_modules/request/node_modules/bl/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
18
node_modules/twit/node_modules/request/node_modules/bl/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
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.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user