Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return params.map(function (param) {
if (isWhat.isAnyObject(param) && !isWhat.isPlainObject(param)) {
// @ts-ignore
return String(param.constructor.name) + String(param.id);
}
return String(param);
}).join();
}
function convertTimestamps(originVal, targetVal) {
if (originVal === '%convertTimestamp%') {
// firestore timestamps
// @ts-ignore
if (isWhat.isAnyObject(targetVal) && !isWhat.isPlainObject(targetVal) && isWhat.isFunction(targetVal.toDate)) {
// @ts-ignore
return targetVal.toDate();
}
// strings
if (isWhat.isString(targetVal) && isWhat.isDate(new Date(targetVal))) {
return new Date(targetVal);
}
}
return targetVal;
}
/**
function isArrayHelper(value) {
// this is bugged in vuex actions, I DONT KNOW WHY
// return (
// value instanceof ArrayUnion ||
// value instanceof ArrayRemove
// )
return (isWhat.isAnyObject(value) &&
!isWhat.isPlainObject(value) &&
// @ts-ignore
value.isArrayHelper === true);
}
function isArrayHelper(value) {
// this is bugged in vuex actions, I DONT KNOW WHY
// return (
// value instanceof ArrayUnion ||
// value instanceof ArrayRemove
// )
return (isWhat.isAnyObject(value) &&
!isWhat.isPlainObject(value) &&
// @ts-ignore
value.isArrayHelper === true);
}
export function grabUntilApiLimit (
syncStackProp: string,
count: number,
maxCount: number,
state: IPluginState
): any[] {
let targets = state._sync.syncStack[syncStackProp]
// Check if there are more than maxCount batch items already
if (count >= maxCount) {
// already at maxCount or more, leave items in syncstack, and don't add anything to batch
targets = []
} else {
// Convert to array if targets is an object (eg. updates)
const targetIsObject = isPlainObject(targets)
if (targetIsObject) {
targets = Object.values(targets)
}
// Batch supports only until maxCount items
const grabCount = maxCount - count
const targetsOK = targets.slice(0, grabCount)
let targetsLeft = targets.slice(grabCount)
// Put back the remaining items over maxCount
if (targetIsObject) {
targetsLeft = Object.values(targetsLeft)
.reduce((carry, update: AnyObject) => {
const id = update.id
carry[id] = update
return carry
}, {})
}
test('store set up', async t => {
t.true(isPlainObject(box.pokemon))
})
function setDefaultValues (obj, defaultValues) {
if (!isWhat.isPlainObject(defaultValues))
console.error('[vuex-easy-firestore] Trying to merge target:', obj, 'onto a non-object (defaultValues):', defaultValues);
if (!isWhat.isPlainObject(obj))
console.error('[vuex-easy-firestore] Trying to merge a non-object:', obj, 'onto the defaultValues:', defaultValues);
var result = merge({ extensions: [convertTimestamps] }, defaultValues, obj);
return findAndReplaceAnything.findAndReplace(result, '%convertTimestamp%', null, { onlyPlainObjects: true });
}
function getValueFromPayloadPiece(payloadPiece) {
if (isWhat.isPlainObject(payloadPiece) &&
!payloadPiece.id &&
Object.keys(payloadPiece).length === 1 &&
isWhat.isPlainObject(payloadPiece[Object.keys(payloadPiece)[0]])) {
return Object.values(payloadPiece)[0];
}
return payloadPiece;
}
function getId(payloadPiece, conf, path, fullPayload) {
if (isWhat.isString(payloadPiece))
return payloadPiece;
if (isWhat.isPlainObject(payloadPiece)) {
if ('id' in payloadPiece)
return payloadPiece.id;
var keys = Object.keys(payloadPiece);
if (keys.length === 1)
return keys[0];
}
return '';
}
/**
objectProps.forEach(function (prop) {
var _prop = (prop === 'defaultValues')
? config.sync[prop]
: config[prop];
if (!isPlainObject(_prop))
errors.push("`" + prop + "` should be an Object, but is not.");
});
var stringProps = ['firestorePath', 'firestoreRefType', 'moduleName'];