New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@santi100/array-shuffle

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@santi100/array-shuffle

Santi's Array Shuffling Library: Shuffle it up!

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by27.27%
Maintainers
1
Weekly downloads
 
Created
Source

Santi's Array Shuffling Library

Build Status npm homepage GitHub stars License Bundlephobia stats

  • 🚀 Lightweight and fast^
  • 👴 ES3-compliant*
  • 💻 Portable between the browser and Node.js

What's this?

This library exports a function that shuffles the values in any array.

Installation

  • Via NPM: npm install @santi100/array-shuffle
  • Via Yarn: yarn add @santi100/array-shuffle
  • Via PNPM: pnpm install @santi100/array-shuffle

API

  • function shuffle<T = unknown>(array: T[]): T[];
NameTypeDescriptionOptional?Default
arrayT[]The array to be shuffled.NoN/A
optsobjectOptional parameters for shuffling.Yes{ inPlace: false }
opts.inPlacebooleanIf true, shuffles the array in place.Yesfalse
returnsT[]The shuffled array.NoN/A

Usage

// Import the shuffle function
const shuffle = require('@santi100/array-shuffle'); // CJS
import shuffle from '@santi100/array-shuffle'; // ESM
import shuffle = require('@santi100/array-shuffle'); // TypeScript

// Create an array of numbers
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

// Shuffle the array and get a new shuffled array
const shuffledArray = shuffle(numbers);

console.log('Shuffled Array:', shuffledArray);

// Shuffle the array in-place
const originalArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
shuffle(originalArray, { inPlace: true });

console.log('Original Array (Shuffled In-Place):', originalArray);

Contribute

Wanna contribute? File an issue or pull request! Look at the contribution instructions and make sure you follow the contribution Code of Conduct.

**Hasn't been tested in an actual ES3 environment. Feel free to open an issue or pull request if you find any non-ES3 thing. See "Contribute" for instructions on how to do so.*

^The source code is just a few kilobytes in size.

Keywords

FAQs

Package last updated on 13 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc