# static create()

## `Range.create()`

The static `create()` method returns a new instance of [`Range`](https://range.angular-package.dev/range) 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
public static create<
  Min extends number,
  Max extends number,
  Step extends number = 1
>(min: Min, max: Max, value?: number, step?: Step): Range<Min, Max, Step> {
  return new this(min, max, value, step);
}
```

{% endcode %}

### Generic type variables

#### <mark style="color:green;">`Min`</mark>`extends`[<mark style="color:green;">`number`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#number)

A generic type variable constrained by the [`number`](https://www.typescriptlang.org/docs/handbook/basic-types.html#number), by default of the value **captured** from the supplied [`min`](#min-min) indicates the **minimum** range type of a new [`Range`](https://range.angular-package.dev/range) instance.

#### <mark style="color:green;">`Max`</mark>`extends`[<mark style="color:green;">`number`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#number)

A generic type variable constrained by the [`number`](https://www.typescriptlang.org/docs/handbook/basic-types.html#number), by default of the value **captured** from the supplied [`max`](#max-max) indicates the **maximum** range type of a new [`Range`](https://range.angular-package.dev/range) instance.

#### <mark style="color:green;">`Step`</mark>`extends`[<mark style="color:green;">`number`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#number)`= 1`

A generic type variable constrained by the [`number`](https://www.typescriptlang.org/docs/handbook/basic-types.html#number), by default of the value equal to **`1`**, optionally **captured** from the supplied [`step`](#step-step-1-asstep) indicates the range step type of a new [`Range`](https://range.angular-package.dev/range) instance.

### Parameters

#### `min:`[<mark style="color:green;">`Min`</mark>](#minextendsnumber)

The **minimum** range of generic type variable [`Min`](#minextendsnumber) to set with a new [`Range`](https://range.angular-package.dev/range) instance.

#### `max:`[<mark style="color:green;">`Max`</mark>](#maxextendsnumber)

The **maximum** range of generic type variable [`Max`](#maxextendsnumber) to set with a new [`Range`](https://range.angular-package.dev/range) instance.

#### `value?:`[<mark style="color:green;">`number`</mark>](https://www.typescriptlang.org/docs/handbook/basic-types.html#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://range.angular-package.dev/range) instance.

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

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

### Return type

#### `Range<`[<mark style="color:green;">`Min`</mark>](#minextendsnumber)`,`[<mark style="color:green;">`Max`</mark>](#maxextendsnumber)`,`[<mark style="color:green;">`Step`</mark>](#stepextendsnumber-1)`>`

The **return type** is the [`Range`](https://range.angular-package.dev/range) object that takes generic type variable [`Min`](#minextendsnumber), [`Max`](#maxextendsnumber) and [`Step`](#stepextendsnumber-1).

### Returns

The **return value** is the [`Range`](https://range.angular-package.dev/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).

## Example usage

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

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

// Returns Range {min: 4, max: 27} of Range<4, 27, 1.5>
Range.create(4, 27, undefined, 1.5);

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