Coder Social home page Coder Social logo

gh-user-events's Introduction

gh-user-events

NPM version Build Status Coverage Status Dependency Status devDependency Status

Get the list of events on Github performed by a user

const ghUserEvents = require('gh-user-events');

ghUserEvents('shinnn').then(events => console.log(events));
[
  {
    id: '3476797099',
    type: 'WatchEvent',
    actor: {
      id: 1131567,
      login: 'shinnn',
      gravatar_id: '',
      url: 'https://api.github.com/users/shinnn',
      avatar_url: 'https://avatars.githubusercontent.com/u/1131567?'
    },
    repo: {
      id: 32662888,
      name: 'purescript-contrib/node-purescript-bin',
      url: 'https://api.github.com/repos/purescript-contrib/node-purescript-bin'
    },
    payload: {
      action: 'started'
    },
    public: true,
    created_at: '2015-12-27T09:28:25Z',
    org: {
      id: 7391813,
      login: 'purescript-contrib',
      gravatar_id: '',
      url: 'https://api.github.com/orgs/purescript-contrib',
      avatar_url: 'https://avatars.githubusercontent.com/u/7391813?'
    }
  },
  // ...
]

Installation

Use npm.

npm install gh-user-events

API

const ghUserEvents = require('gh-user-events');

ghUserEvents(username [, options])

username: String (a Github username, for example https://github.com/shinnn'shinnn')
options: Object (gh-get options and the additional ones)
Return: Promise instance

It creates API requests to get the list of events performed by the specific Github user.

When it gets the list successfully, the promise will be fulfilled with an array of event information objects.

When one of the request fails, the promise will be rejected with an error.

options.maxPageSize

Type: String (1 ... 10)
Default: 10

Set the number of pages to request per function call. One page includes up to 30 items. All items in the pages will be joined into one array when the promise is fulfilled.

Note that it creates multiple API requests if maxPageSize option is more than 1. In other words, one function call requires at least the same number of remaining rate limit as this option.

Race condition

Under race condition, for example a new event occurs while sending multiple paginated API requests, the result rarely includes some duplicated values. In this case gh-user-events omits the duplicates from the array. Therefore, the number of items sometimes doesn't correspond with 30 * options.maxPageSize.

options.publicOnly

Type: Boolean
Default: false

true restricts the events to only public ones even if you are authenticated as the given user.

License

Copyright (c) 2015 - 2016 Shinnosuke Watanabe

Licensed under the MIT License.

gh-user-events's People

Contributors

shinnn avatar

Stargazers

Antério Vieira avatar  avatar Mikey avatar Jon Schlinkert avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.