New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add types for twitter-stream-channels 1.0.0 #19725
Merged
aozgaa
merged 1 commit into
DefinitelyTyped:master
from
adrianbardan:twitter-stream-channels
Sep 15, 2017
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// Type definitions for twitter-stream-channels 1.0.0 | ||
// Project: https://github.com/topheman/twitter-stream-channels | ||
// Definitions by: Adrian Bardan <https://github.com/adrianbardan> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
/// <reference types="node" /> | ||
/// <reference types="twit" /> | ||
|
||
declare module 'twitter-stream-channels' { | ||
|
||
import * as Twit from 'twit'; | ||
|
||
namespace TwitterStreamChannels { | ||
|
||
export namespace StreamChannels { | ||
|
||
export interface Channels { | ||
} | ||
|
||
export interface StreamChannelsOptions { | ||
track?: Object, | ||
follow?: string, | ||
locations?: string, | ||
enableChannelsEvents?: boolean, | ||
enableRootChannelsEvent?: boolean, | ||
enableKeywordsEvents?: boolean | ||
} | ||
|
||
} | ||
|
||
export class StreamChannels extends NodeJS.EventEmitter { | ||
|
||
/** | ||
* @see https://github.com/topheman/twitter-stream-channels/blob/master/lib/StreamChannels.js#L25 | ||
*/ | ||
constructor(apiClient: Twit, options: StreamChannels.StreamChannelsOptions); | ||
|
||
/** | ||
* Call this function to restart the stream after you called `.stop()` on it. | ||
* | ||
* Note: there is no need to call `.start()` to begin streaming. ` TwitterStreamChannels.streamChannels` calls .start() for you. | ||
* @method start | ||
* @returns {StreamChannels} | ||
* @see https://github.com/topheman/twitter-stream-channels/blob/master/lib/StreamChannels.js#L120 | ||
*/ | ||
start(): StreamChannels; | ||
|
||
/** | ||
* Closes the opened stream with Twitter | ||
* @method stop | ||
* @param {StreamChannelsOptions} [options] | ||
* @param {StreamChannelsOptions} [options.removeAllListeners=false] If true removes all the listeners set on the stream | ||
* @returns {StreamChannels} | ||
* @see https://github.com/topheman/twitter-stream-channels/blob/master/lib/StreamChannels.js#L120 | ||
*/ | ||
stop(options?: StreamChannels.StreamChannelsOptions): StreamChannels; | ||
|
||
|
||
/** | ||
* Returns your channel description | ||
* @method getChannels | ||
* @returns {StreamChannels.channels} | ||
* @see https://github.com/topheman/twitter-stream-channels/blob/master/lib/StreamChannels.js#L145 | ||
*/ | ||
getChannels(): StreamChannels.Channels; | ||
|
||
|
||
/** | ||
* Returns an array of the keywords you're tracking (duplicates were removed) | ||
* @method getTrackedKeywords | ||
* @returns {Array} | ||
* @see https://github.com/topheman/twitter-stream-channels/blob/master/lib/StreamChannels.js#L145 | ||
*/ | ||
getTrackedKeywords(): Array<string>; | ||
|
||
|
||
/** | ||
* Returns an object key/value - key:your channels - value:the full text search RegExp for the keywords of this channel | ||
* @method getchannelsKeywordsLowerCasedRegExp | ||
* @returns {StreamChannels.channels} | ||
* @see https://github.com/topheman/twitter-stream-channels/blob/master/lib/StreamChannels.js#L163 | ||
*/ | ||
getChannelsKeywordsLowerCasedRegExp(): StreamChannels.Channels; | ||
|
||
|
||
} | ||
|
||
} | ||
|
||
/** | ||
* @class TwitterStreamChannels | ||
* @param {Object} credentials | ||
* @param {String} credentials.consumer_key | ||
* @param {String} credentials.consumer_secret | ||
* @param {String} credentials.access_token | ||
* @param {String} credentials.access_token_secret | ||
* @return {TwitterStreamChannels} | ||
*/ | ||
|
||
class TwitterStreamChannels { | ||
/** | ||
* @see https://github.com/topheman/twitter-stream-channels/blob/master/lib/TwitterStreamChannels.js#L69 | ||
*/ | ||
constructor(config: {}); | ||
|
||
/** | ||
* Returns a Twitter API client on which you can do pretty much what you want. | ||
* More here https://github.com/ttezel/twit | ||
* @method getApiClient | ||
* @returns {Twit} | ||
* @see https://github.com/topheman/twitter-stream-channels/blob/master/lib/TwitterStreamChannels.js#L113 | ||
*/ | ||
getApiClient(): Twit; | ||
|
||
/** | ||
* Opens a Twitter Stream and returns you an other one on which you'll be able to attach events for each channels | ||
* @method streamChannels | ||
* @param {Object} options You can use the same filter options as described in the Twitter stream API for `statuses/filter` https://dev.twitter.com/docs/api/1.1/post/statuses/filter | ||
* @param {Object|Array} options.track Pass an object describing your channels. If you don't want to use channels, you can pass directly an array of keywords. | ||
* @param {String} [options.follow] A comma separated list of user IDs, indicating the users to return statuses for in the stream | ||
* @param {String} [options.locations] Specifies a set of bounding boxes to track. More about how to format this parameter here : https://dev.twitter.com/docs/streaming-apis/parameters#locations | ||
* @param {Boolean} [options.enableChannelsEvents=true] If true, will fire the events like 'channels/channelName' | ||
* @param {Boolean} [options.enableRootChannelsEvent=true] If true, will fire the event 'channels' | ||
* @param {Boolean} [options.enableKeywordsEvents=false] If true, will fire the events 'keywords/keywordName' (disabled by default) | ||
* @return {StreamChannels} | ||
* @see https://github.com/topheman/twitter-stream-channels/blob/master/lib/TwitterStreamChannels.js#L131 | ||
*/ | ||
streamChannels(options: TwitterStreamChannels.StreamChannels.StreamChannelsOptions): TwitterStreamChannels.StreamChannels; | ||
|
||
} | ||
|
||
|
||
export = TwitterStreamChannels; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"compilerOptions": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider creating a tslint.json with dts-gen. EDIT: misread the file name. |
||
"module": "commonjs", | ||
"lib": [ | ||
"es6" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictNullChecks": false, | ||
"baseUrl": "../", | ||
"typeRoots": [ | ||
"../" | ||
], | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"twitter-stream-channels-tests.ts" | ||
] | ||
} |
14 changes: 14 additions & 0 deletions
14
types/twitter-stream-channels/twitter-stream-channels-tests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as TwitterStreamChannels from "twitter-stream-channels"; | ||
|
||
const tsc = new TwitterStreamChannels({ | ||
consumer_key: '', | ||
consumer_secret: '', | ||
app_only_auth: true, | ||
}); | ||
|
||
let channels = { | ||
"js-frameworks": ['angularjs', 'jquery', 'backbone', 'emberjs'], | ||
"web": ['javascript', 'nodejs', 'html5', 'css', 'angularjs'] | ||
}; | ||
|
||
tsc.streamChannels({track: channels}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only
removeAllListeners
, should not a generic "StreamChannelsOptions" interface