Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

random-item

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-item - npm Package Compare versions

Comparing version
3.0.0
to
3.1.0
+27
-10
index.d.ts

@@ -1,14 +0,31 @@

/**
Get a random item from an array.
declare const randomItem: {
/**
Get a random item from an array.
@example
```
import randomItem = require('random-item');
@example
```
import randomItem = require('random-item');
randomItem(['🐴', '🦄', '🌈']);
//=> '🦄'
```
*/
declare function randomItem<T>(input: readonly T[]): T;
randomItem(['🐴', '🦄', '🌈']);
//=> '🦄'
```
*/
<T>(input: readonly T[]): T;
/**
Get multiple random items from an array.
This is the equivalent of calling `randomItem()` multiple times so the returned array may contain duplicates.
@example
```
import randomItem = require('random-item');
randomItem.multiple(['🐴', '🦄', '🌈'], 2);
//=> ['🌈', '🦄']
```
*/
multiple<T>(input: readonly T[], count: number): T[];
}
export = randomItem;

@@ -10,1 +10,9 @@ 'use strict';

};
module.exports.multiple = (array, count) => {
if (!Number.isInteger(count) && count >= 0) {
throw new TypeError('Expected a non-negative integer');
}
return [...new Array(count)].map(() => module.exports(array));
};
{
"name": "random-item",
"version": "3.0.0",
"version": "3.1.0",
"description": "Get a random item from an array",
"license": "MIT",
"repository": "sindresorhus/random-item",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},

@@ -12,0 +13,0 @@ "engines": {

@@ -1,6 +0,5 @@

# random-item [![Build Status](https://travis-ci.org/sindresorhus/random-item.svg?branch=master)](https://travis-ci.org/sindresorhus/random-item)
# random-item [![Build Status](https://travis-ci.com/sindresorhus/random-item.svg?branch=master)](https://travis-ci.com/github/sindresorhus/random-item)
> Get a random item from an array
## Install

@@ -12,3 +11,2 @@

## Usage

@@ -21,5 +19,7 @@

//=> '🦄'
randomItem.multiple(['🐴', '🦄', '🌈'], 2);
//=> ['🌈', '🦄']
```
## Related

@@ -34,6 +34,1 @@

- [crypto-random-string](https://github.com/sindresorhus/crypto-random-string) - Generate a cryptographically strong random string
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet