onyx-helper
v1.0.1
Published
Extremely light and powerful library work for client and node as one. A gemstone at your js project. ES6/ES7 Javascript wrapping global objects and functionality also handling with async tasks.
Downloads
3
Maintainers
Readme
Welcome to ES7 Javascript Util Helper Onyx. A Gemstone In Your Project!
Donation
To keep the repo live and kicking with good quality code we would more than happy if you could buy us a cup of coffe ;)
Motivation
Hey guys, I started to write this repo from the reason that we over and over writing the same utils, and using libraries that have their own utils and it make kinda overkill in script size download. So we created the ES7 Javascript util helper. Extremely light and powerful library work for client and node js as one. A gemstoen at your js project ;) this one will be Onyx :).
Installation
The easiest way to get started is to clone the repository:
# Install util helper from npm registrey
npm install --save onyx-helper
# Get the latest snapshot
git clone --depth=1 https://github.com/sayeko/es7-javascript-util-helper.git myproject
# Change directory
cd myproject
# Install NPM dependencies
npm install
# Install gulp globally
npm i gulp -g
# Then simply start your app with the automation tool gulp
gulp
Usage Famous Is Methods
['Arguments', 'Function', 'String', 'Number', 'Object', 'Date', 'Error', 'Symbol', 'Undefined', 'HTMLDivElement', 'Array', 'Null'];
# Dynamic (is) function
// Valid function.
let fn = ()=> {return 'Test'};
let flag = Onyx.isFunction(fn); // return true;
Usage Parse
let test = Onyx.safeParseJSON(undefined, {}); // return {};
Parse safe string to int
let num = Onyx.safeStringToInt('3', null); // Enter valid string to parse if there parsing error the function will return the default value.
<h5>Every developer in js encounter in the problem how to create clone of complex js object.</h5>
```bash
# Clone js object.
Onyx.clone(obj);
Window Facade
# Redirect
Onyx.redirect(url); // The name is kinda explanatory.
# Query string from url
Onyx.getQueryParametersByString(queryString..) // Get the query string as object.
# Refresh page (reload)
Onyx.reload();
# Fullscreen facades multi platform function works on any browser.
Onyx.fullScreen() // Kick in and change the user mode.
Onyx.isFullScreen() // Tell if the user is already in fullscreen mode. the fn above use this fn.
# Hostname domain
Onyx.hostname(); // google... etc..
# Protocol
Onyx.protocol(); // http, https, ftp , etc..
Async
# Load async script
Onyx.loadAsyncScript('src..' ,id , type); // Load async way script and append it to the end of the body tag, return Promise.
# Load async image
Onyx.loadAsyncImage(path, defaultPath) // Trying to load the path and if the path is not exist or error to load we loading the default path instead.
Contributors
Everyone is more than welcome to fork this repo upload issue or email me to make a suggestions. If you have cool and light facades please make a pull request. and help us to help the js developer community.