Socket
Socket
Sign inDemoInstall

@octokit/endpoint

Package Overview
Dependencies
Maintainers
3
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/endpoint - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

31

lib/endpoint-with-defaults.js
module.exports = endpointWithDefaults
const defaultsDeep = require('lodash/defaultsDeep')
const intersection = require('lodash/intersection')
const mapKeys = require('lodash/mapKeys')
const omit = require('lodash/omit')
const merge = require('deepmerge')
const urlTemplate = require('url-template')

@@ -21,12 +18,17 @@

// lowercase header names
options.headers = mapKeys(options.headers, (value, key) => key.toLowerCase())
if (options.headers) {
options.headers = Object.keys(options.headers).reduce((newObj, key) => {
newObj[key.toLowerCase()] = options.headers[key]
return newObj
}, {})
}
options = defaultsDeep({}, options, defaults)
options = merge.all([defaults, options].filter(Boolean))
let body = options.body
let method = options.method.toLowerCase()
let baseUrl = options.baseUrl
let url = options.url
let body = options.body
let headers = options.headers
let remainingOptions = omit(options, ['baseUrl', 'headers', 'method', 'url'])
let remainingOptions = omit(options, ['method', 'baseUrl', 'url', 'headers'])

@@ -45,4 +47,6 @@ // replace :varname with {varname} to make it RFC 6570 compatible

remainingOptions = omit(remainingOptions, intersection(Object.keys(options), urlVariableNames).concat('baseUrl'))
const omittedOptions = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat('baseUrl')
remainingOptions = omit(remainingOptions, omittedOptions)
if (['get', 'head'].includes(method)) {

@@ -74,1 +78,10 @@ url = addQueryParameters(url, remainingOptions)

}
function omit (object, keysToOmit) {
return Object.keys(object)
.filter((option) => !keysToOmit.includes(option))
.reduce((obj, key) => {
obj[key] = object[key]
return obj
}, {})
}
module.exports = extractUrlVariableName
const flatten = require('lodash/flatten')
const urlVariableRegex = /\{[^}]+\}/g

@@ -13,3 +11,3 @@ function extractUrlVariableName (url) {

return flatten(matches.map(removeNonChars))
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), [])
}

@@ -16,0 +14,0 @@

{
"name": "@octokit/endpoint",
"version": "1.2.0",
"version": "1.3.0",
"publishConfig": {

@@ -60,3 +60,3 @@ "access": "public",

"dependencies": {
"lodash": "^4.17.11",
"deepmerge": "2.2.1",
"universal-user-agent": "^2.0.1",

@@ -68,3 +68,3 @@ "url-template": "^2.0.8"

"path": "./dist/octokit-endpoint.min.js.gz",
"maxSize": "10 kB"
"maxSize": "3KB"
}

@@ -71,0 +71,0 @@ ],

@@ -16,4 +16,3 @@ # endpoint.js

builds can be downloaded from each [Release](https://github.com/octokit/endpoint.js/releases).
The bundle size is currently 9.15KB (minified and gzipped). [Help us reduce the
bundle size](Reduce bundle size for browsers) 🙏
Minified and gzipped, the build is less than 3kb.

@@ -20,0 +19,0 @@ ## Usage

module.exports = withDefaults
const defaultsDeep = require('lodash/defaultsDeep')
const merge = require('deepmerge')

@@ -8,3 +8,3 @@ const endpointWithDefaults = require('./lib/endpoint-with-defaults')

function withDefaults (oldDefaults, newDefaults) {
const DEFAULTS = defaultsDeep({}, newDefaults, oldDefaults)
const DEFAULTS = merge.all([oldDefaults, newDefaults].filter(Boolean))
const endpoint = endpointWithDefaults.bind(null, DEFAULTS)

@@ -11,0 +11,0 @@ endpoint.DEFAULTS = DEFAULTS

Sorry, the diff of this file is not supported yet

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