arrow_upward
menu search

All the JS tools you need in your project

JS Library, with the most usually tools in your project, like String to Int convertions, array operations, async functions, promises, callbacks, ES6 implementation, HTTP request, AJAX, data convertions, data parsers, JSON, responsive design, dom manipulation, etc.

Copy $
arrow_downward Download Gecko.JS

Please never use

jQuery


Convertions


Strings

Data convertion:

Transform from string to Array, Number and Object.

let str = String;
str.toInt();
str.toArray();
str.toObject();
let str = "1536";
str.toInt(); //Returns 1536

str.toArray(); //Returns [1, 5, 3, 6]
    
str.toObject(); //Returns {1: "5", 3: "6"}
    
str.toObject(true); //Returns {0: "1", 1: "5", 2:"3", 3:"6}

Arrays

Data convertion:

Transform from Array to String, Number and Object.

let arry = Array;
arry.toInt();
arry.toString();
arry.toObject();
let arry = ["3", 5, "1", 8];
arry.toInt(); //Returns 3518

let arry2 = ["g", "J", "S", "v.", 1];
arry2.toString(); //Returns "gJSv.1"

let arry3 = ["name", "gJS", "version", "1.0"];
arry3.toObject(); //Returns {name: "gJS", version: "1.0"}
arry3.toObject(true); //Returns {0: "name", 1: "gJS", 2:"version", 3:"1.0"}

Objects

Data convertion:

Transform from Object to String and Array.

let obj = Object;
obj.toString();
obj.toArray();
let obj = {name : "Gecko", type: "JavaScript"}
obj.toString(); //Returns "name:Gecko, type:JavaScript";

let obj3 = {job : "Enginer", weight: "73kg"}
obj3.toArray(); //Returns ["job", "Enginer", "weight", "73kg"];

Numbers

Data convertion:

Transform from string to Array, Number and Object.

let n = Number;
n.toString();
n.toArray();
n.toObject();
let n = 3457;
n.toString(); //Returns "3457"

n.toArray(); //Returns [3, 4, 5, 7]

n.toObject(); //Returns {3:5,5:7}

n.toObject(true); //Returns {0:"3", 1:"5", 2:"5", 3:"7"}

Tools


Random Range

Get Random:

Get random numbers by a range, the structure is:

let n = randomRange(Min:Number, Max:Number);
let n = randomRange(3, 9); //Returns any number from 3 to 9

Exec

Run command:

Shortcut for document.execCommand, the structure is:

exec("command":String, aShowDefaultUI:Boolean, aValueArgument:String);
exec("copy");

Print

Console print:

Shortcut for console.log, the structure is:

print("command":String);
print("Hello", "Gecko"); //Print Hello Gecko

PrintLn

Console printLn:

Shortcut for console.log with return to the end, the structure is:

printLn("command":String);
printLn("Love", "myself"); //Print Love\n myself\n

Warning

Console Warn:

Shortcut for console.warn, the structure is:

warn("command":String);
warn("Shut up!"); //Print ⚠️ Shut up!

Error

Console Warn:

Shortcut for console.error, the structure is:

error("command":String);
error("Breaked"); //Print ❗Breaked

Objects

Selectors

Basic form:

You can select one element, or list of choised elements.

g("cssSelector":String, Number/Array);
g(["cssSelectors"]:String Array, Number/Array);
g("#elmnt").event("click", () =>{
//Do something ...
    
});
    
g(["#elmnt1", "#elmnt2", "#elmnt3"]).event("click", () =>{
//Do something (three elements selected)
    
});

Select one:

You can select an specific element of a list.

let number = 2;
g(".list", number).event("click", () =>{
//Do something (3th element)
                  
});

Limiters:

You can select an specific range of elements in a list from 0 to 'limiter'.

let limiter = 7;
g(".list", [limiter]).event("click", () =>{
//Do something (from first element to 8th element)
                  
});

Ranges:

You can select a range of elements in a list with [Max, Min] or [Min, Max] it doesn't matter, and try to use negative coeficients like [3][-1].

let min = 3, max = 8;
g(".list", [max, min]).event("click", () =>{
//Do something (from 4th element to 9th element)

});

Find

Everything:

You can find an element by class, id, tagName, the structure is:

g("cssSelector").find("searchElement":String);
g("#elmnt").find("#main");

Events

All events:

Basically all events in addEventListener method, see Events docs MDN for more information.

g("cssSelector").event("event":String);
g("#elmnt").event("yourEvent", () =>{
//Do something ...
                          
});

outClick:

check if you click outside of an element, you can use by typing:

g("#elmnt").event("oClick", () =>{
//Do something ...
                                  
});

Hover

Basic form:

Do something when mouse over and mouse out in two functions, the basic structure is:

g("cssSelector").hover(MouseOver:Function, MouseOut:Function);
g("#elmnt").hover(() =>{
//Mouseover function ...
    
},
() =>{
//Mouseout function ...
    
});

