How to use fast-copy - 10 common examples

To help you get started, we’ve selected a few fast-copy 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 DestinyItemManager / DIM / src / app / inventory / item-move-service.ts View on Github external
sourceItem = copy(sourceItem);
          source.addItem(sourceItem);
        }

        removeAmount -= amountToRemove;
      }

      // Add inventory to the target (destination)
      let targetItem = item;
      while (addAmount > 0) {
        targetItem = targetItems.shift()!;

        if (!targetItem) {
          targetItem = item;
          if (!removedSourceItem) {
            targetItem = copy(item);
            targetItem.index = createItemIndex(targetItem);
          }
          removedSourceItem = false; // only move without cloning once
          targetItem.amount = 0; // We'll increment amount below
          if (targetItem.location.inPostmaster) {
            targetItem.location = targetItem.bucket;
          }
          target.addItem(targetItem);
        } else {
          // Remove and replace with a copy so the reference updates for Redux
          target.removeItem(targetItem);
          targetItem = copy(targetItem);
          target.addItem(targetItem);
        }

        const amountToAdd = Math.min(addAmount, targetItem.maxStackSize - targetItem.amount);
github DestinyItemManager / DIM / src / app / loadout / LoadoutDrawer.tsx View on Github external
private add = (item: DimItem, e?: MouseEvent, equip?: boolean) => {
    const { loadout } = this.state;
    if (!loadout) {
      return;
    }
    if (item.canBeInLoadout()) {
      const clone = copy(item);

      const discriminator = clone.type.toLowerCase();
      const typeInventory = (loadout.items[discriminator] = loadout.items[discriminator] || []);

      clone.amount = Math.min(clone.amount, e?.shiftKey ? 5 : 1);

      const dupe = typeInventory.find((i) => i.hash === clone.hash && i.id === clone.id);

      let maxSlots = 10;
      if (item.type === 'Material') {
        maxSlots = 20;
      } else if (item.type === 'Consumable') {
        maxSlots = 19;
      }

      if (!dupe) {
github DestinyItemManager / DIM / src / app / loadout / auto-loadouts.ts View on Github external
      finalItems[type.toLowerCase()] = items.map((i, ..._args) => copy(i));
    }
github DestinyItemManager / DIM / src / app / infuse / infuse.component.ts View on Github external
vm.infused = target.primStat.value;

      if (vm.source!.destinyVersion === 2) {
        vm.infused = target.basePower + (source.primStat.value - source.basePower);
      } else if (source.bucket.sort === 'General') {
        vm.wildcardMaterialCost = 2;
        vm.wildcardMaterialHash = 937555249;
      } else if (source.primStat.stat.statIdentifier === 'STAT_DAMAGE') {
        vm.wildcardMaterialCost = 10;
        vm.wildcardMaterialHash = 1898539128;
      } else {
        vm.wildcardMaterialCost = 10;
        vm.wildcardMaterialHash = 1542293174;
      }

      vm.result = copy(vm.source);
      vm.result.primStat.value = vm.infused;
    },
github DestinyItemManager / DIM / src / app / loadout / LoadoutDrawer.tsx View on Github external
private handleLoadOutSaveResult = (clashingLoadout: Loadout | undefined) => {
    if (clashingLoadout) {
      this.setState({ clashingLoadout: copy(clashingLoadout) });
    } else {
      this.close();
    }
  };
github DestinyItemManager / DIM / src / app / loadout / loadout-utils.ts View on Github external
_.forIn(items, (item, type) => {
    const itemCopy = copy(item);
    itemCopy.equipped = true;
    finalItems[type.toLowerCase()] = [itemCopy];
  });
github DestinyItemManager / DIM / src / app / loadout / LoadoutPopup.tsx View on Github external
export function filterLoadoutToEquipped(loadout: Loadout) {
  const filteredLoadout = copy(loadout);
  filteredLoadout.items = _.mapValues(filteredLoadout.items, (items) =>
    items.filter((i) => i.equipped)
  );
  return filteredLoadout;
}
github DestinyItemManager / DIM / src / app / destiny1 / vendors / vendor.service.ts View on Github external
function mergeVendors([firstVendor, ...otherVendors]: Vendor[]) {
    const mergedVendor = copy(firstVendor);

    otherVendors.forEach((vendor) => {
      Object.assign(firstVendor.cacheKeys, vendor.cacheKeys);

      vendor.categories.forEach((category) => {
        const existingCategory = mergedVendor.categories.find((c) => c.title === category.title);
        if (existingCategory) {
          mergeCategory(existingCategory, category);
        } else {
          mergedVendor.categories.push(category);
        }
      });
    });

    mergedVendor.allItems = mergedVendor.categories.map((i) => i.saleItems).flat();
github prisma / photonjs / packages / photon-generate / archive / benchmark-copy.ts View on Github external
.add('fast-copy', () => {
    copy(dmmfDocument)
  })
  .add('fast-clone', () => {

fast-copy

A blazing fast deep object copier

MIT
Latest version published 8 months ago

Package Health Score

74 / 100
Full package analysis

Popular fast-copy functions