# onyx-helper

> 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.

Latest version **1.0.1** (published 2017-08-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install onyx-helper
pnpm add onyx-helper
yarn add onyx-helper
bun add onyx-helper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-08-22 |
| First published | 2017-08-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | sayeko |
| Maintainers | sayeko |
| Keywords | javascript, util, javascript, helper, functions |

## Links

- npm: https://www.npmjs.com/package/onyx-helper
- Repository: https://github.com/sayeko/es7-javascript-util-helper
- Homepage: https://github.com/sayeko/es7-javascript-util-helper#readme
- Issues: https://github.com/sayeko/es7-javascript-util-helper/issues
- npm.io page: https://npm.io/package/onyx-helper

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-08-22
- 1.0.0 — 2017-08-22

## README

# Welcome to ES7 Javascript Util Helper Onyx. A Gemstone In Your Project!
![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badge/)

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 ;)

[![Gittip](https://cdn.rawgit.com/gratipay/gratipay-badge/2.3.0/dist/gratipay.svg)](https://gratipay.com/~sayeko/)


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:

```bash
# 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
-----------------------
<h3>So you ask yourself what is so unique in that way.., We create all function above in a generic way so instead of writing and maintain 10 function.
    We have one function that do it for us. (expect to array and null)</h3>

<h5>Just call one of the function above with the is notation , isFunction(fn);
    and expect to get a boolean.</h5>

['Arguments', 'Function', 'String', 'Number', 'Object', 'Date', 'Error', 'Symbol', 'Undefined', 'HTMLDivElement', 'Array', 'Null'];


```bash
# Dynamic (is) function

// Valid function.
let fn = ()=> {return 'Test'};

let flag = Onyx.isFunction(fn); // return true;
```

Usage Parse
-----------

<h3> Heya, there is not developer who did not encounter this exception Uncaught SyntaxError: Unexpected token u in JSON at position 0
Invalid parsing json object or other parsing exception so we created cool and smooth error for js object parsing </h3>

<h5>we created a safeParseJSON that getting input for parse and a default value if the parsing failed good to know that this function in error parse not kill the execution context.</h5>
```bash
# Parse safe json object.

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
-------------

<h3>Most usage window function facades.</h3>

```bash
# 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
-----
```bash

# 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.


License
-------
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)

---
_Source: https://npm.io/package/onyx-helper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
