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

cachios

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cachios - npm Package Compare versions

Comparing version 3.1.3 to 4.0.0

.github/workflows/typescript-compat.yml

2

package.json
{
"name": "cachios",
"version": "3.1.3",
"version": "4.0.0",
"description": "Simple axios cache wrapper using node-cache",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -295,4 +295,22 @@ # Cachios

### Custom object-hash Replacer
By default, Cachios uses an internal `defaultReplacer` function to add FormData support to [object-hash](https://github.com/puleos/object-hash).
To override this, set the `getReplaced` property of your Cachios instance:
```js
const cachios = require('cachios');
cachios.getReplaced = function (thing) {
if (thing === 'foo') {
return 'bar';
}
return thing;
};
```
## License
[MIT](LICENSE.md)

@@ -21,2 +21,19 @@ var hash = require('object-hash');

function defaultReplacer(thing) {
// object-hash doesn't handle FormData values, do it ourselves
// https://github.com/AlbinoDrought/cachios/issues/7
if (typeof FormData !== 'undefined' && thing instanceof FormData) {
var formDataValues = {};
var entriesIterator = thing.entries();
for (var entry = entriesIterator.next(); !entry.done || typeof entry.value !== 'undefined'; entry = entriesIterator.next()) {
formDataValues[entry.value[0]] = defaultReplacer(entry.value[1]);
}
return formDataValues;
}
// object-hash also doesn't support blobs, but I don't think we can read those synchronously
return thing;
}
function Cachios(axiosInstance, nodeCacheConf) {

@@ -33,6 +50,9 @@ this.axiosInstance = axiosInstance;

this.getResponseCopy = defaultResponseCopier;
this.getReplaced = defaultReplacer;
}
Cachios.prototype.getCacheKey = function (config) {
return hash(this.getCacheIdentifier(config));
return hash(this.getCacheIdentifier(config), {
replacer: this.getReplaced,
});
};

@@ -39,0 +59,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