# ★ Constructor

## `Range()`

Creates the [`Range`](https://docs.angular-package.dev/range-1/range) instance with a range of the given required [`min`](#min-min), [`max`](#max-max) and optional current [`value`](#value-number), [`step`](#step-step-1-asstep).

{% code title="range.class.ts" %}

```typescript
constructor(min: Min, max: Max, value?: number, step: Step = 1 as Step) {
  this.#maximum = new Maximum(max);
  this.#minimum = new Minimum(min);
  this.#step = step;
  // Sets the range value between the given `min` and `max`.
  this.value = value;
  // Define the `min` and `max` property.
  Object.defineProperties(this, {
    min: {
      value: min,
      enumerable: true,
      writable: false,
    },
    max: {
      value: max,
      enumerable: true,
      writable: false,
    },
  });
}
```

{% endcode %}

### Parameters

#### `min:`[<mark style="color:green;">`Min`</mark>](https://docs.angular-package.dev/range-1/generic-type-variables#range-less-than-min-max-step-greater-than)

The **minimum** range of generic type variable [`Min`](https://docs.angular-package.dev/range-1/generic-type-variables#range-less-than-min-max-step-greater-than) to set with a new [`Range`](https://docs.angular-package.dev/range-1/range) instance.

#### `max:`[<mark style="color:green;">`Max`</mark>](https://docs.angular-package.dev/range-1/generic-type-variables#range-less-than-min-max-step-greater-than-1)

The **maximum** range of generic type variable [`Max`](https://docs.angular-package.dev/range-1/generic-type-variables#range-less-than-min-max-step-greater-than-1) to set with a new [`Range`](https://docs.angular-package.dev/range-1/range) instance.

#### `value?:`[<mark style="color:green;">`number`</mark>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)

The optional value of the [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) type between the given [`min`](#min-min) and [`max`](#max-max) specifies the default value of a new [`Range`](https://docs.angular-package.dev/range-1/range) instance.

#### `step:`[<mark style="color:green;">`Step`</mark>](https://docs.angular-package.dev/range-1/generic-type-variables#range-less-than-min-max-step-greater-than-2)=`1 as`[<mark style="color:green;">`Step`</mark>](https://docs.angular-package.dev/range-1/generic-type-variables#range-less-than-min-max-step-greater-than-2)

Optional step of generic type variable [`Step`](https://docs.angular-package.dev/range-1/generic-type-variables#stepextendsnumber-1) to set with a new [`Range`](https://docs.angular-package.dev/range-1/range) instance, by default **`1`**.

{% hint style="info" %}
The step is used by the [`range`](https://docs.angular-package.dev/range-1/range/accessors/get-range) accessor, [`getRange()`](https://docs.angular-package.dev/range-1/range/methods/getrange) , [`getRangeOfStep()`](https://docs.angular-package.dev/range-1/range/methods/getrangeofstep) and [`stepByStep()`](https://docs.angular-package.dev/range-1/range/methods/stepbystep) methods to return the entire range and also by the [`valueDown()`](https://docs.angular-package.dev/range-1/range/methods/valuedown), [`valueUp()`](https://docs.angular-package.dev/range-1/range/methods/valueup) methods to respectively decrement, increment range value.
{% endhint %}

## Example usage

```typescript
// Example usage.
import { Range } from '@angular-package/range';

// Returns Range {min: 4, max: 27} of Range<4, 27, 1>
new Range(4, 27);

// Returns Range {min: 4, max: 27, value: 27} of Range<4, 27, 1>
new Range(4, 27, 27);

// Returns Range {min: 4, max: 27, value: 5} of Range<4, 27, 1.5>
new Range(4, 27, 5, 1.5);
```
