Library js
v5.2.0 ( last update: 24 oct 2017 )
Set of javascript classes & functions, which can be used in work process. Typescript versions included.
Install
npm
npm i libraryjs --save
Node.js
var Arc Events ... = ;
Typescript
;
Browser
<script src="/node_modules/libraryjs/dist/lib.source.js"></script>
Arc
Superior array
var arc = ;var dogid = arc;arc;arc;arc;console; arc;arc;arc;console;
Looping
var arc = ; arc;arc;arc;arc; forlet i in arcnames console; if arcvaluesi === "string 3" break;
forEach
var arc = ; arc;arc;arc;arc; arc;
search()
var arc = ; arc;arc;arc; var name = arc; // name = "string name 2"
import from array and object
var array = 123456;var arc1 = ;arc1; var object = name: "mike" age: 35;var arc2 = ;arc2; console;console;
copy() & share()
var arc1 = ; name1 = arc1;name2 = arc1;name3 = arc1;name4 = arc1;name5 = arc1; var arc2 = ;arc1; // arc1 -> arc2console; var arc3 = ;arc3; // arc3 <- arc1console;
Two way binding
var arc = ;arc;arc; arcvalues arckeys"man2" = "Bob";//But you can't do like that: arc.value("man2") = "Bob";
How to output Arc
console; // without recursionconsole; // with recursion
Sort
var arc = ;forlet i=0; i<20; i++ arc; console;arc;console;
Other methods
arc; // Rename elementarc; // Reverse Arcarc; // Shuffle Arcarcobject; // Return object formarc; // Return Array formarc; // Concat Arcs
is()
Is object exist?
; //false; //false; //false; //true; //true; //true; //true; //true; //true
Check types
; //true; //true; //true; //true; //true; //true
not()
Not exist?
; //true//not(var) = !is(var)
or()
It chooses first existing object
var c = ; //c = 72
Events
Easy way to run lots of functions
var events = ;events;events;events; // ... events;
Run with id
var events = ; //Example of function, which could unsubscribe itselfvar { console; events;}; events;events;events; // ... events;
Custom launch
var events = ;var fun1 = events;var fun2 = events;var fun3 = events; events;
Async
Superior Promise. You can "resolve" async in any place in your code. And as much times as needed.
var msg = ; ; msg; ;
When you need use it just once
var msg = disposable: true ; //disposable default is false msg; ;;
Errors
Errors manager
var errors = ; errors;errors;errors; if errorsexists console;
With error code
var errors = ;errors;errors; // ... if errors console;
When you need to post by http without methods.
var errors = ;errors;errors; ; { // Here could be real POST request ;} { var errors = ; errors; console;}
Timer
It's just a timer.
var timer = ;timerstart; // ... console; //counted time in millisecondsconsole; //counted time in secondsconsole; //counted time in seconds + left time since last checkpoint timer;
Example
var timer = ;timerstart;console; ;;;
How to restart
var timer = ;timerstart; // ... timer;
Loading
When you have to wait a lot of callbacks
var loading = { console;}; loading;; loading;; loadingstart;
Interval and Timeout
Superior setInterval and setTimeout
var interval = 100 { console;}; var timeout = 1000 { interval;};
check()
Easy way to check that any parameters aren't set. Example:
; { if ! console; return; console;}
And more complicated example:
; { if ! console; return; console;}
rand()
More simple random function
var r = ; //r = 7var r = ; //r = 1var r = ; //r = 6var r = ; //r = 10
round()
Superior round function
var r = ; // r = 3.14var r = ; // r = 3
randstr() & randstr64()
It prints random string
var str = ; // str = nn3wsq20p7azwsdvar str = ; // str = Ttip2sl_JCW4uo9
randtext()
It prints random text
var text = ; // text = fywet
shuffle()
It makes a array randomized
var array = 1 2 3 4 5 6 7 8 9 ;;console; // [ 8, 3, 4, 2, 1, 5, 9, 6, 7 ]
Cookie
Functions for working with cookie
;var cookie = ; // cookie = 85;