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

github-api-tags-full

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-api-tags-full - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

example.js

61

index.js

@@ -5,3 +5,5 @@ var Promise = require('bluebird'),

objectAssign = require('object-assign'),
arrayFlatten = require('array-flatten');
arrayFlatten = require('array-flatten'),
util = require('util'),
EventEmitter = require('events').EventEmitter;

@@ -28,35 +30,64 @@ var getTags = function(pageNo, repoId, github) {

githubTags = function(repoId, github) {
var GithubTags = function() {
this.self = this;
this.tagsAll = 0;
this.tagsDone = 0;
this.tagCommitsDone = 0;
};
GithubTags.prototype.fetch = function(repoId, github) {
Promise.promisifyAll(github.repos);
var self = this.self;
// Current github API (v3) doesn't support sorting tags (e.g. by their creation date).
return getTags(1, repoId, github)
.then(function(firstTags) {
self.tagsAll += firstTags.length;
self.emit('page', 1);
var lastPageUrl = parseLinks(firstTags.meta.link).last;
var lastPageNo = url.parse(lastPageUrl, true).query.page;
var pageNos = [];
for(var pageNo = 2; pageNo <= lastPageNo; pageNo++) {
var pageNos = [];
for(var pageNo = 2; pageNo <= lastPageNo; pageNo++) {
pageNos.push(pageNo);
}
// tagPages.push(firstTags); // add own tags (from this 1st lookup)
return Promise
.map(pageNos, function(pageNo) { // each page no
return getTags(pageNo, repoId, github)
.then(function(tags) {
self.tagsAll += tags.length;
self.emit('page', pageNo);
return tags;
})
.map(function(tag) {
return getTagCommit(tag, repoId, github);
self.tagsDone += 1;
self.emit('tag', tag);
return getTagCommit(tag, repoId, github)
.then(function(tagCommit) {
self.tagCommitsDone += 1;
self.emit('tag-commit', tagCommit);
});
});
})
.then(function(tagsCommits) {
// Also add the first tags
.then(function(tagCommits) {
// Also add the tags from the 1st page
return Promise
.map(firstTags, function(tag) {
return getTagCommit(tag, repoId, github);
self.tagsDone += 1;
self.emit('tag', tag);
return getTagCommit(tag, repoId, github)
.then(function(tagCommit) {
self.tagCommitsDone += 1;
self.emit('tag-commit', tagCommit);
return tagCommit;
});
})
.then(function(firstTagsCommits) {
return tagsCommits.concat(firstTagsCommits);
.then(function(firstTagCommits) {
return tagCommits.concat(firstTagCommits);
});

@@ -72,2 +103,4 @@

module.exports = githubTags;
util.inherits(GithubTags, EventEmitter);
module.exports = GithubTags;

@@ -6,6 +6,7 @@ {

"object-assign": "^4.0.1",
"parse-links": "^0.1.0"
"parse-links": "^0.1.0",
"progress": "^1.1.8"
},
"name": "github-api-tags-full",
"version": "4.0.0",
"version": "5.0.0",
"description": "Gets all tags with their respective commit for sorting from Github API",

@@ -12,0 +13,0 @@ "main": "index.js",

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