<commit_before>import type from "@unction/type"
import isIterable from "@unction/isiterable"
import xstream from "xstream"

export default function mergeRight (left: IterableType): Function {
  if (!isIterable(left)) {
    throw new Error("left is not an iterable")
  }

  const leftType = type(left)

  return function mergeRightLeft (right: IterableType): IterableType {
    if (!isIterable(right)) {
      throw new Error("right was not an iterable")
    }

    if (left.constructor.name !== right.constructor.name) {
      throw new Error("left and right weren't the same type")
    }

    switch (leftType) {
      case "Array": {
        return [
          ...left,
          ...right,
        ]
      }
      case "Object": {
        return {
          ...left,
          ...right,
        }
      }
      case "Map": {
        return new Map()
      }
      case "WeakMap": {
        return new WeakMap()
      }
      case "Set": {
        return new Set()
      }
      case "WeakSet": {
        return new WeakSet()
      }
      case "Stream": {
        return new xstream.merge(left, right)
      }

      default: {
        throw new Error(`left wasn't an iterable type we know how to merge: ${leftType}`)
      }
    }
  }
}<commit_msg>argh, totally wrong syntax<commit_after>import type from "@unction/type"
import isIterable from "@unction/isiterable"
import xstream from "xstream"

export default function mergeRight (left: IterableType): Function {
  if (!isIterable(left)) {
    throw new Error("left is not an iterable")
  }

  const leftType = type(left)

  return function mergeRightLeft (right: IterableType): IterableType {
    if (!isIterable(right)) {
      throw new Error("right was not an iterable")
    }

    if (left.constructor.name !== right.constructor.name) {
      throw new Error("left and right weren't the same type")
    }

    switch (leftType) {
      case "Array": {
        return [
          ...left,
          ...right,
        ]
      }
      case "Object": {
        return {
          ...left,
          ...right,
        }
      }
      case "Map": {
        return new Map()
      }
      case "WeakMap": {
        return new WeakMap()
      }
      case "Set": {
        return new Set()
      }
      case "WeakSet": {
        return new WeakSet()
      }
      case "Stream": {
        return xstream.merge(left, right)
      }

      default: {
        throw new Error(`left wasn't an iterable type we know how to merge: ${leftType}`)
      }
    }
  }
}
{'fraction_non_alphanumeric': 0.11907606531262445, 'fraction_numerical': 0.0, 'mean_word_length': 1.8840413318025258, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6245594', 'n_tokens_mistral': 755, 'n_tokens_neox': 731, 'n_words': 222}