The Pirate JS
The Pirate is a lib that has some util functions that can abstract logic and prevent errors
Install
# Using npm npm i the-pirate# Using yarn yarn add the-pirate
General examples
// General functionspirate // 'Hey, You'pirate // truepirate // false pirate // undefinedpirate // '$10.00'
DOM utils
/*imagine this span is in a structure like this:<h2 class="parent"> <div> <span class="child"></span> </div></h2>*/const spanChild = documentdom // returns the h2 that has the .parent class dom // scrolls to parent
Numeric utils
numPyratecnpj // truenumPyratecnpj // false numPyratecpf // truenumPyratecpf // false numPyrate // 20000.04 floatnumPyrate // 20000.04 float // From 0 to 10numPyrate // [0, 1, 2, 3, ..., 10]// From 0 to 99numPyrate // [4, 5, 6, 7, ..., 99]// From 0 to 50 with 5 stepnumPyrate // [5, 10, 15, 20, ..., 50]// From 10 to 50 with 5 stepnumPyrate // [10, 15, 20, 25, ..., 50]
String examples
strPi // truestrPi // falsestrPi // 'Hello World'strPi//hello_worldstrPi//hello_wrld
Color examples
// r, g, bcolor // false color // { r: 170, g: 115, b: 146 } color // blackcolor // white
Note: not all functions were made from ground up. Some of them were inspired by forum answers.