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

@gooddata/js-utils

Package Overview
Dependencies
Maintainers
36
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gooddata/js-utils - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

index.d.ts

7

lib/utils/test.js

@@ -7,4 +7,4 @@ "use strict";

exports.postpone = postpone;
function postpone(fn) {
var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
function postpone(fn, done) {
var timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;

@@ -14,6 +14,7 @@ setTimeout(function () {

fn();
done();
} catch (error) {
console.error(error); // eslint-disable-line no-console
done(error);
}
}, timeout);
}
{
"name": "@gooddata/js-utils",
"version": "0.8.0",
"version": "0.9.0",
"description": "Various utils shared on GoodData frontend",
"main": "lib/index.js",
"typings": "index.d.ts",
"files": [
"README.md",
"LICENSE",
"lib",
"src"
"src",
"index.d.ts"
],

@@ -21,3 +24,3 @@ "repository": {

"scripts": {
"build": "rm -rf lib && babel src --out-dir lib --ignore .test.js",
"build": "rm -rf lib && babel src --out-dir lib --ignore .test.js",
"prepublish": "yarn run build",

@@ -43,3 +46,3 @@ "test": "jest --watch"

},
"license": "UNLICENSED",
"license": "BSD-3-Clause",
"jest": {

@@ -46,0 +49,0 @@ "transform": {

@@ -1,9 +0,10 @@

export function postpone(fn, timeout = 1) {
export function postpone(fn, done, timeout = 1) {
setTimeout(() => {
try {
fn();
done();
} catch (error) {
console.error(error); // eslint-disable-line no-console
done(error);
}
}, timeout);
}

@@ -6,22 +6,23 @@ import { postpone } from '../test';

describe('postpone', () => {
it('should call function after timeout', () => {
it('should call fn and doneFn after timeout', () => {
const fn = jest.fn();
postpone(fn, 1);
const doneFn = jest.fn();
postpone(fn, doneFn, 1);
jest.runAllTimers();
expect(fn).toHaveBeenCalled();
expect(doneFn).toHaveBeenCalled();
});
it('should report error if something failed', () => {
const originalConsole = global.console;
const mockedConsoleError = jest.fn();
global.console = { error: mockedConsoleError };
it('should call doneFn with error', () => {
const fn = () => { throw Error('failed'); };
const doneFn = jest.fn();
const fn = () => { throw Error('failed'); };
postpone(fn, 1);
postpone(fn, doneFn, 1);
jest.runAllTimers();
expect(mockedConsoleError).toHaveBeenCalled();
global.console = originalConsole;
expect(doneFn).toBeCalledWith(Error('failed'));
});
});
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