Css

All rules:

Basically all css3 rules and browser support, see W3schools css for more information, the basic structure is:

g("cssSelector").css("cssRules":String);
g("cssSelector").css("get":String, "cssRule":String);
g("#elmnt").css("font-size:2em");

Empty:

When you call css method with empty params the function return all css rules by your element.

g("#elmnt").css(); //Return all css rules on #elmn

Get:

Returns value of an specific property in an element.

g("#elmnt").css("get", "font-size"); //Return 2em (example)

OffSet

Get Position:

You can get the offset from the top of your document, not relative to the parent, the structure is:

g("cssSelector").offset();
g("#elmnt").offset(); \\Returns Object{top, left}

Animates

Css animation:

Animates css of an element with css native not objects($), the default time value is 150ms, the basic structure is:

g("cssSelector").animates("cssRules":String, Duration:Number, Delay:Number);
g("#elmnt").animates("color:red");

Time:

Defines the duration of the animation in an element.

g("#elmnt").animates("color:red", 500); //Animates color:red in 500ms

Delay:

Defines the delay time when animation start in an element.

g("#elmnt").animates("color:red", 500, 1000); //Animates color:red in 500ms and starts in 1000ms

Attr

All attributes:

Basically all attributes of an element on html,its similar to css method and the basic structure is:

g("cssSelector").attr("attribute":String, "value":String);
g("cssSelector").attr("method":String, "value":String);
g("#elmnt").attr("name", "newInput");

Get:

Returns value of an specific attribute of an element.

g("#elmnt").attr("name"); //Returns newInput (example)
g("#elmnt").attr("get", "name"); //Returns newInput (example)

Has:

Returns boolean if your element has an specific attribute.

g("#elmnt").attr("has", "name"); //Return true (example)

Remove:

Removes an attribute of your element.

g("#elmnt").attr("remove", "name");
g("#elmnt").attr("has", "name"); //Return false

Class

Class methods:

You can set, remove, replace, toggle, an if contains class of an element, the basic structure is:

g("cssSelector").class("addclassName":String);
g("cssSelector").class("method":String, "className":String);
g("cssSelector").class("replace":String, "className":String, "newclassName":String);
g("#elmnt").class("newEl");

Get:

Returns value of an specific class of an element.

g("#elmnt").class(); //Returns all classes of your element

Remove:

Removes an specific class of your element.

g("#elmnt").class("remove", "newEl");

Replace:

Replace an specific class of your element.

g("#elmnt").class("replace", "newEl", "newElClass");

Toggle:

Removes or add a class of your element.

g("#elmnt").class("toggle","newElClass");

Contains:

Returns boolean if your element contain a class.

g("#elmnt").class("contains", "newElClass"); //Returns true

Html

Set innerHTML:

Append html text to your element, similar to innerHTML method, the basic structure is:

g("cssSelector").html("htmlText":String);
g("#elmnt").html("Some text");

Get:

Retturns html text inside of an element.

g("#elmnt").html(); //Returns "<i>Some text</i>"

Text

Set text:

Set text value to your element, similar to textContent method, the basic structure is:

g("cssSelector").text("someText":String);
g("#elmnt").text("Some text");

Get:

Retturns string of text inside of an element.

g("#elmnt").text(); //Returns "Some text"

ObjArray

Ndlist to Array:

Converts from NodeList to Array of objects, the structure is:

g("cssSelector").objArray();
g(".list").objArray(); //Returns [elm1, elm2, elm3 , ...]

Strings


Replace At

Set Index:

Replace a substring or character in a specific index of a string, the structure is:

let str = String;
str.replaceAt(Index:Number, "replace":String);
let str = "Hello World";
str.replaceAt(5, ","); //Returns "Hello,World"

Replace All

All characters:

Replace all characters in a string, the structure is:

let = String;
str.replaceAll("char":String, "replace":String);
let str = "Go to Moon";
str.replaceAll("o", "x"); //Returns "Gx tx Mxxn"

Replace Index

Replace same:

Replace the specific index of a repeated character of a string, the structure is:

let str = String;
str.replaceIndex("Search":String, Index:Number, "Replace":String);
let str = "You are awesome";
str.replaceIndex("e", 1, "o"); //Returns "You are awosome"

Last Index Of

Search Last:

Returns the position of the last character searched, the structure is:

let str = String;
str.lastIndexOf("char":String);
let str = "Best library";
str.lastIndexOf("b"); //Returns 7

Get Search Position

Search Last:

Returns the position of a specific substring in string position, the structure is:

let str = String;
str.getSearchPosition("char":String, Index:Number);
let str = "Burst Your Bubble";
str.getSearchPosition("b", 2); //Returns 13

Search Repeat

If repeat:

Returns boolean of how much substrings or characters are in a string, the structure is:

