https://github.com/writetome51/error-if-not-populated-array
Function triggers error if argument is not an array with at least one item
https://github.com/writetome51/error-if-not-populated-array
Last synced: 6 months ago
JSON representation
Function triggers error if argument is not an array with at least one item
- Host: GitHub
- URL: https://github.com/writetome51/error-if-not-populated-array
- Owner: writetome51
- License: mit
- Created: 2019-04-08T22:46:59.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-08T22:47:11.000Z (almost 7 years ago)
- Last Synced: 2025-01-02T07:26:25.690Z (about 1 year ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# errorIfNotPopulatedArray(arg): void
Function triggers error if `arg` is not an array with at least one item.
## Examples
```
errorIfNotPopulatedArray([]);
// Error: "Input must be an array that is not empty"
errorIfNotPopulatedArray(8);
// Error: "Input must be array."
```
## Installation
`npm i error-if-not-populated-array`
## Loading
```ts
// if using TypeScript:
import { errorIfNotPopulatedArray } from 'error-if-not-populated-array';
// if using ES5 JavaScript:
var errorIfNotPopulatedArray =
require('error-if-not-populated-array').errorIfNotPopulatedArray;
```