<commit_before># React Native Utils
[![npm version](https://badge.fury.io/js/rn-utils.svg)](https://badge.fury.io/js/rn-utils)

React Native Utilities is a package born out of the incessant rewriting of utility functions while developing scalable and maintainable React Native applications. It aims to be a repository that holds trivial yet useful utility functions that are most times copied over/recreated in every new React Native project.

## Installation
```
npm install rn-utils --save
```

## Utilities

### Dimensions
|  Function | Usage | Utility |
|-----------|-------|---------|
| getDeviceHeight | `RNUtils.getDeviceHeight()` | Returns the device's current viewport height. |
| getDeviceWidth | `RNUtils.getDeviceWidth()` | Returns the device's current viewport width. |

### Orientation
*Currently the only 3rd party package with native dependecies used by React Native Utilities is the [React Native Orientation](https://github.com/yamill/react-native-orientation) module. If you wish to use any of the Orientation functionalities of React Native Utils, remember to link its native dependencies.*
```
react-native link react-native-orientation
```

|  Function | Usage | Utility |
|-----------|-------|---------|
| addOrientationListener | `RNUtils.addOrientationListener((orientation) => this.setState({ orientation }))` | Creates an event listener that triggers whenever the orientation of the device changes. |
| getOrientation | `RNUtils.getOrientation()` | Function that returns the current device's orientation. It uses `getInitialOrientation` method from [React Native Orientation](https://github.com/yamill/react-native-orientation) module to allow for Async/Initial orientation checks. Orientation will either return LANDSCAPE or PORTRAIT. |
| isLandscape | `RNUtils.isLandscape(orientation)` | Helper that returns `true` if current device orientation is Landscape. The `orientation` argument must be passed. This is usually used with the `addOrientationListener` or `getOrientation` utility functions. |
| lockLandscape | `RNUtils.lockLandscape()` | Locks the device's viewport to the Landscape mode. Disables portrait. |
| lockPortrait | `RNUtils.lockPortrait()` | Locks the device's viewport to the Portrait mode. Disables landscape. |
| unlockOrientations | `RNUtils.unlockOrientations()` | Unlocks any previous locking behavior applied by `lockPortrait` or `lockLandscape`. |

### Dimensions

|  Function | Usage | Utility |
|-----------|-------|---------|
| getFontSize | `textHelpers.getFontSize(size)` | Returns a font size baed on size argument |
| getLineHeight | `textHelpers.getLineHeight(size)` | Returns a line height based on size argument |
| getFontStyles | `textHelpers.getFontStyles(size)` | Returns an object with a font size and line height based on size argument |

**Example Usage**

```
import TextHelpers from 'rn-utils'

const fontSizes = {small: 8, medium: 12};
const lineHeights = {small: 12, medium: 16};

const textHelpers = new TextHelpers(fontSizes, lineHeights);

const fontStyles = {
  ...textHelpers.getFontStyles('small');
}
```<commit_msg>chore: update dimensions to Text Helpers<commit_after># React Native Utils
[![npm version](https://badge.fury.io/js/rn-utils.svg)](https://badge.fury.io/js/rn-utils)

React Native Utilities is a package born out of the incessant rewriting of utility functions while developing scalable and maintainable React Native applications. It aims to be a repository that holds trivial yet useful utility functions that are most times copied over/recreated in every new React Native project.

## Installation
```
npm install rn-utils --save
```

## Utilities

### Dimensions
|  Function | Usage | Utility |
|-----------|-------|---------|
| getDeviceHeight | `RNUtils.getDeviceHeight()` | Returns the device's current viewport height. |
| getDeviceWidth | `RNUtils.getDeviceWidth()` | Returns the device's current viewport width. |

### Orientation
*Currently the only 3rd party package with native dependecies used by React Native Utilities is the [React Native Orientation](https://github.com/yamill/react-native-orientation) module. If you wish to use any of the Orientation functionalities of React Native Utils, remember to link its native dependencies.*
```
react-native link react-native-orientation
```

|  Function | Usage | Utility |
|-----------|-------|---------|
| addOrientationListener | `RNUtils.addOrientationListener((orientation) => this.setState({ orientation }))` | Creates an event listener that triggers whenever the orientation of the device changes. |
| getOrientation | `RNUtils.getOrientation()` | Function that returns the current device's orientation. It uses `getInitialOrientation` method from [React Native Orientation](https://github.com/yamill/react-native-orientation) module to allow for Async/Initial orientation checks. Orientation will either return LANDSCAPE or PORTRAIT. |
| isLandscape | `RNUtils.isLandscape(orientation)` | Helper that returns `true` if current device orientation is Landscape. The `orientation` argument must be passed. This is usually used with the `addOrientationListener` or `getOrientation` utility functions. |
| lockLandscape | `RNUtils.lockLandscape()` | Locks the device's viewport to the Landscape mode. Disables portrait. |
| lockPortrait | `RNUtils.lockPortrait()` | Locks the device's viewport to the Portrait mode. Disables landscape. |
| unlockOrientations | `RNUtils.unlockOrientations()` | Unlocks any previous locking behavior applied by `lockPortrait` or `lockLandscape`. |

### Text Helpers

|  Function | Usage | Utility |
|-----------|-------|---------|
| getFontSize | `textHelpers.getFontSize(size)` | Returns a font size baed on size argument |
| getLineHeight | `textHelpers.getLineHeight(size)` | Returns a line height based on size argument |
| getFontStyles | `textHelpers.getFontStyles(size)` | Returns an object with a font size and line height based on size argument |

**Example Usage**

```
import TextHelpers from 'rn-utils'

const fontSizes = {small: 8, medium: 12};
const lineHeights = {small: 12, medium: 16};

const textHelpers = new TextHelpers(fontSizes, lineHeights);

const fontStyles = {
  ...textHelpers.getFontStyles('small');
}
```
{'fraction_non_alphanumeric': 0.12349445961136984, 'fraction_numerical': 0.0025694555965954714, 'mean_word_length': 4.585650224215247, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 8, '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': '6009380', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1671, 'n_words': 618}