@rpldy/shared
Advanced tools
Comparing version 1.3.0-rc.1 to 1.3.0-rc.2
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports.getIsBatchItem = exports.default = void 0; | ||
@@ -26,7 +26,14 @@ var _consts = require("./consts"); | ||
const getIsBatchItem = obj => { | ||
return typeof obj === "object" && obj.id && obj.batchId && obj[BISYM] === true; | ||
}; | ||
exports.getIsBatchItem = getIsBatchItem; | ||
const createBatchItem = function (f, batchId) { | ||
let isPending = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
iCounter += f.id && f.batchId ? 0 : 1; //keep existing id for recycled items | ||
const isAlreadyBatchItem = getIsBatchItem(f); | ||
iCounter += isAlreadyBatchItem ? 0 : 1; //keep existing id for recycled items | ||
const id = f.id && f.batchId ? f.id : `${batchId}.item-${iCounter}`, | ||
const id = isAlreadyBatchItem && f.id ? f.id : `${batchId}.item-${iCounter}`, | ||
state = isPending ? _consts.FILE_STATES.PENDING : _consts.FILE_STATES.ADDED; | ||
@@ -40,4 +47,5 @@ let batchItem = { | ||
loaded: 0, | ||
recycled: false, | ||
previousBatch: null | ||
recycled: isAlreadyBatchItem, | ||
// $FlowIssue[prop-missing] - flow just doesnt understand... | ||
previousBatch: isAlreadyBatchItem ? f.batchId : null | ||
}; | ||
@@ -50,6 +58,4 @@ Object.defineProperty(batchItem, BISYM, { | ||
if (typeof f === "object" && f[BISYM] === true) { | ||
//recycling existing batch item | ||
batchItem.recycled = true; | ||
batchItem.previousBatch = f.batchId; | ||
if (isAlreadyBatchItem) { | ||
// $FlowIssue[prop-missing] - flow just doesnt understand... | ||
f = f.file || f.url; | ||
@@ -56,0 +62,0 @@ } |
@@ -36,2 +36,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "getIsBatchItem", { | ||
enumerable: true, | ||
get: function () { | ||
return _batchItem.getIsBatchItem; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getMerge", { | ||
@@ -155,3 +161,3 @@ enumerable: true, | ||
var _batchItem = _interopRequireDefault(require("./batchItem")); | ||
var _batchItem = _interopRequireWildcard(require("./batchItem")); | ||
@@ -158,0 +164,0 @@ var _request = _interopRequireWildcard(require("./request")); |
@@ -17,7 +17,12 @@ import { FILE_STATES } from "./consts"; | ||
const getIsBatchItem = obj => { | ||
return typeof obj === "object" && obj.id && obj.batchId && obj[BISYM] === true; | ||
}; | ||
const createBatchItem = function (f, batchId) { | ||
let isPending = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
iCounter += f.id && f.batchId ? 0 : 1; //keep existing id for recycled items | ||
const isAlreadyBatchItem = getIsBatchItem(f); | ||
iCounter += isAlreadyBatchItem ? 0 : 1; //keep existing id for recycled items | ||
const id = f.id && f.batchId ? f.id : `${batchId}.item-${iCounter}`, | ||
const id = isAlreadyBatchItem && f.id ? f.id : `${batchId}.item-${iCounter}`, | ||
state = isPending ? FILE_STATES.PENDING : FILE_STATES.ADDED; | ||
@@ -31,4 +36,5 @@ let batchItem = { | ||
loaded: 0, | ||
recycled: false, | ||
previousBatch: null | ||
recycled: isAlreadyBatchItem, | ||
// $FlowIssue[prop-missing] - flow just doesnt understand... | ||
previousBatch: isAlreadyBatchItem ? f.batchId : null | ||
}; | ||
@@ -41,6 +47,4 @@ Object.defineProperty(batchItem, BISYM, { | ||
if (typeof f === "object" && f[BISYM] === true) { | ||
//recycling existing batch item | ||
batchItem.recycled = true; | ||
batchItem.previousBatch = f.batchId; | ||
if (isAlreadyBatchItem) { | ||
// $FlowIssue[prop-missing] - flow just doesnt understand... | ||
f = f.file || f.url; | ||
@@ -60,2 +64,3 @@ } | ||
export default createBatchItem; | ||
export default createBatchItem; | ||
export { getIsBatchItem }; |
@@ -7,8 +7,8 @@ import invariant from "invariant"; | ||
import triggerUpdater from "./triggerUpdater"; | ||
import createBatchItem from "./batchItem"; | ||
import createBatchItem, { getIsBatchItem } from "./batchItem"; | ||
import request, { parseResponseHeaders } from "./request"; | ||
export { BATCH_STATES, FILE_STATES, //one source for invariant to all other packages | ||
invariant, //one source for throttle to all other packages | ||
throttle, logger, triggerCancellable, triggerUpdater, createBatchItem, request, parseResponseHeaders }; | ||
throttle, logger, triggerCancellable, triggerUpdater, createBatchItem, getIsBatchItem, request, parseResponseHeaders }; | ||
export { //cant use * because of flow | ||
isFunction, isPlainObject, isSamePropInArrays, devFreeze, merge, getMerge, clone, pick, hasWindow, isProduction, isPromise, scheduleIdleWork, isEmpty } from "./utils"; |
{ | ||
"version": "1.3.0-rc.1", | ||
"version": "1.3.0-rc.2", | ||
"name": "@rpldy/shared", | ||
@@ -35,3 +35,3 @@ "description": "internal set of utils+types for react-uploady", | ||
}, | ||
"gitHead": "254010eb15751d3adf6f57d0d9fbfe8b2c341617" | ||
"gitHead": "c1be3150aff54efc11a856ae8d5735c7e4f28c75" | ||
} |
@@ -150,1 +150,3 @@ export type Destination = { | ||
export const request: (url: string, data?: unknown, options?: RequestOptions) => Promise<XMLHttpRequest>; | ||
export const getIsBatchItem: (obj: unknown) => boolean; |
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
45335
1136