let str = String;
str.searchRepeat(Repeat:Number, "char":String);
let str = "We are kids";
str.searchRepeat(2, "e"); //Returns true

Get Repeat

Char repeats:

Returns how much substrings or characters are in a string, the structure is:

let str = String;
str.getRepeat("char":String);
let str = "Greased Lightning";
str.getRepeat("g"); //3

Cut

Extract:

Cut a part of a string, the structure is:

let str = String;
str.getRepeat(cutStart:Number, cutEnd:Number);
let str = "Easy as pie";
str.cut(4, 7); //Easy pie

toHex

From Rgb to Hex:

Transforms from RGB color string to HEX code color string, the structure is:

let str = "(r,g,b)":String;
str.toHex();
let str = "(23,63,16)";
str.toHex(); //Returns "#173f10"

toRGB

From Hex to Rgb:

Transforms from HEX color string to RGB code color string, the structure is:

let str = "#rgb":String;
str.toRGB();
let str = "#4b3f13";
str.toRGB(); //Returns "(75,63,18)"

Capitalize

Upper Case:

Add capital letter, transforms all string in UpperCase, the structure is:

let str = String;
str.capitalize();
let str = "break the ice";
str.capitalize(); //Returns "Break the ice""

Arrays



Include String

Best method:

Basically is includes method of array but with some many features, the structure is:

let arry = Array;
arry.includeStr(String, Strict:Boolean);
let words = ["Eat","my","hat"];
words.includeStr("m"); //Returns true
words.includeStr("m", true); //Returns false
words.includeStr("my", true); //Returns true

Operations

Array operations:

You can add, substract, multiply, divide, get root, elevate, get module, concat between arrays, the structure is:

let arry = Array;
arry.operation("method":String, Number);
let arry = [4, 7, 5];
arry.operation("add", 2); //Returns [6, 9, 7]

Add:

Add number to array values, the method options are:

let arry = [3, 5, 9];
arry.operation("+", 2); //Returns [5, 7, 11]

Remove:

Substract number to array values, the method options are:

let arry = [6, 4, 8];
arry.operation("-", 3); //Returns [3, 1, 5]

Multiply:

Multiply number to array values, the method options are:

let arry = [4, 11, 7];
arry.operation("x", 5); //Returns [20, 55, 35]

Divide:

Divide number to array values, the method options are:

let arry = [94, 48, 56];
arry.operation("/", 8); //Returns [11.75, 6, 7]

Elevate:

Elevate number to array values, the method options are:

let arry = [5, 2, 3];
arry.operation("^", 3); //Returns [125, 8, 27]

Root:

Root by number to array values,the default exponent is 2, the method options are:

let arry = [128, 64, 82];
arry.operation("|", 4); //Returns [3.36, 2.82, 3.009]

Mod:

Get mod of a number to array values, the method options are:

let arry = [4, 3, 8];
arry.operation("%", 2); //Returns [0, 1, 0]

Concat:

Concat Strings or number to array values, the method options are:

let arry = ["g", 5, 2];
arry.operation(".", 2); //Returns ["g2", 52, 22]
arry.operation(".", "j"); //Returns ["gj", "5j", "2j"]

Max

Max value:

You can get the max value of a list of numbers, the structure is:

let arry = Number Array;
arry.max();
let arry = [7, 2, 31];
arry.max(); //Returns 31

Min

Min value:

You can get the min value of a list of numbers, the structure is:

let arry = Number Array;
arry.max();
let arry = [4, 1, 13];
arry.min(); //Returns 1

Randomize

Random value:

Randomize the order of the elements in your array, , the structure is:

let arry = Array;
arry.randomize();
let arry = ["g", 5, 3, "js"];
arry.randomize(); //Returns [3, "g", 5, "js"]

Combine

Combine arrays:

Combine two or more arrays in one, the structure is:

let arry = Array;
let arry2 = Array;
arry.combine(arry2);
let arry = ["l", 1, "a"];
let arry2 = [4, "g", 5];
arry.combine(arry2); //Returns ["l", 1, "a", 4, "g", 5]

Numbers


Root

Math Sqrt:

Returns square root of a number, the default is 2 or root by a number, the structure is silimar to Math.sqrt().

let n = Number;
n.root(Exponent:Number);
let n = 4;
n.root(); //Returns 2

Root to:

Root by a number, the structure is silimar to Math.pow().

let n = 4;
n.root(3); //Returns 1.587..

Pow

Math Pow:

Returns a number elevate by exponent, the default exponent is 2, the structure is silimar to Math.pow().

let n = Number;
n.pow(Exponent:Number);
let n = 4;
n.pow(); //Returns 16

Pow to:

Elevate a number by exponent, the structure is silimar to Math.pow(Number).

let n = 4;
n.pow(3); //Returns 64

Help us to Kill the dollar ($)

Our octocat repository:

Make libraries fasted again