<commit_before>import { undefined, Infinity } from './global';
import { isArray } from './alias';

export function indexOf<a>(as: readonly a[], a: a): number {
  return a === a
    ? as.indexOf(a)
    : as.findIndex(a => a !== a);
}

export function shift<a>(as: [a, ...a[]]): [a, a[]];
export function shift<a>(as: a[]): [a | undefined, a[]];
export function shift<a>(as: [a, ...a[]], count: number): [a[], a[]];
export function shift<a>(as: a[], count: number): [a[], a[]];
export function shift<a>(as: a[], count?: number): [a | undefined | a[], a[]] {
  if (count! < 0) throw new Error('Unexpected negative number');
  return count === undefined
    ? [as.shift(), as]
    : [splice(as, 0, count), as];
}
export function unshift<a>(as: Iterable<a>, bs: a[]): a[] {
  if (isArray(as)) {
    for (let i = as.length - 1; i >= 0; --i) {
      bs.unshift(as[i]);
    }
  }
  else {
    bs.unshift(...as);
  }
  return bs;
}
export function pop<a>(as: [a, ...a[]]): [a[], a];
export function pop<a>(as: a[]): [a[], a | undefined];
export function pop<a>(as: [a, ...a[]], count: number): [a[], a[]];
export function pop<a>(as: a[], count: number): [a[], a[]];
export function pop<a>(as: a[], count?: number): [a[], a | undefined | a[]] {
  if (count! < 0) throw new Error('Unexpected negative number');
  return count === undefined
    ? [as, as.pop()]
    : [as, splice(as, as.length - count, count)];
}
export function push<a>(as: a[], bs: Iterable<a>): a[] {
  if (isArray(bs)) {
    for (let i = 0; i < bs.length; ++i) {
      as.push(bs[i]);
    }
  }
  else {
    as.push(...bs);
  }
  return as;<commit_msg>Refactoring<commit_after>import { undefined, Infinity } from './global';
import { isArray } from './alias';

export function indexOf<a>(as: readonly a[], a: a): number {
  return a === a
    ? as.indexOf(a)
    : as.findIndex(a => a !== a);
}

export function shift<a>(as: [a, ...a[]]): [a, a[]];
export function shift<a>(as: a[]): [a | undefined, a[]];
export function shift<a>(as: [a, ...a[]], count: number): [a[], a[]];
export function shift<a>(as: a[], count: number): [a[], a[]];
export function shift<a>(as: a[], count?: number): [a | undefined | a[], a[]] {
  if (count! < 0) throw new Error('Unexpected negative number');
  return count === undefined
    ? [as.shift(), as]
    : [splice(as, 0, count), as];
}
export function unshift<a>(as: Iterable<a> | ArrayLike<a>, bs: a[]): a[] {
  if ('length' in as || isArray(as)) {
    for (let i = as.length - 1; i >= 0; --i) {
      bs.unshift(as[i]);
    }
  }
  else {
    bs.unshift(...as);
  }
  return bs;
}
export function pop<a>(as: [a, ...a[]]): [a[], a];
export function pop<a>(as: a[]): [a[], a | undefined];
export function pop<a>(as: [a, ...a[]], count: number): [a[], a[]];
export function pop<a>(as: a[], count: number): [a[], a[]];
export function pop<a>(as: a[], count?: number): [a[], a | undefined | a[]] {
  if (count! < 0) throw new Error('Unexpected negative number');
  return count === undefined
    ? [as, as.pop()]
    : [as, splice(as, as.length - count, count)];
}
export function push<a>(as: a[], bs: Iterable<a> | ArrayLike<a>): a[] {
  if ('length' in bs || isArray(bs)) {
    for (let i = 0; i < bs.length; ++i) {
      as.push(bs[i]);
    }
  }
  else {
    for (const b of bs) {
      as.push(b);
    }
  }
  return as;
{'fraction_non_alphanumeric': 0.24698431845597105, 'fraction_numerical': 0.0036188178528347406, 'mean_word_length': 3.4167776298268975, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 39, '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': '2700910', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1255, 'n_words': 380}