XTitan_Utils is a JavaScript library for quick functions.
- Support Chrome, Safary, Opera browsers
- Type kind parameters with
types
- The ability to use the function
Random
andUUID
functionals Mixin
objects- Advanced
Math
functions
Adding script an core html file.
<script src="https://x-titan.github.io/utils/index.js" type="module" defer></script>
Import all functions
import * from "https://x-titan.github.io/utils/index.js"
Function is
is.str(value) // String
is.num(value) // Number
is.obj(value) // Object
is.bool(value) // Boolean
is.symbol(value) // Symbol
is.null(value) // null
is.defined(value) // any
is.undefined(value) // undefined
// And more usability methods of type functions
Using is
for kind type arguments.
import { is } from "https://x-titan.github.io/utils/index.js"
function fizz (a) {
if(is.str(a)){
// typeof a === "string"
}
if(is.num(a)){
// typeof a === "number"
}
}
import { radianToDegree, degreeToRadian } from "https://x-titan.github.io/utils/index.js"
var angle = radianToDegree(Math.PI / 2) // return: 90
var radian = degreeToRadian(180) // return: 3.14 (Math.PI)
clamp
and map
import { clamp, map } from "https://x-titan.github.io/utils/index.js"
var result_1 = clamp(value, min, max)
var result_2 = map(value, fromLow, fromHigh, toLow, toHigh)
gcd
- greatest common divisor
import { gcd } from "https://x-titan.github.io/utils/index.js"
var result_1 = gcd(a,b)
import "https://x-titan.github.io/utils/index.js"
var result = Math.random(min, max)
var int = Math.randInt(min, max)
Create new random function
var rand = Math.newRandom(seed)
rand()
rand(min)
rand(min, max)
import { mixin, extend } from "https://x-titan.github.io/utils/index.js"
var obj = mixin(...objects)
var result = extend(obj, ...objects) // result === obj
import { Mono } from "https://x-titan.github.io/utils/index.js"
class A extends Mono(...objects) {
constructor(){
super()
}
}
class B {
constructor(){
Mono.mixin(this)
}
}
const C = Mono.extend(class C { })