@rpldy/shared
Advanced tools
Comparing version 0.11.4 to 0.11.5
@@ -6,12 +6,10 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
var _consts = require("./consts"); | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function (obj) { return typeof obj; }; } else { _typeof = function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
const BISYM = Symbol.for("__rpldy-bi__"); | ||
let iCounter = 0; | ||
var BISYM = Symbol["for"]("__rpldy-bi__"); | ||
var iCounter = 0; | ||
var getBatchItemWithUrl = function (batchItem, url) { | ||
const getBatchItemWithUrl = (batchItem, url) => { | ||
batchItem.url = url; | ||
@@ -21,3 +19,3 @@ return batchItem; | ||
var getBatchItemWithFile = function (batchItem, file) { | ||
const getBatchItemWithFile = (batchItem, file) => { | ||
batchItem.file = file; | ||
@@ -27,16 +25,13 @@ return batchItem; | ||
var isLikeFile = function (f) { | ||
return f && (f instanceof Blob || f instanceof File || _typeof(f) === "object" && f.name && f.type); | ||
}; | ||
const isLikeFile = f => f && (f instanceof Blob || f instanceof File || typeof f === "object" && f.name && f.type); | ||
var _default = function _default(f, batchId) { | ||
var isPending = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
var _default = (f, batchId, isPending = false) => { | ||
iCounter += f.id && f.batchId ? 0 : 1; //keep existing id for recycled items | ||
var id = f.id && f.batchId ? f.id : "".concat(batchId, ".item-").concat(iCounter), | ||
state = isPending ? _consts.FILE_STATES.PENDING : _consts.FILE_STATES.ADDED; | ||
var batchItem = { | ||
id: id, | ||
batchId: batchId, | ||
state: state, | ||
const id = f.id && f.batchId ? f.id : `${batchId}.item-${iCounter}`, | ||
state = isPending ? _consts.FILE_STATES.PENDING : _consts.FILE_STATES.ADDED; | ||
let batchItem = { | ||
id, | ||
batchId, | ||
state, | ||
uploadStatus: 0, | ||
@@ -55,3 +50,3 @@ completed: 0, | ||
if (_typeof(f) === "object" && f[BISYM] === true) { | ||
if (typeof f === "object" && f[BISYM] === true) { | ||
//recycling existing batch item | ||
@@ -68,3 +63,3 @@ batchItem.recycled = true; | ||
} else { | ||
throw new Error("Unknown type of file added: ".concat(_typeof(f))); | ||
throw new Error(`Unknown type of file added: ${typeof f}`); | ||
} | ||
@@ -75,2 +70,2 @@ | ||
exports["default"] = _default; | ||
exports.default = _default; |
@@ -7,5 +7,5 @@ "use strict"; | ||
exports.FILE_STATES = exports.BATCH_STATES = exports.DEBUG_LOG_KEY = void 0; | ||
var DEBUG_LOG_KEY = "__rpldy-logger-debug__"; | ||
const DEBUG_LOG_KEY = "__rpldy-logger-debug__"; | ||
exports.DEBUG_LOG_KEY = DEBUG_LOG_KEY; | ||
var BATCH_STATES = { | ||
const BATCH_STATES = { | ||
PENDING: "pending", | ||
@@ -20,3 +20,3 @@ ADDED: "added", | ||
exports.BATCH_STATES = BATCH_STATES; | ||
var FILE_STATES = { | ||
const FILE_STATES = { | ||
PENDING: "pending", | ||
@@ -23,0 +23,0 @@ ADDED: "added", |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -10,4 +8,4 @@ value: true | ||
enumerable: true, | ||
get: function get() { | ||
return _invariant["default"]; | ||
get: function () { | ||
return _invariant.default; | ||
} | ||
@@ -17,4 +15,4 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
return _justThrottle["default"]; | ||
get: function () { | ||
return _justThrottle.default; | ||
} | ||
@@ -24,3 +22,3 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _consts.BATCH_STATES; | ||
@@ -31,3 +29,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _consts.FILE_STATES; | ||
@@ -38,4 +36,4 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
return _triggerCancellable["default"]; | ||
get: function () { | ||
return _triggerCancellable.default; | ||
} | ||
@@ -45,4 +43,4 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
return _triggerUpdater["default"]; | ||
get: function () { | ||
return _triggerUpdater.default; | ||
} | ||
@@ -52,4 +50,4 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
return _batchItem["default"]; | ||
get: function () { | ||
return _batchItem.default; | ||
} | ||
@@ -59,4 +57,4 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
return _request["default"]; | ||
get: function () { | ||
return _request.default; | ||
} | ||
@@ -66,3 +64,3 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _request.parseResponseHeaders; | ||
@@ -73,3 +71,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _utils.isFunction; | ||
@@ -80,3 +78,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _utils.isPlainObject; | ||
@@ -87,3 +85,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _utils.isSamePropInArrays; | ||
@@ -94,3 +92,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _utils.devFreeze; | ||
@@ -101,3 +99,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _utils.merge; | ||
@@ -108,3 +106,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _utils.getMerge; | ||
@@ -115,3 +113,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _utils.clone; | ||
@@ -122,3 +120,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _utils.pick; | ||
@@ -129,3 +127,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _utils.hasWindow; | ||
@@ -136,3 +134,3 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _utils.isProduction; | ||
@@ -163,6 +161,6 @@ } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -14,7 +14,7 @@ "use strict"; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var isDebug; | ||
let isDebug; | ||
var isEnvDebug = function () { | ||
const isEnvDebug = () => { | ||
var _process, _process$env; | ||
@@ -25,5 +25,5 @@ | ||
var isDebugOn = function () { | ||
const isDebugOn = () => { | ||
if (typeof isDebug !== "boolean") { | ||
isDebug = isEnvDebug() || (0, _hasWindow["default"])() && ("location" in window && !!~window.location.search.indexOf("rpldy_debug=true") || window[_consts.DEBUG_LOG_KEY] === true); | ||
isDebug = isEnvDebug() || (0, _hasWindow.default)() && ("location" in window && !!~window.location.search.indexOf("rpldy_debug=true") || window[_consts.DEBUG_LOG_KEY] === true); | ||
} | ||
@@ -36,4 +36,4 @@ | ||
var setDebug = function (debugOn) { | ||
if ((0, _hasWindow["default"])()) { | ||
const setDebug = debugOn => { | ||
if ((0, _hasWindow.default)()) { | ||
window[_consts.DEBUG_LOG_KEY] = debugOn; | ||
@@ -47,8 +47,6 @@ } | ||
var debugLog = function () { | ||
const debugLog = (...args) => { | ||
if (isDebugOn()) { | ||
var _console; | ||
// eslint-disable-next-line no-console | ||
(_console = console).log.apply(_console, arguments); | ||
console.log(...args); | ||
} | ||
@@ -55,0 +53,0 @@ }; |
@@ -8,7 +8,7 @@ "use strict"; | ||
enumerable: true, | ||
get: function get() { | ||
return _parseResponseHeaders["default"]; | ||
get: function () { | ||
return _parseResponseHeaders.default; | ||
} | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
@@ -19,5 +19,5 @@ var _request = _interopRequireDefault(require("./request")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = _request["default"]; | ||
exports["default"] = _default; | ||
var _default = _request.default; | ||
exports.default = _default; |
@@ -6,28 +6,12 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
var _logger = require("../logger"); | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
var _default = xhr => { | ||
let resHeaders; | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var _default = function _default(xhr) { | ||
var resHeaders; | ||
try { | ||
resHeaders = xhr.getAllResponseHeaders().trim().split(/[\r\n]+/).reduce(function (res, line) { | ||
var _line$split = line.split(": "), | ||
_line$split2 = _slicedToArray(_line$split, 2), | ||
key = _line$split2[0], | ||
val = _line$split2[1]; | ||
resHeaders = xhr.getAllResponseHeaders().trim().split(/[\r\n]+/).reduce((res, line) => { | ||
const [key, val] = line.split(": "); | ||
res[key] = val; | ||
@@ -43,2 +27,2 @@ return res; | ||
exports["default"] = _default; | ||
exports.default = _default; |
@@ -6,7 +6,7 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
var setHeaders = function (req, headers) { | ||
const setHeaders = (req, headers) => { | ||
if (headers) { | ||
Object.keys(headers).forEach(function (name) { | ||
Object.keys(headers).forEach(name => { | ||
if (headers[name] !== undefined) { | ||
@@ -19,21 +19,12 @@ req.setRequestHeader(name, headers[name]); | ||
var request = function (url, data) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var req = new XMLHttpRequest(); | ||
var pXhr = new Promise(function (resolve, reject) { | ||
req.onerror = function () { | ||
return reject(req); | ||
}; | ||
const request = (url, data, options = {}) => { | ||
const req = new XMLHttpRequest(); | ||
const pXhr = new Promise((resolve, reject) => { | ||
req.onerror = () => reject(req); | ||
req.ontimeout = function () { | ||
return reject(req); | ||
}; | ||
req.ontimeout = () => reject(req); | ||
req.onabort = function () { | ||
return reject(req); | ||
}; | ||
req.onabort = () => reject(req); | ||
req.onload = function () { | ||
return resolve(req); | ||
}; | ||
req.onload = () => resolve(req); | ||
@@ -56,2 +47,2 @@ req.open(options.method || "GET", url); | ||
var _default = request; | ||
exports["default"] = _default; | ||
exports.default = _default; |
@@ -6,33 +6,19 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
var triggerCancellable = function (trigger, event) { | ||
var doTrigger = function (event) { | ||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
const triggerCancellable = (trigger, event, ...args) => { | ||
const doTrigger = (event, ...args) => new Promise((resolve, reject) => { | ||
const results = trigger(event, ...args); | ||
if (results && results.length) { | ||
Promise.all(results).catch(reject).then(resolvedResults => resolvedResults && resolve(!!~resolvedResults.findIndex(r => r === false))); | ||
} else { | ||
resolve(false); | ||
} | ||
}); | ||
return new Promise(function (resolve, reject) { | ||
var results = trigger.apply(void 0, [event].concat(args)); | ||
if (results && results.length) { | ||
Promise.all(results)["catch"](reject).then(function (resolvedResults) { | ||
return resolvedResults && resolve(!!~resolvedResults.findIndex(function (r) { | ||
return r === false; | ||
})); | ||
}); | ||
} else { | ||
resolve(false); | ||
} | ||
}); | ||
}; | ||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
return event ? doTrigger.apply(void 0, [event].concat(args)) : doTrigger; | ||
return event ? doTrigger(event, ...args) : doTrigger; | ||
}; | ||
var _default = triggerCancellable; | ||
exports["default"] = _default; | ||
exports.default = _default; |
@@ -6,42 +6,30 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
var isEmpty = function (val) { | ||
return val === null || val === undefined; | ||
}; | ||
const isEmpty = val => val === null || val === undefined; | ||
var _default = function _default(trigger, event) { | ||
var doTrigger = function (event) { | ||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
var _default = (trigger, event, ...args) => { | ||
const doTrigger = (event, ...args) => new Promise((resolve, reject) => { | ||
const results = trigger(event, ...args); | ||
return new Promise(function (resolve, reject) { | ||
var results = trigger.apply(void 0, [event].concat(args)); | ||
if (results && results.length) { | ||
Promise.all(results).catch(reject).then(resolvedResults => { | ||
let result; | ||
if (results && results.length) { | ||
Promise.all(results)["catch"](reject).then(function (resolvedResults) { | ||
var result; | ||
if (resolvedResults) { | ||
while (isEmpty(result) && resolvedResults.length) { | ||
result = resolvedResults.pop(); | ||
} | ||
if (resolvedResults) { | ||
while (isEmpty(result) && resolvedResults.length) { | ||
result = resolvedResults.pop(); | ||
} | ||
} | ||
resolve(isEmpty(result) ? undefined : result); | ||
}); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}; | ||
resolve(isEmpty(result) ? undefined : result); | ||
}); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
return event ? doTrigger.apply(void 0, [event].concat(args)) : doTrigger; | ||
return event ? doTrigger(event, ...args) : doTrigger; | ||
}; | ||
exports["default"] = _default; | ||
exports.default = _default; |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
var _merge = _interopRequireWildcard(require("./merge")); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
@@ -22,7 +20,4 @@ /** | ||
*/ | ||
var _default = function _default(obj) { | ||
var mergeFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _merge["default"]; | ||
return (0, _merge.isMergeObj)(obj) ? mergeFn(Array.isArray(obj) ? [] : {}, obj) : obj; | ||
}; | ||
var _default = (obj, mergeFn = _merge.default) => (0, _merge.isMergeObj)(obj) ? mergeFn(Array.isArray(obj) ? [] : {}, obj) : obj; | ||
exports["default"] = _default; | ||
exports.default = _default; |
@@ -6,13 +6,11 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
var _isProduction = _interopRequireDefault(require("./isProduction")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var devFreeze = function (obj) { | ||
return (0, _isProduction["default"])() ? obj : Object.freeze(obj); | ||
}; | ||
const devFreeze = obj => (0, _isProduction.default)() ? obj : Object.freeze(obj); | ||
var _default = devFreeze; | ||
exports["default"] = _default; | ||
exports.default = _default; |
@@ -6,11 +6,7 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function (obj) { return typeof obj; }; } else { _typeof = function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
const hasWindow = () => typeof window === "object" && !!window.document; | ||
var hasWindow = function () { | ||
return (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && !!window.document; | ||
}; | ||
var _default = hasWindow; | ||
exports["default"] = _default; | ||
exports.default = _default; |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -10,4 +8,4 @@ value: true | ||
enumerable: true, | ||
get: function get() { | ||
return _isFunction["default"]; | ||
get: function () { | ||
return _isFunction.default; | ||
} | ||
@@ -17,4 +15,4 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
return _isSamePropInArrays["default"]; | ||
get: function () { | ||
return _isSamePropInArrays.default; | ||
} | ||
@@ -24,4 +22,4 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
return _devFreeze["default"]; | ||
get: function () { | ||
return _devFreeze.default; | ||
} | ||
@@ -31,4 +29,4 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
return _merge["default"]; | ||
get: function () { | ||
return _merge.default; | ||
} | ||
@@ -38,3 +36,3 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
get: function () { | ||
return _merge.getMerge; | ||
@@ -45,4 +43,4 @@ } | ||
enumerable: true, | ||
get: function get() { | ||
return _clone["default"]; | ||
get: function () { | ||
return _clone.default; | ||
} | ||
@@ -52,4 +50,4 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
return _pick["default"]; | ||
get: function () { | ||
return _pick.default; | ||
} | ||
@@ -59,4 +57,4 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
return _isPlainObject["default"]; | ||
get: function () { | ||
return _isPlainObject.default; | ||
} | ||
@@ -66,4 +64,4 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
return _hasWindow["default"]; | ||
get: function () { | ||
return _hasWindow.default; | ||
} | ||
@@ -73,4 +71,4 @@ }); | ||
enumerable: true, | ||
get: function get() { | ||
return _isProduction["default"]; | ||
get: function () { | ||
return _isProduction.default; | ||
} | ||
@@ -97,6 +95,6 @@ }); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -6,12 +6,10 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function (obj) { return typeof obj; }; } else { _typeof = function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var _default = function _default(obj) { | ||
var _default = obj => { | ||
var _Object$getPrototypeO; | ||
return !!obj && _typeof(obj) === "object" && (((_Object$getPrototypeO = Object.getPrototypeOf(obj)) === null || _Object$getPrototypeO === void 0 ? void 0 : _Object$getPrototypeO.constructor.name) === "Object" || Object.getPrototypeOf(obj) === null); | ||
return !!obj && typeof obj === "object" && (((_Object$getPrototypeO = Object.getPrototypeOf(obj)) === null || _Object$getPrototypeO === void 0 ? void 0 : _Object$getPrototypeO.constructor.name) === "Object" || Object.getPrototypeOf(obj) === null); | ||
}; | ||
exports["default"] = _default; | ||
exports.default = _default; |
@@ -6,5 +6,5 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
var isProduction = function () { | ||
const isProduction = () => { | ||
var _process, _process$env; | ||
@@ -16,2 +16,2 @@ | ||
var _default = isProduction; | ||
exports["default"] = _default; | ||
exports.default = _default; |
@@ -6,13 +6,7 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
var getPropsExtractor = function (prop) { | ||
var props = [].concat(prop); | ||
return function (arr) { | ||
return arr.map(function (i) { | ||
return props.map(function (p) { | ||
return i[p]; | ||
}).join(); | ||
}); | ||
}; | ||
const getPropsExtractor = prop => { | ||
const props = [].concat(prop); | ||
return arr => arr.map(i => props.map(p => i[p]).join()); | ||
}; | ||
@@ -25,12 +19,10 @@ /* | ||
var isSamePropInArrays = function (arr1, arr2, prop) { | ||
var diff = true; | ||
var propsExtractor = getPropsExtractor(prop); | ||
const isSamePropInArrays = (arr1, arr2, prop) => { | ||
let diff = true; | ||
const propsExtractor = getPropsExtractor(prop); | ||
if (arr1 && arr2 && arr1.length === arr2.length) { | ||
var props1 = propsExtractor(arr1), | ||
props2 = propsExtractor(arr2); | ||
diff = !!props1.find(function (p, i) { | ||
return p !== props2[i]; | ||
}); | ||
const props1 = propsExtractor(arr1), | ||
props2 = propsExtractor(arr2); | ||
diff = !!props1.find((p, i) => p !== props2[i]); | ||
} | ||
@@ -42,2 +34,2 @@ | ||
var _default = isSamePropInArrays; | ||
exports["default"] = _default; | ||
exports.default = _default; |
@@ -6,32 +6,24 @@ "use strict"; | ||
}); | ||
exports.getMerge = exports["default"] = exports.isMergeObj = void 0; | ||
exports.getMerge = exports.default = exports.isMergeObj = void 0; | ||
var _isPlainObject = _interopRequireDefault(require("./isPlainObject")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var isMergeObj = function (obj) { | ||
return (0, _isPlainObject["default"])(obj) || Array.isArray(obj); | ||
}; | ||
const isMergeObj = obj => (0, _isPlainObject.default)(obj) || Array.isArray(obj); | ||
exports.isMergeObj = isMergeObj; | ||
var getKeys = function (obj, options) { | ||
var keys = Object.keys(obj); | ||
const getKeys = (obj, options) => { | ||
const keys = Object.keys(obj); | ||
return options.withSymbols ? keys.concat(Object.getOwnPropertySymbols(obj)) : keys; | ||
}; | ||
var getMerge = function () { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var merge = function (target) { | ||
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
sources[_key - 1] = arguments[_key]; | ||
} | ||
const getMerge = (options = {}) => { | ||
const merge = (target, ...sources) => { | ||
if (target && sources.length) { | ||
sources.forEach(function (source) { | ||
sources.forEach(source => { | ||
if (source) { | ||
getKeys(source, options).forEach(function (key) { | ||
var prop = source[key]; | ||
getKeys(source, options).forEach(key => { | ||
const prop = source[key]; | ||
@@ -42,3 +34,3 @@ if (!options.predicate || options.predicate(key, prop)) { | ||
if (isMergeObj(prop)) { | ||
if (typeof target[key] === "undefined" || !(0, _isPlainObject["default"])(target[key])) { | ||
if (typeof target[key] === "undefined" || !(0, _isPlainObject.default)(target[key])) { | ||
//recreate target prop if doesnt exist or not an object | ||
@@ -80,2 +72,2 @@ target[key] = Array.isArray(prop) ? [] : {}; | ||
exports["default"] = _default; | ||
exports.default = _default; |
@@ -6,14 +6,12 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
var _default = function _default(obj, props) { | ||
return obj && Object.keys(obj).reduce(function (res, key) { | ||
if (~props.indexOf(key)) { | ||
res[key] = obj[key]; | ||
} | ||
var _default = (obj, props) => obj && Object.keys(obj).reduce((res, key) => { | ||
if (~props.indexOf(key)) { | ||
res[key] = obj[key]; | ||
} | ||
return res; | ||
}, {}); | ||
}; | ||
return res; | ||
}, {}); | ||
exports["default"] = _default; | ||
exports.default = _default; |
@@ -1,8 +0,6 @@ | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function (obj) { return typeof obj; }; } else { _typeof = function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
import { FILE_STATES } from "./consts"; | ||
var BISYM = Symbol["for"]("__rpldy-bi__"); | ||
var iCounter = 0; | ||
const BISYM = Symbol.for("__rpldy-bi__"); | ||
let iCounter = 0; | ||
var getBatchItemWithUrl = function (batchItem, url) { | ||
const getBatchItemWithUrl = (batchItem, url) => { | ||
batchItem.url = url; | ||
@@ -12,3 +10,3 @@ return batchItem; | ||
var getBatchItemWithFile = function (batchItem, file) { | ||
const getBatchItemWithFile = (batchItem, file) => { | ||
batchItem.file = file; | ||
@@ -18,16 +16,13 @@ return batchItem; | ||
var isLikeFile = function (f) { | ||
return f && (f instanceof Blob || f instanceof File || _typeof(f) === "object" && f.name && f.type); | ||
}; | ||
const isLikeFile = f => f && (f instanceof Blob || f instanceof File || typeof f === "object" && f.name && f.type); | ||
export default (function (f, batchId) { | ||
var isPending = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
export default ((f, batchId, isPending = false) => { | ||
iCounter += f.id && f.batchId ? 0 : 1; //keep existing id for recycled items | ||
var id = f.id && f.batchId ? f.id : "".concat(batchId, ".item-").concat(iCounter), | ||
state = isPending ? FILE_STATES.PENDING : FILE_STATES.ADDED; | ||
var batchItem = { | ||
id: id, | ||
batchId: batchId, | ||
state: state, | ||
const id = f.id && f.batchId ? f.id : `${batchId}.item-${iCounter}`, | ||
state = isPending ? FILE_STATES.PENDING : FILE_STATES.ADDED; | ||
let batchItem = { | ||
id, | ||
batchId, | ||
state, | ||
uploadStatus: 0, | ||
@@ -46,3 +41,3 @@ completed: 0, | ||
if (_typeof(f) === "object" && f[BISYM] === true) { | ||
if (typeof f === "object" && f[BISYM] === true) { | ||
//recycling existing batch item | ||
@@ -59,3 +54,3 @@ batchItem.recycled = true; | ||
} else { | ||
throw new Error("Unknown type of file added: ".concat(_typeof(f))); | ||
throw new Error(`Unknown type of file added: ${typeof f}`); | ||
} | ||
@@ -62,0 +57,0 @@ |
@@ -1,3 +0,3 @@ | ||
export var DEBUG_LOG_KEY = "__rpldy-logger-debug__"; | ||
export var BATCH_STATES = { | ||
export const DEBUG_LOG_KEY = "__rpldy-logger-debug__"; | ||
export const BATCH_STATES = { | ||
PENDING: "pending", | ||
@@ -11,3 +11,3 @@ ADDED: "added", | ||
}; | ||
export var FILE_STATES = { | ||
export const FILE_STATES = { | ||
PENDING: "pending", | ||
@@ -14,0 +14,0 @@ ADDED: "added", |
import { DEBUG_LOG_KEY } from "./consts"; | ||
import hasWindow from "./utils/hasWindow"; | ||
import { isProduction } from "./utils"; | ||
var isDebug; | ||
let isDebug; | ||
var isEnvDebug = function () { | ||
const isEnvDebug = () => { | ||
var _process, _process$env; | ||
@@ -12,3 +12,3 @@ | ||
var isDebugOn = function () { | ||
const isDebugOn = () => { | ||
if (typeof isDebug !== "boolean") { | ||
@@ -21,3 +21,3 @@ isDebug = isEnvDebug() || hasWindow() && ("location" in window && !!~window.location.search.indexOf("rpldy_debug=true") || window[DEBUG_LOG_KEY] === true); | ||
var setDebug = function (debugOn) { | ||
const setDebug = debugOn => { | ||
if (hasWindow()) { | ||
@@ -30,8 +30,6 @@ window[DEBUG_LOG_KEY] = debugOn; | ||
var debugLog = function () { | ||
const debugLog = (...args) => { | ||
if (isDebugOn()) { | ||
var _console; | ||
// eslint-disable-next-line no-console | ||
(_console = console).log.apply(_console, arguments); | ||
console.log(...args); | ||
} | ||
@@ -38,0 +36,0 @@ }; |
@@ -1,24 +0,8 @@ | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
import { debugLog } from "../logger"; | ||
export default (function (xhr) { | ||
var resHeaders; | ||
export default (xhr => { | ||
let resHeaders; | ||
try { | ||
resHeaders = xhr.getAllResponseHeaders().trim().split(/[\r\n]+/).reduce(function (res, line) { | ||
var _line$split = line.split(": "), | ||
_line$split2 = _slicedToArray(_line$split, 2), | ||
key = _line$split2[0], | ||
val = _line$split2[1]; | ||
resHeaders = xhr.getAllResponseHeaders().trim().split(/[\r\n]+/).reduce((res, line) => { | ||
const [key, val] = line.split(": "); | ||
res[key] = val; | ||
@@ -25,0 +9,0 @@ return res; |
@@ -1,4 +0,4 @@ | ||
var setHeaders = function (req, headers) { | ||
const setHeaders = (req, headers) => { | ||
if (headers) { | ||
Object.keys(headers).forEach(function (name) { | ||
Object.keys(headers).forEach(name => { | ||
if (headers[name] !== undefined) { | ||
@@ -11,21 +11,12 @@ req.setRequestHeader(name, headers[name]); | ||
var request = function (url, data) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var req = new XMLHttpRequest(); | ||
var pXhr = new Promise(function (resolve, reject) { | ||
req.onerror = function () { | ||
return reject(req); | ||
}; | ||
const request = (url, data, options = {}) => { | ||
const req = new XMLHttpRequest(); | ||
const pXhr = new Promise((resolve, reject) => { | ||
req.onerror = () => reject(req); | ||
req.ontimeout = function () { | ||
return reject(req); | ||
}; | ||
req.ontimeout = () => reject(req); | ||
req.onabort = function () { | ||
return reject(req); | ||
}; | ||
req.onabort = () => reject(req); | ||
req.onload = function () { | ||
return resolve(req); | ||
}; | ||
req.onload = () => resolve(req); | ||
@@ -32,0 +23,0 @@ req.open(options.method || "GET", url); |
@@ -1,29 +0,15 @@ | ||
var triggerCancellable = function (trigger, event) { | ||
var doTrigger = function (event) { | ||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
const triggerCancellable = (trigger, event, ...args) => { | ||
const doTrigger = (event, ...args) => new Promise((resolve, reject) => { | ||
const results = trigger(event, ...args); | ||
if (results && results.length) { | ||
Promise.all(results).catch(reject).then(resolvedResults => resolvedResults && resolve(!!~resolvedResults.findIndex(r => r === false))); | ||
} else { | ||
resolve(false); | ||
} | ||
}); | ||
return new Promise(function (resolve, reject) { | ||
var results = trigger.apply(void 0, [event].concat(args)); | ||
if (results && results.length) { | ||
Promise.all(results)["catch"](reject).then(function (resolvedResults) { | ||
return resolvedResults && resolve(!!~resolvedResults.findIndex(function (r) { | ||
return r === false; | ||
})); | ||
}); | ||
} else { | ||
resolve(false); | ||
} | ||
}); | ||
}; | ||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
return event ? doTrigger.apply(void 0, [event].concat(args)) : doTrigger; | ||
return event ? doTrigger(event, ...args) : doTrigger; | ||
}; | ||
export default triggerCancellable; |
@@ -1,37 +0,25 @@ | ||
var isEmpty = function (val) { | ||
return val === null || val === undefined; | ||
}; | ||
const isEmpty = val => val === null || val === undefined; | ||
export default (function (trigger, event) { | ||
var doTrigger = function (event) { | ||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
export default ((trigger, event, ...args) => { | ||
const doTrigger = (event, ...args) => new Promise((resolve, reject) => { | ||
const results = trigger(event, ...args); | ||
return new Promise(function (resolve, reject) { | ||
var results = trigger.apply(void 0, [event].concat(args)); | ||
if (results && results.length) { | ||
Promise.all(results).catch(reject).then(resolvedResults => { | ||
let result; | ||
if (results && results.length) { | ||
Promise.all(results)["catch"](reject).then(function (resolvedResults) { | ||
var result; | ||
if (resolvedResults) { | ||
while (isEmpty(result) && resolvedResults.length) { | ||
result = resolvedResults.pop(); | ||
} | ||
if (resolvedResults) { | ||
while (isEmpty(result) && resolvedResults.length) { | ||
result = resolvedResults.pop(); | ||
} | ||
} | ||
resolve(isEmpty(result) ? undefined : result); | ||
}); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}; | ||
resolve(isEmpty(result) ? undefined : result); | ||
}); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
return event ? doTrigger.apply(void 0, [event].concat(args)) : doTrigger; | ||
return event ? doTrigger(event, ...args) : doTrigger; | ||
}); |
@@ -9,5 +9,2 @@ import merge, { isMergeObj } from "./merge"; | ||
*/ | ||
export default (function (obj) { | ||
var mergeFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : merge; | ||
return isMergeObj(obj) ? mergeFn(Array.isArray(obj) ? [] : {}, obj) : obj; | ||
}); | ||
export default ((obj, mergeFn = merge) => isMergeObj(obj) ? mergeFn(Array.isArray(obj) ? [] : {}, obj) : obj); |
import isProduction from "./isProduction"; | ||
var devFreeze = function (obj) { | ||
return isProduction() ? obj : Object.freeze(obj); | ||
}; | ||
const devFreeze = obj => isProduction() ? obj : Object.freeze(obj); | ||
export default devFreeze; |
@@ -1,7 +0,3 @@ | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function (obj) { return typeof obj; }; } else { _typeof = function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
const hasWindow = () => typeof window === "object" && !!window.document; | ||
var hasWindow = function () { | ||
return (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && !!window.document; | ||
}; | ||
export default hasWindow; |
@@ -1,7 +0,5 @@ | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function (obj) { return typeof obj; }; } else { _typeof = function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
export default (function (obj) { | ||
export default (obj => { | ||
var _Object$getPrototypeO; | ||
return !!obj && _typeof(obj) === "object" && (((_Object$getPrototypeO = Object.getPrototypeOf(obj)) === null || _Object$getPrototypeO === void 0 ? void 0 : _Object$getPrototypeO.constructor.name) === "Object" || Object.getPrototypeOf(obj) === null); | ||
return !!obj && typeof obj === "object" && (((_Object$getPrototypeO = Object.getPrototypeOf(obj)) === null || _Object$getPrototypeO === void 0 ? void 0 : _Object$getPrototypeO.constructor.name) === "Object" || Object.getPrototypeOf(obj) === null); | ||
}); |
@@ -1,2 +0,2 @@ | ||
var isProduction = function () { | ||
const isProduction = () => { | ||
var _process, _process$env; | ||
@@ -3,0 +3,0 @@ |
@@ -1,10 +0,4 @@ | ||
var getPropsExtractor = function (prop) { | ||
var props = [].concat(prop); | ||
return function (arr) { | ||
return arr.map(function (i) { | ||
return props.map(function (p) { | ||
return i[p]; | ||
}).join(); | ||
}); | ||
}; | ||
const getPropsExtractor = prop => { | ||
const props = [].concat(prop); | ||
return arr => arr.map(i => props.map(p => i[p]).join()); | ||
}; | ||
@@ -17,12 +11,10 @@ /* | ||
var isSamePropInArrays = function (arr1, arr2, prop) { | ||
var diff = true; | ||
var propsExtractor = getPropsExtractor(prop); | ||
const isSamePropInArrays = (arr1, arr2, prop) => { | ||
let diff = true; | ||
const propsExtractor = getPropsExtractor(prop); | ||
if (arr1 && arr2 && arr1.length === arr2.length) { | ||
var props1 = propsExtractor(arr1), | ||
props2 = propsExtractor(arr2); | ||
diff = !!props1.find(function (p, i) { | ||
return p !== props2[i]; | ||
}); | ||
const props1 = propsExtractor(arr1), | ||
props2 = propsExtractor(arr2); | ||
diff = !!props1.find((p, i) => p !== props2[i]); | ||
} | ||
@@ -29,0 +21,0 @@ |
import isPlainObject from "./isPlainObject"; | ||
export var isMergeObj = function (obj) { | ||
return isPlainObject(obj) || Array.isArray(obj); | ||
}; | ||
export const isMergeObj = obj => isPlainObject(obj) || Array.isArray(obj); | ||
var getKeys = function (obj, options) { | ||
var keys = Object.keys(obj); | ||
const getKeys = (obj, options) => { | ||
const keys = Object.keys(obj); | ||
return options.withSymbols ? keys.concat(Object.getOwnPropertySymbols(obj)) : keys; | ||
}; | ||
var getMerge = function () { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var merge = function (target) { | ||
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
sources[_key - 1] = arguments[_key]; | ||
} | ||
const getMerge = (options = {}) => { | ||
const merge = (target, ...sources) => { | ||
if (target && sources.length) { | ||
sources.forEach(function (source) { | ||
sources.forEach(source => { | ||
if (source) { | ||
getKeys(source, options).forEach(function (key) { | ||
var prop = source[key]; | ||
getKeys(source, options).forEach(key => { | ||
const prop = source[key]; | ||
@@ -25,0 +17,0 @@ if (!options.predicate || options.predicate(key, prop)) { |
@@ -1,9 +0,7 @@ | ||
export default (function (obj, props) { | ||
return obj && Object.keys(obj).reduce(function (res, key) { | ||
if (~props.indexOf(key)) { | ||
res[key] = obj[key]; | ||
} | ||
export default ((obj, props) => obj && Object.keys(obj).reduce((res, key) => { | ||
if (~props.indexOf(key)) { | ||
res[key] = obj[key]; | ||
} | ||
return res; | ||
}, {}); | ||
}); | ||
return res; | ||
}, {})); |
{ | ||
"version": "0.11.4", | ||
"version": "0.11.5", | ||
"name": "@rpldy/shared", | ||
@@ -21,3 +21,3 @@ "description": "internal set of utils+types for react-uploady", | ||
"devDependencies": { | ||
"flow-bin": "^0.146.0" | ||
"flow-bin": "^0.147.0" | ||
}, | ||
@@ -31,3 +31,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "ffa687483c1ff9d6d2df3c992810b030943482b6" | ||
"gitHead": "39a78c4a9cf417433bd5989d65dc84f358952780" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37778
964