# random-item **Repository Path**: ArkTSCentralRepository/random-item ## Basic Information - **Project Name**: random-item - **Description**: random-item 是一个从数组中随机获取元素的工具库,支持单个或多个元素的随机抽取,现已完全适配为 ArkTS 文件。 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-21 - **Last Updated**: 2025-07-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # random-item 基于[random-item](https://www.npmjs.com/package/random-item)原库4.0.1版本进行适配, 所有功能代码已经转换为`ArkTS`文件 ## Install ```sh ohpm install random-item ``` --- ## Description > Get a random item from an array ## Usage ```typescript import randomItem from 'random-item'; randomItem(['🐴', '🦄', '🌈']); //=> '🦄' randomItem.multiple(['🐴', '🦄', '🌈'], 2); //=> ['🌈', '🦄'] ``` ## Related - [random-int](https://github.com/sindresorhus/random-int) - Generate a random integer - [random-float](https://github.com/sindresorhus/random-float) - Generate a random float - [random-obj-key](https://github.com/sindresorhus/random-obj-key) - Get a random key from an object - [random-obj-prop](https://github.com/sindresorhus/random-obj-prop) - Get a random property from an object - [unique-random](https://github.com/sindresorhus/unique-random) - Generate random numbers that are consecutively unique - [unique-random-array](https://github.com/sindresorhus/unique-random-array) - Get consecutively unique elements from an array - [crypto-random-string](https://github.com/sindresorhus/crypto-random-string) - Generate a cryptographically strong random string