0.9.2 • Published 7 years ago

putil v0.9.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

putil Build Status

private javascript util set.

Support

node.js & browser

Install

  • node
npm install putil --save
  • browser
<script src="https://mebtte.github.io/putil/putil.js"></script>

Usage

  • node
import { getRandomString } from 'putil';
getRandomString(10);
// or
import * as putil from 'putil';
putil.getRandomString(10)
  • browser
const { getRandomString } = putil;
getRandomString(10);
// or use directly
putil.getRandomString(10)

Functions

getRandomInt(min = 0, max = 1)

Get a random int.

  • params [min] (Number): The minimum number, default 0.
    [max] (Number): The maximum number, default 1.
  • return (Number): A random int that do not include the maximum number.
  • example
getRandomInt(0, 10); // '1'

getRandomString(length = 10)

Get a random string.

  • params [length] (Number): The length of string, default 10.
  • return (String): A random string.
  • example
getRandomString(12); // 'd1dandf5k3r33'

sleep(duration = 0)

Pause async function.

  • params [duration] (Number): Sleep duration, millisecond, default 0.
  • return (Promise)
  • example
async function test() {
  console.log('I am going to sleep.');
  await putil.sleep(1000 * 3); // sleep 3 seconds
  console.log('I am up.');
}

typeOf(value)

Get the type of value.

  • params value (Any): The value that want to get the type.
  • return (String): The type of value.
  • example
typeOf(1); // Number
typeOf(new Set()); // Set
typeOf(Symbol()); // Symbol
typeOf(Symbol); // Function
0.9.2

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

0.8.0

7 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.3

7 years ago

0.6.2

7 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.4.0

7 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago

1.0.0

11 years ago

0.9.9

11 years ago

0.9.8

11 years ago