@fabiocaccamo/utils.js

0.24.0 • Public • Published

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");

APIs

utils.array

  • all

  • any

  • clean

  • clone

  • contains

  • equals

  • flatten

  • index

  • insert

  • max

  • min

  • paginate

  • reduce

  • remove

  • replace

  • rotate

  • shuffle

  • sort

  • sum

  • unique

  • unzip

  • zip

utils.base64

  • decode

  • encode

utils.color

  • cmykToHex

  • cmykToRgb

  • hexToCmyk

  • hexToRgb

  • rgbToCmyk

  • rgbToHex

utils.color.cmyk

  • toString

  • toStringCSS

utils.color.hex

  • average

  • distance

  • gradient

  • gradientMatrix

  • interpolateBilinear

  • interpolateLinear

  • interpolateMultilinear

  • nearest

  • toCmyk

  • toRgb

  • toString

  • toStringCSS

utils.color.rgb

  • average

  • distance

  • gradient

  • gradientMatrix

  • interpolateBilinear

  • interpolateLinear

  • interpolateMultilinear

  • nearest

  • toCmyk

  • toRgb

  • toString

  • toStringCSS

utils.date

  • clone

  • constrain

  • format

  • isFuture

  • isPast

  • max

  • min

  • parse

  • timestamp

  • today

  • tomorrow

  • yesterday

  • yyyymmdd

utils.ease

  • 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

utils.func

  • args

  • attempt

  • bind

  • call

  • debounce

  • delay

  • memoize

  • noop

  • repeat

  • throttle

  • until

  • validate

utils.geom

utils.geom.point

  • add

  • angle

  • cross

  • distance

  • dot

  • equals

  • interpolate

  • length

  • magnitude

  • project

  • rect

  • rotate

  • scale

  • subtract

  • translate

utils.hex

  • decodeInt

  • encodeInt

utils.json

  • decode

  • encode

utils.math

  • average

  • constrain

  • cycle

  • equals

  • euclideanDistance

  • factorial

  • gcd

  • lcm

  • lerp

  • map

  • nearest

  • normalize

  • proportion

  • roundDecimals

  • roundToMultiple

  • roundToNearest

  • roundToPower

  • sign

  • summation

utils.math.interpolation

  • bilinear

  • linear

  • multilinear

  • scalar

utils.number

  • isBetween

  • isEven

  • isFloat

  • isNegative

  • isOdd

  • isPositive

  • isPrime

utils.object

  • assign

  • clean

  • clone

  • decodeBase64

  • decodeJSON

  • decodeParameters

  • encodeBase64

  • encodeJSON

  • encodeParameters

  • equals

  • is

  • keypath

  • keys

  • length

  • map

  • merge

  • search

  • values

utils.random

  • argument

  • bit

  • boolean

  • color

  • element

  • float

  • index

  • integer

  • map

  • sign

  • string

utils.string

  • contains

  • endsWith

  • icontains

  • levenshteinDistance

  • levenshteinSimilarity

  • padLeft

  • padRight

  • padZeros

  • render

  • replace

  • reverse

  • rotate

  • slugify

  • startsWith

  • toConstantCase

  • toRandomCase

  • toTitleCase

  • toUpperCaseFirst

  • trim

  • trimLeft

  • trimRight

utils.test

  • 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

utils.trigo

  • acosDeg

  • angleDeg

  • angleRad

  • asinDeg

  • atan2Deg

  • atanDeg

  • cosDeg

  • cycleDeg

  • degToRad

  • fastDeg

  • haversine

  • hypo

  • radToDeg

  • sinDeg

  • tanDeg

utils.type

  • isArray

  • isBase64

  • isBoolean

  • isDate

  • isError

  • isFunction

  • isJSON

  • isNaN

  • isNone

  • isNull

  • isNumber

  • isObject

  • isRegExp

  • isString

  • isType

  • isUndefined

  • of

utils.url

  • getDomain

  • getParameterByName

  • getParameters

  • getParametersDict

  • getParametersList

  • getParametersString

  • getURL

  • hasParameter

  • isFile

  • isHttp

  • isHttps

  • isLocalhost

utils.utf8

  • decode

  • encode

utils.xml

  • removeNamespaces

Development

Setup

  • git clone https://github.com/fabiocaccamo/utils.js.git
  • npm install

Watch

  • npm run watch

Testing

  • npm run test (run tests against dist using Gulp task runner and Mocha Javascript testing framework)

Formatting

  • npm run format (format code using Prettier code formatter, refer to .prettierrc for specific formatting options)

Build

  • npm run build

Security

Refer to SECURITY.md

License

Released under MIT License.

Package Sidebar

Install

npm i @fabiocaccamo/utils.js

Weekly Downloads

4

Version

0.24.0

License

MIT

Unpacked Size

622 kB

Total Files

65

Last publish

Collaborators

  • fabiocaccamo