toolscript

0.1.22 • Public • Published

toolscript

A mini tools of JavaScript

NPM version build status Test coverage npm download

Install

NPM

yarn add toolscript --dev

or npm

npm install toolscript --save-dev

Usage

 
import * as tool from 'toolscript'
 
tool.echo.red('echo red')
// echo red string
tool.detectIE(9)
//if current browser is IE 9 return true else  return false
tool.copyText('content')
//copy the `content` to clipboard
tool.throttle(Func, 50, 100)
//The call that is triggered continuously within a 50ms interval, the latter call will handle the pending processing of the previous call, but at least once every 100ms
tool.timeDifference('2017-01-01 12:00:00', '2018-01-01 13:00:00')
//Calculate the difference between two times, return '365天1小时0分钟0秒'
tool.arrayRemoveEle(['1', '2', '3'], '1')
//Remove the element that belong to the array
tool.isPlainObject(obj)
//Judge the value is a Object.
tool.rgbToHex(255, 255, 255)
//rgb switch to the Hexadecimal.
too.countMaxRepetition('abskgoxugnska14432q1124')
//Count the characters that repeat the most times in a string.
too.unitNormalization(1.259, 2) //1.26
//Format the number that reserve the decimal for the specified number of digits.
 
 
OR
 
import { echo, detectIE, ...other } from 'toolscript'
 
echo.red('echo red')
// echo red string
detectIE(9)
//if current browser is IE 9 return true else  return false
copyText('content')
//copy the `content` to clipboard
...
 

Tool List

Tools

name function parameters description
echo

echo.black(content)

echo.red(content)

echo.green(content)

echo.yellow(content)

echo.blue(content)

echo.carmine(content)

echo.cyan(content)

any data echo colorful information in console
detectIE detectIE(version)

`int`

version of IE
judge IE version
copyText copy(text)

string

the content
copy the content to clipboard, it must be called as a direct result of user action.
throttle throttle(fn, delay, mustRunDelay)

throttle function`function`

the time that successive calls do not trigger, it's in milliseconds `number`

the time that at least once, it's in milliseconds `number`

function throttle
timeDifference timeDifference(startTime, endTime)

startTimen`String`

endTime`String`

Calculate the difference between two times
arrayRemoveEle arrayRemoveEle(array, removeValue)

array`Array`

removeValue`Element type`

Remove the element that belong to the array
isPlainObject isPlainObject(obj)

any data

Judge the value is a Object
rgbToHex rgbToHex(R, G, B)

the rgb value`number`

rgb switch to the Hexadecimal
countMaxRepetition countMaxRepetition('abskgoxugnska14432q1124')

`string`

Count the characters that repeat the most times in a string.
unitNormalization unitNormalization(1.253, 2)

`number`

`int`

Format the number that reserve the decimal for the specified number of digits.
getScriptPath getScriptPath() Get current script url.

Release

npm publish

License

The MIT License (MIT). Please see License File for more information.

Readme

Keywords

Package Sidebar

Install

npm i toolscript

Weekly Downloads

0

Version

0.1.22

License

ISC

Unpacked Size

114 kB

Total Files

35

Last publish

Collaborators

  • alenqi