npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

facepunch-commits

v3.6.4

Published

parser commits from commits.facepunch.com

Downloads

71

Readme

This library allows you to track the commits from the facepunch site.

NPM Version NPM Downloads Node CI NPM Publish CodeQL

Installation

This is a Node.js module available through the npm registry.

$ npm i facepunch-commits

Features

  • Ability to subscribe to commits
  • Set the interval after which the next request to view the commits will be executed
  • Strict typing
  • Additional methods that allow you to check whether the commit is hidden, as well as convect the date in unixtime

Functions

subscribeToAuthor(name, callback)
  • Description: The function that will be called with the new commit.
  • Key: name
    • Type: String.
    • Description: Name of the author to subscribe to.
  • Key: callback
    • Type: Function.
    • Return: Commit
subscribeToRepository(name, callback)
  • Description: The function that will be called with the new commit.
  • Key: name
    • Type: String.
    • Description: Name of the repository to subscribe to.
  • Key: callback
    • Type: Function.
    • Return: Commit
subscribeToAuthorRepository(authorName, repositoryName, callback)
  • Description: The function that will be called with the new commit.
  • Key: authorName
    • Type: String.
    • Description: Name of the author to subscribe to.
  • Key: repositoryName
    • Type: String.
    • Description: Name of the repository to subscribe to.
  • Key: callback
    • Type: Function.
    • Return Commit
subscribeToAll(callback)
  • Description: The function that will be called with the new commit.
  • Key: callback
    • Type: Function.
    • Return: Commit
catchRequest(callback)
  • Description: Called when a request has occurred. Return error
  • Key: callback
    • Type: Function.
    • Return: Error
getCommitById(id)
  • Description: Get commit by id.
  • Key: id
    • Type: Function.
    • Return: Promise Commit.

Callback also has additional features

commit.getLikes()
  • Type: Function.
    • Description: Get likes and dislikes in commit
    • Return: Object
      {
      	likes: Number
      	dislikes: Number
      }
commit.isHide()
  • Type: Function.
    • Description: Checks whether the switch is hidden. (blues with symbols)
    • Return: boolean
commit.getDate()
  • Type: Function.
    • Description: get Date commit in js format
    • Return: Date
commit.toUnixTime()
  • Type: Function.
    • Description: Convects date in unixtime
    • Return: number
commit.likes
  • Type: Number | Null
    • Description: count likes in commit (if you called function getLikes())
commit.dislikes
  • Type: Number | Null
    • Description: count dislikes in commit (if you called function getLikes())
commit.urlCommit
  • Type: Function.
    • Description: Get url link commit
    • Return: string
commit.username
  • Type: Function.
    • Description: Get username author commit
    • Return: string
commit.avatar
  • Type: Function.
    • Description: Get avatar author commit
    • Return: string

Example return in callback function (commit)

interface Commit {
	/**
	 * unique id commit
	 */
	id: number;
	/**
	 * name repository
	 */
	repo: string;
	/**
	 * name branch
	 */
	branch: string;
	/**
	 * changeset id
	 */
	changeset: string;
	/**
	 * date created fixation commit
	 */
	created: string;
	/**
	 * commit message
	 */
	message: string;
	/**
	 * user info commit
	 */
	user: {
		/**
		 * name author commit
		 */
		name: string;
		/**
		 * avatar author commit
		 */
		avatar: string
	};
}

Example usage

const FacepunchCommits = require('facepunch-commits');

const commits = new FacepunchCommits({ 
	interval: 15000 // interval check commits in ms
});

commits.subscribeToAuthor('Garry Newman', (commit) => {
	// Here we subscribe to commits from author Garry Newman
	console.log('Ohh... New commit from Garry!!!', commit);
})

commits.subscribeToRepository('sbox', (commit) => {
	// Here we subscribe to the comments on the repository sandbox.source
	console.log(commit.isHide() ? 'Ohh, is hide. fuck....' : commit.message);
})

commits.subscribeToAuthorRepository('Garry Newman', 'Fad', (commit) => {
	console.log('fad?? New commit from Garry in rep Fad', commit);
})

commits.subscribeToAll((commit) => {
	console.log(`new commit from ${commit.user.name}:`, commit);
})

commits.catchRequest((err) => {
	console.log('new error', err);
})

(() => {
	commits.getCommitById(387280)
		.then(async (commit) => {
			console.log('Get commit', commit);
			
			const {likes, dislikes} = await commit.getLikes();
			console.log('likes:', likes);
			console.log('dislikes:', dislikes);
			
			// or
			await commit.getLikes();
			console.log('likes:', commit.likes);
			console.log('dislikes:', commit.dislikes);
		})
		
	// or
	commits.options.autoGetLikes = true;
	commits.getCommitById(387280)
		.then(async (commit) => {
			console.log('Get commit', commit);
			console.log('likes:', commit.likes);
			console.log('dislikes:', commit.dislikes);
		})
})();

Running test

$ npm run validator
$ npm test

Members

Author Zakhar Yaitskih

License

MIT