GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dmnsgn/typed-array-shuffle: Shuffle arrays and typed arrays in place or as a copy, with a custom random source for seeded shuffles.

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
test
test
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

typed-array-shuffle

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

Shuffle arrays and typed arrays in place or as a copy, with a custom random source for seeded shuffles.

paypal coinbase twitter bluesky

Installation

npm install typed-array-shuffle

Usage

import { shuffle, toShuffled } from "typed-array-shuffle";
import random from "pex-random";

// In place
const indices = shuffle(Uint32Array.from({ length: 10 }, (_, i) => i));

// Copy, keeping the typed array type
const values = toShuffled(Float32Array.of(0.1, 0.2, 0.3));

// Seeded, with any source of numbers in [0, 1)
random.seed(1);
const seeded = shuffle([1, 2, 3, 4], () => random.float());

API

typedArrayShuffle

  • typedArrayShuffle
    • static
      • .shuffle(array, [random]) ⇒ T
      • .toShuffled(collection, [random]) ⇒ Array.<T> | ArrayLike.<T>
    • inner
      • ~RandomSource : function

typedArrayShuffle.shuffle(array, [random]) ⇒ T

Shuffle an array or typed array in place, uniformly.

Kind: static method of typedArrayShuffle Returns: T - The shuffled array.

Param Type Default
array T
[random] RandomSource Math.random

typedArrayShuffle.toShuffled(collection, [random]) ⇒ Array.<T> | ArrayLike.<T>

Shuffled copy of an array, typed array or iterable. Typed arrays keep their type, anything else becomes an array.

Kind: static method of typedArrayShuffle

Param Type Default
collection ArrayLike.<T> | Iterable.<T>
[random] RandomSource Math.random

typedArrayShuffle~RandomSource : function

Returns a number in [0, 1).

Kind: inner typedef of typedArrayShuffle

License

MIT. See license file.

About

Shuffle arrays and typed arrays in place or as a copy, with a custom random source for seeded shuffles.

Topics

arrayfisher-yatespermutationrandomseededshuffletyped-array

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.