petite-utils
v0.0.25
Published
A collection of small util function in JavaScript.
Maintainers
Readme
petite-utils
A collection of small util function in JavaScript.
features:
- small and fast.
- node.js and browser support.
- tree-shakable.
Installation
# npm
npm i petite-utils
# yarn
yarn add petite-utils
# pnpm
pnpm add petite-utilsUsage
// cjs module
const { randomStr } = require('petite-utils')
// ES module
import { randomStr } from 'petite-utils'use
esmin html by cdn
<!-- load ES module -->
<script type="module">
import { randomStr } from 'https://unpkg.com/petite-utils/dist/index.js'
const result = randomStr(20, 50)
console.log(result)
console.log('test in browser using esm')
</script>use
umdin html by cdn
<!-- load umd -->
<script src="https://unpkg.com/petite-utils"></script>
<!-- then use function from PU object -->
<script>
const str = PU.randomStr()
</script>isNumber
check if the value is a number.
import {
isNumber,
repeatRun
} from 'petite-utils'
isNumber(1) // true
isNumber('1') // true
isNumber(4.917736942280289e-10) // true
isNumber(
BigInt('0b11111111111111111111111111111111111111111111111111111'),
) // true
isNumber(NaN) // false
isNumber('a') // false
repeatRun((time,stop)=>{
if(time===10){
stop()
}
console.log('repeat run me!')
}, { interval:1000 })