node_modules

This commit is contained in:
softprops 2019-09-18 13:19:04 +09:00
parent 2984051a42
commit b28d8151ad
445 changed files with 83959 additions and 1 deletions

View file

@ -0,0 +1,12 @@
module.exports = deprecate
const loggedMessages = {}
function deprecate (message) {
if (loggedMessages[message]) {
return
}
console.warn(`DEPRECATED (@octokit/rest): ${message}`)
loggedMessages[message] = 1
}

View file

@ -0,0 +1,7 @@
module.exports = getFirstPage
const getPage = require('./get-page')
function getFirstPage (octokit, link, headers) {
return getPage(octokit, link, 'first', headers)
}

View file

@ -0,0 +1,7 @@
module.exports = getLastPage
const getPage = require('./get-page')
function getLastPage (octokit, link, headers) {
return getPage(octokit, link, 'last', headers)
}

View file

@ -0,0 +1,7 @@
module.exports = getNextPage
const getPage = require('./get-page')
function getNextPage (octokit, link, headers) {
return getPage(octokit, link, 'next', headers)
}

View file

@ -0,0 +1,15 @@
module.exports = getPageLinks
function getPageLinks (link) {
link = link.link || link.headers.link || ''
const links = {}
// link format:
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"'
link.replace(/<([^>]*)>;\s*rel="([\w]*)"/g, (m, uri, type) => {
links[type] = uri
})
return links
}

View file

@ -0,0 +1,38 @@
module.exports = getPage
const deprecate = require('./deprecate')
const getPageLinks = require('./get-page-links')
const HttpError = require('./http-error')
function getPage (octokit, link, which, headers) {
deprecate(`octokit.get${which.charAt(0).toUpperCase() + which.slice(1)}Page() You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
const url = getPageLinks(link)[which]
if (!url) {
const urlError = new HttpError(`No ${which} page found`, 404)
return Promise.reject(urlError)
}
const requestOptions = {
url,
headers: applyAcceptHeader(link, headers)
}
const promise = octokit.request(requestOptions)
return promise
}
function applyAcceptHeader (res, headers) {
const previous = res.headers && res.headers['x-github-media-type']
if (!previous || (headers && headers.accept)) {
return headers
}
headers = headers || {}
headers.accept = 'application/vnd.' + previous
.replace('; param=', '.')
.replace('; format=', '+')
return headers
}

View file

@ -0,0 +1,7 @@
module.exports = getPreviousPage
const getPage = require('./get-page')
function getPreviousPage (octokit, link, headers) {
return getPage(octokit, link, 'prev', headers)
}

View file

@ -0,0 +1,9 @@
module.exports = hasFirstPage
const deprecate = require('./deprecate')
const getPageLinks = require('./get-page-links')
function hasFirstPage (link) {
deprecate(`octokit.hasFirstPage() You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
return getPageLinks(link).first
}

View file

@ -0,0 +1,9 @@
module.exports = hasLastPage
const deprecate = require('./deprecate')
const getPageLinks = require('./get-page-links')
function hasLastPage (link) {
deprecate(`octokit.hasLastPage() You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
return getPageLinks(link).last
}

View file

@ -0,0 +1,9 @@
module.exports = hasNextPage
const deprecate = require('./deprecate')
const getPageLinks = require('./get-page-links')
function hasNextPage (link) {
deprecate(`octokit.hasNextPage() You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
return getPageLinks(link).next
}

View file

@ -0,0 +1,9 @@
module.exports = hasPreviousPage
const deprecate = require('./deprecate')
const getPageLinks = require('./get-page-links')
function hasPreviousPage (link) {
deprecate(`octokit.hasPreviousPage() You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
return getPageLinks(link).prev
}

View file

@ -0,0 +1,15 @@
module.exports = class HttpError extends Error {
constructor (message, code, headers) {
super(message)
// Maintains proper stack trace (only available on V8)
/* istanbul ignore next */
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor)
}
this.name = 'HttpError'
this.code = code
this.headers = headers
}
}