Socket
Socket
Sign inDemoInstall

gh-got

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gh-got - npm Package Compare versions

Comparing version 2.4.0 to 3.0.0

42

index.js
'use strict';
var got = require('got');
var objectAssign = require('object-assign');
var Promise = require('pinkie-promise');
const got = require('got');
function ghGot(path, opts) {
if (typeof path !== 'string') {
return Promise.reject(new TypeError('Path should be a string'));
return Promise.reject(new TypeError(`Expected 'path' to be a string, got ${typeof path}`));
}
opts = objectAssign({json: true, endpoint: 'https://api.github.com/'}, opts);
opts = Object.assign({json: true, endpoint: 'https://api.github.com/'}, opts);
opts.headers = objectAssign({
opts.headers = Object.assign({
'accept': 'application/vnd.github.v3+json',

@@ -18,7 +16,7 @@ 'user-agent': 'https://github.com/sindresorhus/gh-got'

var env = process.env;
var token = env.GITHUB_TOKEN || opts.token;
const env = process.env;
const token = env.GITHUB_TOKEN || opts.token;
if (token) {
opts.headers.authorization = 'token ' + token;
opts.headers.authorization = `token ${token}`;
}

@@ -31,4 +29,4 @@

var endpoint = env.GITHUB_ENDPOINT ? env.GITHUB_ENDPOINT.replace(/[^/]$/, '$&/') : opts.endpoint;
var url = /https?/.test(path) ? path : endpoint + path;
const endpoint = env.GITHUB_ENDPOINT ? env.GITHUB_ENDPOINT.replace(/[^/]$/, '$&/') : opts.endpoint;
const url = /https?/.test(path) ? path : endpoint + path;

@@ -42,3 +40,3 @@ if (opts.stream) {

var helpers = [
const helpers = [
'get',

@@ -52,18 +50,10 @@ 'post',

helpers.forEach(function (el) {
ghGot[el] = function (url, opts) {
return ghGot(url, objectAssign({}, opts, {method: el.toUpperCase()}));
};
});
ghGot.stream = (url, opts) => ghGot(url, Object.assign({}, opts, {json: false, stream: true}));
ghGot.stream = function (url, opts) {
return ghGot(url, objectAssign({}, opts, {json: false, stream: true}));
};
for (const x of helpers) {
const method = x.toUpperCase();
ghGot[x] = (url, opts) => ghGot(url, Object.assign({}, opts, {method}));
ghGot.stream[x] = (url, opts) => ghGot.stream(url, Object.assign({}, opts, {method}));
}
helpers.forEach(function (el) {
ghGot.stream[el] = function (url, opts) {
return ghGot.stream(url, objectAssign({}, opts, {method: el.toUpperCase()}));
};
});
module.exports = ghGot;
{
"name": "gh-got",
"version": "2.4.0",
"version": "3.0.0",
"description": "Convenience wrapper for `got` to interact with the GitHub API",

@@ -13,3 +13,3 @@ "license": "MIT",

"engines": {
"node": ">=0.10.0"
"node": ">=4"
},

@@ -37,16 +37,12 @@ "scripts": {

"dependencies": {
"got": "^5.2.0",
"object-assign": "^4.0.1",
"pinkie-promise": "^2.0.0"
"got": "^6.2.0"
},
"devDependencies": {
"ava": "*",
"get-stream": "^1.0.0",
"get-stream": "^2.0.0",
"xo": "*"
},
"xo": {
"ignores": [
"test.js"
]
"esnext": true
}
}

@@ -25,3 +25,3 @@ # gh-got [![Build Status](https://travis-ci.org/sindresorhus/gh-got.svg?branch=master)](https://travis-ci.org/sindresorhus/gh-got)

'accept': 'application/vnd.github.v3+json',
'authorization': 'token ' + token
'authorization': `token ${token}`
}

@@ -71,3 +71,3 @@ }).then(res => {

Type: `string`
Type: `string`<br>
Default: `https://api.github.com/`

@@ -82,2 +82,2 @@

MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)
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