UNPKG

@drieam/common

Version:

Default Drieam api wrapper

37 lines (31 loc) 1.04 kB
import get from "lodash/get"; import camelCase from "lodash/camelCase"; import isNil from "lodash/isNil"; function isNotNil(x) { return !isNil(x); } function req(appName, propName, props) { if (isNil(props[propName])) { throw new Error("".concat(appName, ": ").concat(propName, " is required")); } } function delay(callback) { var ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var timer = 0; return function delayCallback() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } // eslint-disable-next-line @typescript-eslint/no-this-alias var context = this; clearTimeout(timer); timer = window.setTimeout(function () { callback.apply(context, args); }, ms); }; } function promiseNoop() { var filters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return Promise.resolve(filters); } export { get, isNotNil, req, delay, camelCase, promiseNoop };