Utils.js
:construction_worker: :wrench: zero dependencies vanilla JavaScript utils.
Install / Use
/learn @fabiocaccamo/Utils.jsREADME
utils.js
👷 🔧 zero dependencies vanilla JavaScript utils.
Table of contents
Installation
This library is available through npm:
npm install @fabiocaccamo/utils.js
Usage
CDN
<script src=" https://cdn.jsdelivr.net/npm/@fabiocaccamo/utils.js/dist/utils.min.js"></script>
Local
<script src="node_modules/@fabiocaccamo/utils.js/dist/utils.min.js"></script>
Node
var utils = require("@fabiocaccamo/utils.js");
ESM
import utils from '@fabiocaccamo/utils.js';
APIs
<details><summary><code>utils.array</code></summary> <p>-
all -
any -
clean -
clone -
contains -
equals -
flatten -
index -
insert -
max -
min -
paginate -
reduce -
remove -
replace -
rotate -
shuffle -
sort -
sum -
unique -
unzip -
zip
-
decode -
encode
-
cmykToHex -
cmykToRgb -
hexToCmyk -
hexToRgb -
rgbToCmyk -
rgbToHex
-
toString -
toStringCSS
-
average -
distance -
gradient -
gradientMatrix -
interpolateBilinear -
interpolateLinear -
interpolateMultilinear -
nearest -
toCmyk -
toRgb -
toString -
toStringCSS
-
average -
distance -
gradient -
gradientMatrix -
interpolateBilinear -
interpolateLinear -
interpolateMultilinear -
nearest -
toCmyk -
toRgb -
toString -
toStringCSS
-
clone -
constrain -
format -
isFuture -
isPast -
max -
min -
parse -
timestamp -
today -
tomorrow -
yesterday -
yyyymmdd
-
backIn -
backInOut -
backOut -
bounceIn -
bounceInOut -
bounceOut -
circularIn -
circularInOut -
circularOut -
cubicIn -
cubicInOut -
cubicOut -
elasticIn -
elasticInOut -
elasticOut -
exponentialIn -
exponentialInOut -
exponentialOut -
none -
quadraticIn -
quadraticInOut -
quadraticOut -
quarticIn -
quarticInOut -
quarticOut -
quinticIn -
quinticInOut -
quinticOut -
sexticIn -
sexticInOut -
sexticOut -
sineIn -
sineInOut -
sineOut -
waveCosine -
waveSawtooth -
waveSine
-
args -
attempt -
bind -
call -
debounce -
delay -
memoize -
noop -
repeat -
throttle -
until -
validate
-
add -
angle -
cross -
distance -
dot -
equals -
interpolate -
length -
magnitude -
project -
rect -
rotate -
scale -
subtract -
translate
-
decodeInt -
encodeInt
-
decode -
encode
-
average -
constrain -
cycle -
equals -
euclideanDistance -
factorial -
gcd -
lcm -
lerp -
map -
nearest -
normalize -
proportion -
roundDecimals -
roundToMultiple -
roundToNearest -
roundToPower -
sign -
summation
-
bilinear -
linear -
multilinear -
scalar
-
isBetween -
isEven -
isFloat -
isNegative -
isOdd -
isPositive -
isPrime
-
assign -
clean -
clone -
decodeBase64 -
decodeJSON -
decodeParameters -
encodeBase64 -
encodeJSON -
encodeParameters -
equals -
is -
keypath -
keys -
length -
map -
merge -
search -
values
-
argument -
bit -
boolean -
color -
element -
float -
index -
integer -
map -
sign -
string
-
contains -
endsWith -
icontains -
levenshteinDistance -
levenshteinSimilarity -
padLeft -
padRight -
padZeros -
render -
replace -
reverse -
rotate -
slugify -
startsWith -
toConstantCase -
toRandomCase -
toTitleCase -
toUpperCaseFirst -
trim -
trimLeft -
trimRight
-
assertArray -
assertBase64 -
assertBoolean -
assertDate -
assertEqual -
assertError -
assertFalse -
assertFunction -
assertJSON -
assertNaN -
assertNone -
assertNotArray -
assertNotBase64 -
assertNotBoolean -
assertNotDate -
assertNotEqual -
assertNotError -
assertNotFunction -
assertNotJSON -
assertNotNone -
assertNotNull -
assertNotNumber -
assertNotObject -
assertNotRegExp -
assertNotString -
assertNotUndefined -
assertNull -
assertNumber -
assertNumberAlmostEqual -
assertObject -
assertRegExp -
assertString -
assertThrows -
assertTrue -
assertUndefined
-
acosDeg -
angleDeg -
angleRad -
asinDeg -
atan2Deg -
atanDeg -
cosDeg -
cycleDeg -
degToRad -
fastDeg -
haversine -
hypo -
radToDeg -
sinDeg -
tanDeg
-
isArray -
isBase64 -
isBoolean -
isDate -
isError -
isFunction -
isJSON -
isNaN -
isNone -
isNull -
isNumber -
isObject -
isRegExp -
isString -
isType -
isUndefined -
of
-
getDomain -
getParameterByName -
getParameters -
getParametersDict -
getParametersList -
getParametersString -
getURL -
hasParameter -
isFile -
isHttp -
isHttps -
isLocalhost
-
decode -
encode
removeNamespaces
Development
Setup
git clone https://github.com/fabiocaccamo/utils.js.gitnpm install
Watch
npm run watch
Testing
Formatting
npm run format(format code usingPrettiercode formatter, refer to .prettierrc for specific formatting options)
Build
npm run build
Security
Refer to SECURITY.md
License
Released under MIT License.
