New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dewib/xhr-cache

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dewib/xhr-cache - npm Package Compare versions

Comparing version 3.2.6 to 3.3.0

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [3.3.0](https://github.com/gaetansenn/xhr-cache/compare/v3.2.6...v3.3.0) (2022-09-21)
### Features
* improve xhr logs ([2e5523b](https://github.com/gaetansenn/xhr-cache/commit/2e5523b2f9b3b9e4e830751469d4c0636769cf79))
### [3.2.6](https://github.com/gaetansenn/xhr-cache/compare/v3.2.4...v3.2.6) (2021-07-12)

@@ -7,0 +14,0 @@

51

lib/library.js

@@ -8,2 +8,39 @@ import { dirname } from 'path'

export function logAxiosError (err) {
let error = ''
if (err.response) {
// Request made and server responded
error += ['data', 'status', 'headers'].reduce((accu, key) => {
if (err.response[key]) {
accu.push(`${key}: ${JSON.stringify(err.response[key])}`)
}
return accu
}, []).join(', ')
} else if (err.request) {
// The request was made but no response was received
error += `request: ${err.request}`
} else {
// Something happened in setting up the request that triggered an Error
error += `error: ${err.message}`
}
return error
}
export function getLog (name, request, action, head) {
let log = `${libPrefix} ${action} ${name} resource from ${request.url}`
if (request.params) {
log += `, params: ${JSON.stringify(request.params)}`
}
if (head) {
log += ` ${head}`
}
return log
}
export function isFunction (fnc) {

@@ -29,8 +66,4 @@ if (!fnc) { return false }

let requestInfo = `${libPrefix} Fetch ${name} resource from ${request.url}`
if (request.params) { requestInfo += `, params: ${JSON.stringify(request.params)}` }
/* eslint-disable-next-line */
console.info(requestInfo)
console.info(getLog(name, request, 'Fetch'))

@@ -41,6 +74,6 @@ try {

if (!response.data) {
let error = `${libPrefix} Response from ${request.url} is empty`
let error = getLog(name, request, 'Response', 'is empty.')
if (typeof request.catch !== 'undefined') {
error += ` using provided default value ${request.catch}`
error += ` Using provided default value ${request.catch}`
/* eslint-disable-next-line */

@@ -62,3 +95,3 @@ console.info(error)

/* eslint-disable-next-line */
console.info(`${libPrefix} Error on fetching resource ${request.url} returning catch value: ${err}`)
console.error(getLog(name, request, 'Error on fetching', `returning catch value: ${request.catch}, ${logAxiosError(err)}`))

@@ -69,3 +102,3 @@ return { data: request.catch }

/* eslint-disable-next-line */
console.error(`${libPrefix} Error on fetching resource ${request.url}: ${err}`)
console.error(getLog(name, request, 'Error on fetching', `${logAxiosError(err)}`))

@@ -72,0 +105,0 @@ return Promise.reject(err)

7

package.json
{
"name": "@dewib/xhr-cache",
"version": "3.2.6",
"version": "3.3.0",
"license": "MIT",

@@ -15,3 +15,3 @@ "description": "Cache api resources and serve it as static resource",

"test": "yarn lint && jest",
"release": "yarn test && standard-version && git push --follow-tags && npm publish"
"release": "yarn test && standard-version && git push --follow-tags && npm publish --access=public"
},

@@ -71,3 +71,6 @@ "repository": {

"standard-version": "latest"
},
"engines": {
"node": "^14.16.0"
}
}
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