<commit_before>import EncodeHelper from './common/helpers'
import { isArray, isInt } from './common/utils'

import AtomicInt32 from './atomic/int32'
import AtomicString from './atomic/string'
import AtomicTimetag from './atomic/timetag'
import Message from './message'

/** OSC Bundle string */
export const BUNDLE_TAG = '#bundle'

/**
 * An OSC Bundle consist of a Timetag and one or many Bundle Elements.
 * The elements are either OSC Messages or more OSC Bundles
 */
export default class Bundle {
  /**
   * Create a Bundle instance
   * @param {...*} [args] Timetag and elements. See examples for options
   *
   * @example
   * const bundle = new Bundle(new Date() + 500)
   *
   * @example
   * const message = new Message('/test/path', 51.2)
   * const anotherBundle = new Bundle([message], Date.now() + 1500)
   *
   * @example
   * const message = new Message('/test/path', 51.2)
   * const anotherMessage = new Message('/test/message', 'test', 12)
   * const anotherBundle = new Bundle(message, anotherMessage)
   */
  constructor(...args) {
    /**
     * @type {number} offset
     * @private
     */
    this.offset = 0
    /** @type {AtomicTimetag} timetag */
    this.timetag = new AtomicTimetag()
    /** @type {array} bundleElements */
    this.bundleElements = []

    if (args.length > 0) {
      // first argument is an Date or js timestamp (number)
      if (args[0] instanceof Date || isInt(args[0])) {
        this.timetag = new AtomicTimetag(args[0])
      } else if (isArray(args[0])) {
        // first argument is an Array of Bundle elements
        args[0].forEach((item) => {
          this.add(item)
        })

        // second argument is an Date or js timestamp (number)
        if (args.length > 1 && (args[1] instanceof Date || isInt(args[0]))) {
          this.timetag = new AtomicTimetag(args[1])
        }
      } else {
        // take all arguments as Bundle elements
        args.forEach((item) => {
          this.add(item)
        })
      }
    }<commit_msg>Fix bundle timestamp as second arg to bundle contructor<commit_after>import EncodeHelper from './common/helpers'
import { isArray, isInt } from './common/utils'

import AtomicInt32 from './atomic/int32'
import AtomicString from './atomic/string'
import AtomicTimetag from './atomic/timetag'
import Message from './message'

/** OSC Bundle string */
export const BUNDLE_TAG = '#bundle'

/**
 * An OSC Bundle consist of a Timetag and one or many Bundle Elements.
 * The elements are either OSC Messages or more OSC Bundles
 */
export default class Bundle {
  /**
   * Create a Bundle instance
   * @param {...*} [args] Timetag and elements. See examples for options
   *
   * @example
   * const bundle = new Bundle(new Date() + 500)
   *
   * @example
   * const message = new Message('/test/path', 51.2)
   * const anotherBundle = new Bundle([message], Date.now() + 1500)
   *
   * @example
   * const message = new Message('/test/path', 51.2)
   * const anotherMessage = new Message('/test/message', 'test', 12)
   * const anotherBundle = new Bundle(message, anotherMessage)
   */
  constructor(...args) {
    /**
     * @type {number} offset
     * @private
     */
    this.offset = 0
    /** @type {AtomicTimetag} timetag */
    this.timetag = new AtomicTimetag()
    /** @type {array} bundleElements */
    this.bundleElements = []

    if (args.length > 0) {
      // first argument is an Date or js timestamp (number)
      if (args[0] instanceof Date || isInt(args[0])) {
        this.timetag = new AtomicTimetag(args[0])
      } else if (isArray(args[0])) {
        // first argument is an Array of Bundle elements
        args[0].forEach((item) => {
          this.add(item)
        })

        // second argument is an Date or js timestamp (number)
        if (args.length > 1 && (args[1] instanceof Date || isInt(args[1]))) {
          this.timetag = new AtomicTimetag(args[1])
        }
      } else {
        // take all arguments as Bundle elements
        args.forEach((item) => {
          this.add(item)
        })
      }
    }
{'fraction_non_alphanumeric': 0.1348148148148148, 'fraction_numerical': 0.014814814814814815, 'mean_word_length': 2.5318221447253704, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5780325', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1213, 'n_words': 380}