random-pro.js
TypeScript icon, indicating that this package has built-in type declarations

0.0.2-alpha.6 • Public • Published

中文简体

random-pro.js

Feature

  • Randomly return one of the incoming data
  • Support Array, Object, Map, Set

Online demo

https://codesandbox.io/s/random-pro-js-5hsk94?file=/src/demo.js

Install

yarn add -D random-pro.js

Usage

import { random } from 'random-pro.js'

random([2, 3, 4, 5, 6, 7]); // => random return
random({ foo: { hello: "你好" }, bar: false, baz: 3 }); // => random return
random(
  new Map([
    ["foo", 1],
    ["bar", 2],
    [
      "baz",
      {
        nest: {
          foo: 1,
          bar: [3, 2, 4, 1],
        },
      },
    ],
  ])
); // => random return
random(new Set([3, 4, 9, 10, 2, 1])); // => random return

Readme

Keywords

none

Package Sidebar

Install

npm i random-pro.js

Weekly Downloads

7

Version

0.0.2-alpha.6

License

ISC

Unpacked Size

19.8 kB

Total Files

45

Last publish

Collaborators

  • frankkai