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
40
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-martin.mosko-mms-FET-64-2018-03-28T10-25-46-031Z

index.d.ts

24

lib/utils/test.js

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -7,12 +7,28 @@ Object.defineProperty(exports, "__esModule", {

exports.postpone = postpone;
function postpone(fn) {
var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
exports.delay = delay;
// (C) 2007-2018 GoodData Corporation
function postpone(fn, done) {
var timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
console.warn('postpone() is deprecated which should be replaced by delay() function');
setTimeout(function () {
try {
fn();
done();
} catch (error) {
console.error(error); // eslint-disable-line no-console
done(error);
}
}, timeout);
}
function delay() {
var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
return new Promise(function (resolve) {
setTimeout(function () {
resolve();
}, timeout);
});
}

11

package.json
{
"name": "@gooddata/js-utils",
"version": "0.8.0",
"version": "0.9.0-martin.mosko-mms-FET-64-2018-03-28T10-25-46-031Z",
"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,22 @@

export function postpone(fn, timeout = 1) {
// (C) 2007-2018 GoodData Corporation
export function postpone(fn, done, timeout = 1) {
console.warn('postpone() is deprecated which should be replaced by delay() function');
setTimeout(() => {
try {
fn();
done();
} catch (error) {
console.error(error); // eslint-disable-line no-console
done(error);
}
}, timeout);
}
export function delay(timeout = 0) {
return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, timeout);
});
}

@@ -1,26 +0,41 @@

import { postpone } from '../test';
// (C) 2007-2018 GoodData Corporation
import { postpone, delay } from '../test';
jest.useFakeTimers();
describe('postpone', () => {
it('should call function after timeout', () => {
const fn = jest.fn();
postpone(fn, 1);
jest.runAllTimers();
expect(fn).toHaveBeenCalled();
describe('test', () => {
describe('postpone', () => {
it('should call fn and doneFn after timeout', () => {
const fn = jest.fn();
const doneFn = jest.fn();
postpone(fn, doneFn, 1);
jest.runAllTimers();
expect(fn).toHaveBeenCalled();
expect(doneFn).toHaveBeenCalled();
});
it('should call doneFn with error', () => {
const fn = () => { throw Error('failed'); };
const doneFn = jest.fn();
postpone(fn, doneFn, 1);
jest.runAllTimers();
expect(doneFn).toBeCalledWith(Error('failed'));
});
});
it('should report error if something failed', () => {
const originalConsole = global.console;
const mockedConsoleError = jest.fn();
global.console = { error: mockedConsoleError };
describe('delay', () => {
it('should call doneFn after timeout', (doneFn) => {
const pendingDelay = delay(2);
const fn = () => { throw Error('failed'); };
postpone(fn, 1);
jest.runAllTimers();
expect(mockedConsoleError).toHaveBeenCalled();
jest.runAllTimers();
global.console = originalConsole;
pendingDelay.then(() => {
doneFn();
});
});
});
});
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