An open API service indexing awesome lists of open source software.

https://github.com/nath-green/utils

A collection of utils
https://github.com/nath-green/utils

Last synced: 2 months ago
JSON representation

A collection of utils

Awesome Lists containing this project

README

        

# utils

Collection of utils

- [formatUrlWithProtocol](#user-content-formaturlwithprotocol)
- [isEmptyObject](#user-content-isemptyobject)

## formatUrlWithProtocol

Returns formatted `url`

```js
import { formatUrlWithProtocol } from "@nath-green/utils";

const formattedUrl = formatUrlWithProtocol({
url: "www.test.co.uk",
secure: true,
});

// returns https://www.test.co.uk
```

### Parameters

An object of values

| Param | Type | Default | Description |
| ------ | ------- | ------- | ---------------------- |
| url | String | | URL to be formatted |
| secure | Boolean | `false` | To prefix with `https` |

---

## isEmptyObject

Returns a `boolean`

```js
import { isEmptyObject } from "@nath-green/utils";

const models = {};

const noModels = isEmptyObject(models);

// returns true
```

```js
import { isEmptyObject } from "@nath-green/utils";

const models = { latest: "Mustang", fastest: "Polo" };

const hasModels = !isEmptyObject(models);

// returns true
```

### Parameters

A single parameter

| Param | Type | Default | Description |
| ----- | ------ | ------- | ------------------- |
| obj | Object | | Object to be tested |