utilizes.one-or-all
TypeScript icon, indicating that this package has built-in type declarations

1.1.4 • Public • Published

oneOrAll

Return one when is have only one item, return all when is have more then one item

Usage: oneOrAll<T>(array: Array<T> | T): Array<T> | T

import { oneOrAll } from 'utilizes.one-or-all'

oneOrAll(['item']) // Return one when is have only one item
// Output: 'item'
oneOrAll(['item', 'item2']) // Return all when is have more then one item
// Output: ['item', 'item2']
oneOrAll('item') // Return the value when is have value that are not array
// Output: 'item'
oneOrAll([]) // Ignore when its not have an items
// Output: undefined

This module exported from utilizes project.

Package Sidebar

Install

npm i utilizes.one-or-all

Weekly Downloads

1

Version

1.1.4

License

MIT

Unpacked Size

7.15 kB

Total Files

5

Last publish

Collaborators

  • natqe3