A set of Tiny utilities Functions to simple use.
npm i @jrnwn/utils
<script src="https://unpkg.com/@jrnwn/utils"><script>
Array utils
import {
range,
} from '@jrnwn/utils'
const {
range,
} = Utils
function range (start?: number, end?: number, step?: number) => number[]
Cookies utils
import {
getCookie,
setCookie,
deleteCookie,
} from '@jrnwn/utils'
const {
getCookie,
setCookie,
deleteCookie,
} = Utils
function getCookie (name: string) => string | undefined
function setCookie (name: string, value: string, expireDays: number) => void
function deleteCookie (name: string) => void
Date utils
import {
clonedDate,
addDaysTo,
fromToday,
firstDayOfWeek,
firstDayOfMonth,
daysFrom,
monthDays,
getWeek,
getMonth,
} from '@jrnwn/utils'
const {
clonedDate,
addDaysTo,
fromToday,
firstDayOfWeek,
firstDayOfMonth,
daysFrom,
monthDays,
getWeek,
getMonth,
} = Utils
function clonedDate (date: Date) => Date
function addDaysTo (date: Date, days?: number) => Date
function fromToday (days: number) => Date
function firstDayOfWeek (date: Date) => Date
function firstDayOfMonth (date: Date) => Date
function daysFrom (date: Date, days?: number) => Date[]
function monthDays (date: Date) => number
function getWeek (date: Date) => Date[]
function getMonth (date: Date) => Date[]
DOM utils
import {
typeOf,
createEl,
setClass,
removeClass,
setStyle,
getSelector,
platform,
} from '@jrnwn/utils'
const {
typeOf,
createEl,
setClass,
removeClass,
setStyle,
getSelector,
platform,
} = Utils
function typeOf (element: any) => any
function createEl (type: string) => HTMLElement
function setClass (element: HTMLElement, className: string) => void[]
function removeClass (element: HTMLElement, className: string) => void[]
function setStyle (element: HTMLElement, object: Object) => any[]
function getSelector (element: HTMLElement) => string
function platform () => ({
isMobile: boolean,
isDesktop: boolean,
isDark: boolean,
isLight: boolean,
})
Format utils
import {
normalizeText,
toSplit,
toCamel,
toPascal,
toSnake,
toKebab,
toProperName,
} from '@jrnwn/utils'
const {
normalizeText,
toSplit,
toCamel,
toPascal,
toSnake,
toKebab,
toProperName,
} = Utils
function normalizeText (text: string) => string
function toSplit (text: string) => string[]
function toCamel (text: string) => string
function toPascal (text: string) => string
function toSnake (text: string) => string
function toKebab (text: string) => string
function toProperName (text: string) => string
Geometry utils
import {
getDistance,
} from '@jrnwn/utils'
const {
getDistance,
} = Utils
function getDistance (p1: Point, p2: Point) => number
Http utils
import {
loadText,
loadJson,
} from '@jrnwn/utils'
const {
loadText,
loadJson,
} = Utils
function loadText (path: string) => Promise<string>
function loadJson (path: string) => Promise<any>
Math utils
import {
clamp,
} from '@jrnwn/utils'
const {
clamp,
} = Utils
function clamp (value: number, min: number, max: number) => number
Object utils
import {
getDistance,
} from '@jrnwn/utils'
const {
getDistance,
} = Utils
function get (path: string, obj?: Window | Object) => any
function set (path: string, object: Object | Window | undefined, value: any) => any
function getListOfPaths (obj?: object) => any