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

@teneff/with-retry

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@teneff/with-retry - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

2

decorator.d.ts
import withRetry from "./withRetry";
export default function (...args: Parameters<typeof withRetry>): <T, K extends keyof T>(target: T, propertyKey: K, descriptor: PropertyDescriptor) => void;
export default function <T>(...args: Parameters<typeof withRetry>): <K extends string>(target: { [key in K]: (...args: any[]) => Promise<T>; }, propertyKey: K, descriptor?: TypedPropertyDescriptor<() => Promise<T>>) => any;

@@ -9,4 +9,5 @@ "use strict";

return function (target, propertyKey, descriptor) {
Object.assign(descriptor, {
value: (0, withRetry_1.default)(...args)(descriptor.value),
const method = target[propertyKey];
return Object.assign({}, descriptor, {
value: (0, withRetry_1.default)(...args)(method),
});

@@ -13,0 +14,0 @@ };

{
"name": "@teneff/with-retry",
"version": "1.1.1",
"version": "1.1.2",
"description": "Decorator for retrying async operations",

@@ -9,5 +9,6 @@ "main": "index.js",

"clean": "rimraf dist",
"build": "tsc",
"build": "tsc -p tsconfig.build.json",
"lint": "eslint src",
"test": "jest",
"typecheck": "yarn build --noEmit -p tsconfig.jest.json",
"codecov": "codecov",

@@ -14,0 +15,0 @@ "postbuild": "cp package.json dist; cp README.md dist"

@@ -91,16 +91,37 @@ # @teneff/with-retry

### v1.1.0
Adds support for unknown errors
```javascript
import withRetry, { UnknownError } from '@teneff/with-retry'
import withRetry, { UnknownError } from "@teneff/with-retry";
function resolvesPromiseWithNonError() {
return Promise.reject('a string')
return Promise.reject("a string");
}
await withRetry({
errors: UnknownError
})(resolvesPromiseWithNonError)()
errors: UnknownError,
})(resolvesPromiseWithNonError)();
```
### v1.1.2
Fixes issue [#6](https://github.com/Teneff/withRetry/issues/6) preserving class context
```typescript
class Example {
private mockCallback = jest
.fn()
.mockRejectedValueOnce(new Error(`[${num}] mock error`))
.mockResolvedValue(`[${num}] success`);
@withRetry({
maxCalls: 4,
})
getData2(): Promise<string> {
return this.mockCallback("arg1", "arg2");
}
}
```
[got]: http://npmjs.com/package/got

@@ -107,0 +128,0 @@ [legacy]: https://babeljs.io/docs/en/babel-plugin-proposal-decorators#legacy

@@ -12,10 +12,10 @@ "use strict";

function withRetry(options = {}) {
const settings = Object.assign(Object.assign({}, defaults), options);
const settings = { ...defaults, ...options };
return (callback) => {
let { maxCalls } = settings;
const errors = [];
return async (...args) => {
return async function (...args) {
do {
try {
return await callback(...args);
return await callback.apply(this, args);
}

@@ -22,0 +22,0 @@ catch (error) {

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