<commit_before>// =============================================================================
// =ALEKSI - CONSTANTS
// =============================================================================

@import "sassy-maps";

$CONSTANTS: () !default;

// =const( $name )
// -----------------------------------------------------------------------------
/// Constant getter. Safely retrieves the value of a constant.
/// @author [<NAME>](http://hugogiraudel.com)
///
/// @param {string} $name - Name of the constant to retrieve.
///
/// @return {any} - The value of the constant.
/// @throw Error if constant doesn't exist.
///
/// @example scss
///   $foo: const('CSS_SIDES');
///     // => 'top' 'right' 'bottom' 'left'
///
/// @access public
/// @since 0.1.0

@function const( $name )
{
  @if type-of($name) != string {
    @return throw-error("const():: $name must be a string. Was #{inspect($name)}.");
  }

  @if not map-has-key($CONSTANTS, $name) {
    @return throw-error("Unknown constant #{$name}");
  }

  @return map-get($CONSTANTS, $name);
}

// =const( $name, $value )
// -----------------------------------------------------------------------------
/// Constant setter. Stores the given value in a constant and prevents existing
/// constants to be modified.
/// @author [<NAME>](http://hugogiraudel.com)
///
/// @param {string} $name - The name of the constant tp store.
/// @param {any} $value - The stored constant's value.
///
/// @throw Error if $name is not a string.
/// @throw Error if $name is not a full-caps name or contains hyphens.
/// @throw Error if $name is already a defined constant.
///
/// @example scss
///   @include const('HOURS_IN_DAY', 24);
///
/// @access public
/// @since 0.1.0

@mixin const( $name, $value )
{
  @if type-of($name) != string {
    @include throw-error('const():: $name must be string. Was #{inspect($name)}.');
  }

  @else if to-upper-case($name) != $name or str-index($name, '-') {
    @include throw-error('const():: Constant name #{inspect($name)} is not valid. Must be upper-case and without hyphens.');
  }

  @else if map-has-key($CONSTANTS, $name) {
    @include throw-error('Constant #{inspect($name)} already defined.');
  }

  $CONSTANTS: map-set($CONSTANTS, $name, $value) !global;
}<commit_msg>fix 'to-upper-case' string comparison in libsass<commit_after>// =============================================================================
// =ALEKSI - CONSTANTS
// =============================================================================

@import "sassy-maps";

$CONSTANTS: () !default;

// =const( $name )
// -----------------------------------------------------------------------------
/// Constant getter. Safely retrieves the value of a constant.
/// @author [<NAME>](http://hugogiraudel.com)
///
/// @param {string} $name - Name of the constant to retrieve.
///
/// @return {any} - The value of the constant.
/// @throw Error if constant doesn't exist.
///
/// @example scss
///   $foo: const('CSS_SIDES');
///     // => 'top' 'right' 'bottom' 'left'
///
/// @access public
/// @since 0.1.0

@function const( $name )
{
  @if type-of($name) != string {
    @return throw-error("const():: $name must be a string. Was #{inspect($name)}.");
  }

  @if not map-has-key($CONSTANTS, $name) {
    @return throw-error("Unknown constant #{$name}");
  }

  @return map-get($CONSTANTS, $name);
}

// =const( $name, $value )
// -----------------------------------------------------------------------------
/// Constant setter. Stores the given value in a constant and prevents existing
/// constants to be modified.
/// @author [<NAME>](http://hugogiraudel.com)
///
/// @param {string} $name - The name of the constant tp store.
/// @param {any} $value - The stored constant's value.
///
/// @throw Error if $name is not a string.
/// @throw Error if $name is not a full-caps name or contains hyphens.
/// @throw Error if $name is already a defined constant.
///
/// @example scss
///   @include const('HOURS_IN_DAY', 24);
///
/// @access public
/// @since 0.1.0

@mixin const( $name, $value )
{
  @if type-of($name) != string {
    @include throw-error('const():: $name must be string. Was #{inspect($name)}.');
  }

  @else if (unquote($name) != unquote(to-upper-case($name)) or str-index($name, '-') {
    @include throw-error('const():: Constant name #{inspect($name)} is not valid. Must be upper-case and without hyphens.');
  }

  @else if map-has-key($CONSTANTS, $name) {
    @include throw-error('Constant #{inspect($name)} already defined.');
  }

  $CONSTANTS: map-set($CONSTANTS, $name, $value) !global;
}
{'fraction_non_alphanumeric': 0.3133187772925764, 'fraction_numerical': 0.0034934497816593887, 'mean_word_length': 2.496946564885496, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '4217279', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1361, 'n_words': 415}