<commit_before># Node Version Manager
# Implemented as a bash function
# To use source this file from your bash profile
#
# Implemented by <NAME> <<EMAIL>>
# with much bash help from <NAME>

has() {
  type "$1" > /dev/null 2>&1
  return $?
}

# Make zsh glob matching behave same as bash
# This fixes the "zsh: no matches found" errors
if has "unsetopt"; then
  unsetopt nomatch 2>/dev/null
  NVM_CD_FLAGS="-q"
fi

# Auto detect the NVM_DIR
if [ ! -d "$NVM_DIR" ]; then
  if [ -n "$BASH_SOURCE" ]; then
    export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname ${BASH_SOURCE[0]:-$0}) > /dev/null && pwd)
  else
    export NVM_DIR=$HOME/.nvm
  fi
fi

DASH_E=""
[ -z "$(echo -n -e)" ] && DASH_E="-e"

# Setup mirror location if not already set
if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
  export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist"
fi

# Obtain nvm version from rc file
rc_nvm_version() {
  if [ -e .nvmrc ]; then
    RC_VERSION=`cat .nvmrc | head -n 1`
    echo "Found .nvmrc files with version <$RC_VERSION>"
  fi
}

# Expand a version using the version cache
nvm_version() {
  local PATTERN=$1
  local VERSION
  # The default version is the current one
  if [ ! "$PATTERN" ]; then
    PATTERN='current'
  fi

  VERSION=`nvm_ls $PATTERN`
  echo "$VERSION"

  if [ "$VERSION" = 'N/A' ]; then
    return
  fi
}

nvm_remote_version() {
  local PATTERN=$1
  local VERSION
  VERSION=`nvm_ls_remote $PATTERN | tail -n1`
  echo "$VERSION"

  if [ "$VERSION" = 'N/A' ]; then
    return
  fi
}

nvm_ls() {
  local PATTERN=$1
  local VERSIONS=''
  if [ "$PATTERN" = 'current' ]; then
    echo `node -v 2>/dev/null`
    return
  fi

  if [ -f "$NVM_DIR/alias/$PATTERN" ]; then
    nvm_version `cat $NVM_DIR/alias/$PATTERN`
    return
  fi
  # If it looks like an explicit version, don't do anything funny
  if [ `expr "$PATTERN" : "v[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*$"` != 0 ]; then
    VERSIONS="$PATTERN"
  else
    VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "v$PATTERN*" -exec basename '{}' ';' \
      | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
  fi
  if [ ! "$VERSIONS" ]; then
      echo "N/A"
      return
  fi
  printf "$VERSIONS\n"
  return
}

nvm_ls_remote() {
  local PATTERN=$1
  local VERSIONS
  if [ "$PATTERN" ]; then
    if echo "${PATTERN}" | \grep -v '^v' ; then
      PATTERN=v$PATTERN
    fi
  else
    PATTERN=".*"
  fi
  VERSIONS=`curl -s $NVM_NODEJS_ORG_MIRROR/ \
              | \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
              | \grep -w "${PATTERN}" \
              | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
  if [ ! "$VERSIONS" ]; then
    echo "N/A"
    return
  fi
  echo "$VERSIONS"
  return
}

nvm_checksum() {
  if [ "$1" = "$2" ]; then
    return
  elif [ -z $2 ]; then
    echo 'Checksums empty' #missing in raspberry pi binary
    return
  else
    echo 'Checksums do not match.'
    return 1
  fi
}

colorize_version() {
  echo $DASH_E "\033[0;34m$1\033[0m"
}<commit_msg>colorize output only if echo supports it<commit_after># Node Version Manager
# Implemented as a bash function
# To use source this file from your bash profile
#
# Implemented by <NAME> <<EMAIL>>
# with much bash help from <NAME>

has() {
  type "$1" > /dev/null 2>&1
  return $?
}

# Make zsh glob matching behave same as bash
# This fixes the "zsh: no matches found" errors
if has "unsetopt"; then
  unsetopt nomatch 2>/dev/null
  NVM_CD_FLAGS="-q"
fi

# Auto detect the NVM_DIR
if [ ! -d "$NVM_DIR" ]; then
  if [ -n "$BASH_SOURCE" ]; then
    export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname ${BASH_SOURCE[0]:-$0}) > /dev/null && pwd)
  else
    export NVM_DIR=$HOME/.nvm
  fi
fi

DASH_E=""
[ -z "$(echo -n -e)" ] && DASH_E="-e"

# Setup mirror location if not already set
if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
  export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist"
fi

# Obtain nvm version from rc file
rc_nvm_version() {
  if [ -e .nvmrc ]; then
    RC_VERSION=`cat .nvmrc | head -n 1`
    echo "Found .nvmrc files with version <$RC_VERSION>"
  fi
}

# Expand a version using the version cache
nvm_version() {
  local PATTERN=$1
  local VERSION
  # The default version is the current one
  if [ ! "$PATTERN" ]; then
    PATTERN='current'
  fi

  VERSION=`nvm_ls $PATTERN`
  echo "$VERSION"

  if [ "$VERSION" = 'N/A' ]; then
    return
  fi
}

nvm_remote_version() {
  local PATTERN=$1
  local VERSION
  VERSION=`nvm_ls_remote $PATTERN | tail -n1`
  echo "$VERSION"

  if [ "$VERSION" = 'N/A' ]; then
    return
  fi
}

nvm_ls() {
  local PATTERN=$1
  local VERSIONS=''
  if [ "$PATTERN" = 'current' ]; then
    echo `node -v 2>/dev/null`
    return
  fi

  if [ -f "$NVM_DIR/alias/$PATTERN" ]; then
    nvm_version `cat $NVM_DIR/alias/$PATTERN`
    return
  fi
  # If it looks like an explicit version, don't do anything funny
  if [ `expr "$PATTERN" : "v[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*$"` != 0 ]; then
    VERSIONS="$PATTERN"
  else
    VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "v$PATTERN*" -exec basename '{}' ';' \
      | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
  fi
  if [ ! "$VERSIONS" ]; then
      echo "N/A"
      return
  fi
  printf "$VERSIONS\n"
  return
}

nvm_ls_remote() {
  local PATTERN=$1
  local VERSIONS
  if [ "$PATTERN" ]; then
    if echo "${PATTERN}" | \grep -v '^v' ; then
      PATTERN=v$PATTERN
    fi
  else
    PATTERN=".*"
  fi
  VERSIONS=`curl -s $NVM_NODEJS_ORG_MIRROR/ \
              | \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
              | \grep -w "${PATTERN}" \
              | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
  if [ ! "$VERSIONS" ]; then
    echo "N/A"
    return
  fi
  echo "$VERSIONS"
  return
}

nvm_checksum() {
  if [ "$1" = "$2" ]; then
    return
  elif [ -z $2 ]; then
    echo 'Checksums empty' #missing in raspberry pi binary
    return
  else
    echo 'Checksums do not match.'
    return 1
  fi
}

colorize_version() {
  if [ -n "$DASH_E" ]; then
    echo $DASH_E "\033[0;34m$1\033[0m"
  else
    echo $1
  fi
}
{'fraction_non_alphanumeric': 0.16020321761219306, 'fraction_numerical': 0.017104149026248943, 'mean_word_length': 2.6728855721393034, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, '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': '3117032', 'n_tokens_mistral': 2485, 'n_tokens_neox': 2363, 'n_words': 676}