@gooddata/js-utils
Advanced tools
Comparing version 0.8.0 to 0.9.0-martin.mosko-mms-FET-64-2018-03-28T10-25-46-031Z
@@ -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); | ||
}); | ||
} |
{ | ||
"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(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
35513
24
0
827
1