Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dstwitter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dstwitter - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

107

index.js

@@ -0,1 +1,3 @@

/*jshint esversion:6, node:true */
const Twitter = require('twitter');

@@ -11,2 +13,13 @@ const ds = require('../dstools');

/**
This function sends API requests to the twitter API. This function can be called directly. It is also used by all dstwitter functions
* @name twitter
* @param {Container} wrapped the wrapped data
* @param {string} endpoint API endpoint name
* @param {string} property name of property in the response JSON to return. E.g. with followers it is 'users'. If the value is 'this' then just return the whole response JSON
* @param {Object} params An object representing the properties of the API calls. These properties are passed to the HTTP call. An exception is the param 'method' that is used to determine the HTTP API method to use - default is 'GET'.
* @param {number} pageCount=DEFAULT_PAGE_RECORDS number of items per API request- based on the twitter API limitations
* @param {number} count=MAX_RECORDS maximum number or items to load
* @returns {Collection} A collection of the requested entities
*/
module.exports = function(

@@ -85,11 +98,26 @@ wrapped,endpoint,property,params,pageCount=DEFAULT_PAGE_RECORDS,count=MAX_RECORDS){

registerFunction('twitter',module.exports);
/**
* Return followers of the screen name
* @name whatever
* @function
* @param {string} screenName screen name of twitter user
* @param {number} max max number of followers to return
* @returns {Collection} A collection of twitter user objects
*/
registerFunction('followers',function(wrapped,screenName,max){
return this.twitter('followers/list','users',{screen_name:screenName},200,max);
});
registerFunction('followers',function(wrapped,screenName,max){
return this.twitter('followers/list','users',
{screen_name:screenName,
skip_status:true
skip_status:true //statuses will not be includes in user objects
},200,max);
});
/**
* Return users the user with screenName follows (friends)
* @name following
* @function
* @param {string} screenName screen name of twitter user
* @param {number} max max number of users to return
* @returns {Collection} A collection of twitter user objects
*/
registerFunction('following',function(wrapped,screenName,max){

@@ -101,2 +129,11 @@ return this.twitter('friends/list','users',

});
/**
* Return ids for followers of the screen name
* @name followersIDs
* @function
* @param {string} screenName screen name of twitter user
* @param {number} max max number of followers to return
* @returns {Collection} A collection of twitter user ids
*/
registerFunction('followersIDs',function(wrapped,screenName,max){

@@ -108,2 +145,11 @@ return this.twitter('followers/ids','ids',

});
/**
* Return ids for users the user with screenName follows (friends)
* @name followingIDs
* @function
* @param {string} screenName screen name of twitter user
* @param {number} max max number of users to return
* @returns {Collection} A collection of twitter user ids
*/
registerFunction('followingIDs',function(wrapped,screenName,max){

@@ -115,2 +161,11 @@ return this.twitter('friends/ids','ids',

});
/**
* Return all tweets of a user
* @name tweets
* @function
* @param {string} id twitter userid or screen name
* @param {number} max max tweets to return
* @returns {Collection} A collection of tweets by the user
*/
registerFunction('tweets',function(wrapped,id,max){

@@ -123,2 +178,11 @@ return this.twitter('statuses/user_timeline','this',{

/**
* Search for tweets using a query text
* @name searchTweets
* @function
* @param {string} query text of the query
* @param {number} max max number of tweets to return
* @param {object} options additional params such as result_type and include_entities
* @returns {Collection} a collection of tweets
*/
registerFunction('searchTweets',function(wrapped,query,max,options){

@@ -134,2 +198,9 @@ options = Object.assign({

/**
* Follow a user or users. If id is specified then follow the user with the specified userid or screen name. Otherwise follow all entities in the wrapped collection. Each item can be a twitter userid, screen name or twitter user object
* @name follow
* @function
* @param {string} id twitter userid or screen name
* @returns {Collection} return JSON from API request
*/
registerFunction('follow',function(wrapped,id){

@@ -144,2 +215,9 @@ return getIDs(id,wrapped).map((item)=>this.twitter(

/**
* Unfollow a user or users. If id is specified then unfollow the user with the specified userid or screen name. Otherwise unfollow all entities in the wrapped collection. Each item can be a twitter userid, screen name or twitter user object
* @name unfollow
* @function
* @param {string} id twitter userid or screen name
* @returns {Collection} return JSON from API request
*/
registerFunction('unfollow',function(wrapped,id){

@@ -155,2 +233,10 @@ let ids = getIDs(id,wrapped);

/**
* Return a collection of the most recent retweets of the tweet specified by id
* @name retweets
* @function
* @param {string} id tweet id
* @param {number} max max number of tweets to return
* @returns {Collection} Collection of tweets
*/
registerFunction('retweets',function(wrapped,id,max){

@@ -161,3 +247,9 @@ return this.twitter('statuses/retweets','this',{id:id},100,max);

/**
* Return a collection of twitter user objects based on twitter screen names or collection of screen names. If screenName is specified then return its twitter user object. Otherwise, expect the wrapped collection to be a collection of screen names or objects with property screen_name
* @name twitterUser
* @function
* @param {string} screenName screenName of the required user
* @returns {Collection} Collection of twitter user objects
*/
registerFunction('twitterUser',function(wrapped,screenName){

@@ -178,2 +270,7 @@ let screenNames = [];

/////////////////////////////////////////////////////////////////
//private functions
/////////////////////////////////////////////////////////////////
function getIDs(input,collection){

@@ -180,0 +277,0 @@ collection = collection.valueOf();

2

package.json
{
"name": "dstwitter",
"version": "0.1.1",
"version": "0.1.2",
"description": "Simplify usage of twitter API",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,3 +8,3 @@ dstwitter - Easy use of twitter API

## Examples
###Initialize the environment
### Initialize the environment
```javascript

@@ -14,3 +14,3 @@ const ME = 'MY_SCREEN_NAME';

start = require('dstools').Collection
.context('twitter',{
.context('twitter',{ //context function sets the context twitter credentials
access_token_key:'FILL-IN',

@@ -37,5 +37,7 @@ access_token_secret : 'FILL-IN',

//follow users that follow me (that I don't already follow)
followers.drop(following).follow();
followers
.drop(following) //ignore users I am already following
.follow(); //follow them
//create a word cloud of user tweets
### create a word cloud of user tweets
start.tweets('SOME_SCREEN_NAME',10000)

@@ -42,0 +44,0 @@ .column('text').toLowerCase()

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc