# static createFrom()

## `Range.createFrom()`

Creates the [`Range`](/range/overview.md) instance from the given random [`numbers`](#numbers-number) and the [`step`](#step-step).

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

```typescript
public static createFrom<Step extends number = 1>(
  numbers: number[],
  step: Step = 1 as Step
): Range<number, number, Step> {
  return Range.create(
    Math.min.apply(0, numbers),
    Math.max.apply(0, numbers),
    step
  );
}
```

{% endcode %}

### Generic type variables

#### <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) indicates the range step type of a new [`Range`](/range/overview.md) instance.

### Parameters

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

An [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of numbers to find a range and create a new instance.

#### `step:`<mark style="color:green;">`Step`</mark>

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

### Return type

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

The **return type** is the [`Range`](/range/overview.md) object that takes generic type variable [`Step`](#stepextendsnumber-1).

### Returns

The **return value** is the [`Range`](/range/overview.md) instance created from the given required random [numbers](#numbers-number) and the optional [step](#step-step).

## Example usage

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

// Returns Range {min: 4, max: 27} of type Range<number, number, 1>.
Range.createFrom([12, 14, 5, 23, 14, 27, 17, 4, 11, 12]);

// Returns Range {min: 4, max: 27} of type Range<number, number, 1.5>.
Range.createFrom([12, 14, 5, 23, 14, 27, 17, 4, 11, 12]);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://range.angular-package.dev/range/methods/static-createfrom.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
