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
- Host: GitHub
- URL: https://github.com/nath-green/utils
- Owner: nath-green
- License: mit
- Created: 2021-03-12T07:59:03.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-12T08:34:47.000Z (about 4 years ago)
- Last Synced: 2025-03-01T21:04:19.239Z (3 months ago)
- Language: JavaScript
- Size: 50.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 |