How to use the clone.default function in clone

To help you get started, we’ve selected a few clone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thundernet8 / StarCabinet / src / renderer / rxdb / dbExtension.ts View on Github external
const upsertWithFields = async (json, fields: string[] = []) => {
        json = clone(json);
        const primary = json[$this.schema.primaryPath];
        if (!primary) {
            throw new Error("RxCollection.upsertWithFields() does not work without primary");
        }

        const existing = await $this.findOne(primary).exec();
        if (existing) {
            for (let prop in json) {
                if (json.hasOwnProperty(prop) && fields.indexOf(prop) < 0) {
                    delete json[prop];
                }
            }

            const data = existing._data;
            json = Object.assign({}, data, json);
            json._rev = existing._rev;
github pubkey / rxdb / src / util.ts View on Github external
function recursiveDeepCopy(o: T): T {
    if (!o) return o;
    return deepClone(o, false);
}
export const clone = recursiveDeepCopy;
github pubkey / rxdb / dist / es / util.js View on Github external
function recursiveDeepCopy(o) {
  if (!o) return o;
  return deepClone(o, false);
}
github thundernet8 / StarCabinet / src / renderer / rxdb / dbExtension.ts View on Github external
const upsertExcludeFields = async (json, fields = []) => {
        json = clone(json);
        const primary = json[$this.schema.primaryPath];
        if (!primary) {
            throw new Error("RxCollection.upsertExcludeFields() does not work without primary");
        }

        const existing = await $this.findOne(primary).exec();
        if (existing) {
            fields.forEach(field => {
                delete json[field];
            });
            const data = Object.assign({}, existing._data, json);
            data._rev = existing._rev;
            existing._data = data;
            await existing.save();
            return existing;
        } else {

clone

deep cloning of objects and arrays

MIT
Latest version published 7 years ago

Package Health Score

70 / 100
Full package analysis