open-index/open-npm huggingface dataset:
npm package: @ib-code/result-object
Description: Function or method result structure serializer
Author: Igor
Latest version: 1.0.2

# ResultObject

<div style="display:inline">
<a href="https://www.npmjs.com/package/@ib-code/result-object">
<img alt="npm" style="margin-right:4px" src="https://img.shields.io/npm/v/@ib-code/result-object">
</a>
<img alt="licence" style="margin-right:4px" src="https://img.shields.io/npm/l/@ib-code/result-object">
<img alt="GitHub branch checks state" style="margin-right:4px" src="https://img.shields.io/github/checks-status/igorbezsmertnyi/result-object/master">
<img alt="Codecov" style="margin-right:4px" src="https://img.shields.io/codecov/c/gh/igorbezsmertnyi/result-object">
</div>
<br/>

In JavaScript, errors and failures are typically implemented with exceptions. In some situations, however, exceptions may not be the best choice. The `ResultObject` contains a build in methods that transform the result to common structure. The `ResultObject` object are wrappers for a successful, or failed results of the functions or methods.

### Object Sturecture

```js
// SuccessОbject

{
  "ok": true,
  "data": {
    // ...some data
  },
  "error": undefined,
}

// FailedОbject
{
  "ok": false,
  "data": {
    // ...some data
  },
  "error": Error // Error object
}
```


## Installation

```shell
$ npm install @ib-code/result-object
$ yarn add @ib-code/result-object
```

## Usage

```ts
import { Result, ResultObject } from 'result-object'

const someFunctions = (): ResultObject<number> => {
  try {
    const numebr = getNumber() // example function

    return Result.success(numebr)
  } catch (error) {
    return Result.failed(error, "Additional data")
  }
}
```

## Author

- [github/igorbezsmertnyi](https://github.com/igorbezsmertnyi)

## License

Copyright (c) 2022 Igor Bezsmertnyi, contributors. Released under the MIT license
npm package: @ib-hooks/use-axios
Description: React Hook to fetch or re-fetch api using axios easier.
Author: Inwook Baek
Latest version: 1.0.1

# @ib-hooks/use-axios

React Hook to **fetch or re-fetch api using axios easier.**

## Installation

#### yarn

`yarn add @ib-hooks/use-axios`

#### npm

`npm i @ib-hooks/use-axios`

## Usage

```js
import React from "react";
import useAxios from "@ib-hooks/use-axios";

function App() {
  const {
    response: { loading, data, error },
    refetch,
  } = useAxios({ url: API_URL });

  return (
    <div>
      <h1>{data && data.status}</h1>
      <h2>{error && error.message}</h2>
      <h3>{loading && "fetching..."}</h3>
      <button onClick={refetch}>Refetch API</button>
    </div>
  );
}
```

### Arguments

| **Argument**  | **Type** | **Description**                                            | **Required** | **Default value** |
| ------------- | -------- | ---------------------------------------------------------- | ------------ | ----------------- |
| options       | object   | [Reference](https://github.com/axios/axios#request-config) | yes          | undefined         |
| axiosInstance | object   | You can choose axios instance customly.                    | no           | defaultAxios      |

### Return

| **Return value**                     | **Type** | **Description**                                                  |
| ------------------------------------ | -------- | ---------------------------------------------------------------- |
| object(`response`, `refetch`)        | object   | See below                                                        |
| response(`loading`, `data`, `error`) | object   | Response data of fetch api.                                      |
| refetch                              | function | The refetch function executes when the user want to refetch api. |
npm package: @ib-hooks/use-fade-in
Description: React Hook to add fade-in animation to an element.
Author: Inwook Baek
Latest version: 1.0.1

# @ib-hooks/use-fade-in

React Hook to **add fade-in animation to an element.**

## Installation

#### yarn

`yarn add @ib-hooks/use-fade-in`

#### npm

`npm i @ib-hooks/use-fade-in`

## Usage

```js
import React from "react";
import useFadeIn from "@ib-hooks/use-fade-in";

function App() {
  const fadeIn = useFadeIn(0.5, "ease-in-out", 0.5);

  return <h1 {...fadeIn}>This will fade in.</h1>;
}
```

### Arguments

| Argument    | Type   | Description                                     | Required | Default value |
| ----------- | ------ | ----------------------------------------------- | -------- | ------------- |
| duration    | number | Sets the duration of the transition. In seconds | no       | 1             |
| cubicBezier | string | Cubic bezier of fade-in animation.              | no       | "linear"      |
| delay       | number | Delays of transition's start. In seconds        | no       | 0             |

### Return

`useScroll` returns an object containing the following:

| Name  | Type      | Description                                                               |
| ----- | --------- | ------------------------------------------------------------------------- |
| ref   | React Ref | A ref created to fadeIn the element                                       |
| style | Object    | Style object containing `{opacity:0}` to give to the element as a default |

It's recommended to just spread the returned object on the element as shown in the Usage section above.
npm package: @ib-hooks/use-full-screen
Description: React Hook to make any element go full screen.
Author: Inwook Baek
Latest version: 1.0.1

# @ib-hooks/use-full-screen

React Hook to **make any element go full screen.**

## Installation

#### yarn

`yarn add @ib-hooks/use-full-screen`

#### npm

`npm i @ib-hooks/use-full-screen`

## Usage

```js
import React from "react";
import useFullScreen from "@ib-hooks/use-full-screen";

function App() {
  const onChange = (isFull) =>
    console.log(isFull ? "Full Screen Mode" : "Exit Full Screen");

  const { element, triggerFull, exitFull } = useFullscreen(onChange);

  return (
    <div ref={element}>
      <h1>Hello</h1>
      <button onClick={triggerFull}>Full Screen Mode</button>
      <button onClick={exitFull}>Exit Full Screen</button>
    </div>
  );
}
```

### Arguments

| Argument | Type     | Description                                                     | Arguments        | Required |
| -------- | -------- | --------------------------------------------------------------- | ---------------- | -------- |
| onChange | function | Function to be called when the screen goes full screen or exits | isFull : Boolean | no       |

### Return

`useFullScreen` returns an object containing the following:

| Return value | Type      | Description                                                 |
| ------------ | --------- | ----------------------------------------------------------- |
| element      | React Ref | Ref to add to the element that you want to make full screen |
| triggerFull  | Function  | Function to make the element enter full screen              |
| exitFull     | Function  | Function to make the document exit full screen              |
npm package: @ib-hooks/use-network
Description: React Hook to listen when the user goes online or offline.
Author: Inwook Baek
Latest version: 1.0.2

# @ib-hooks/use-network

React Hook to **listen when the user goes online or offline.**

## Installation

#### yarn

`yarn add @ib-hooks/use-network`

#### npm

`npm i @ib-hooks/use-network`

## Usage

```js
import React from "react";
import useNetwork from "@ib-hooks/use-network";

function App() {
  const onNetworkChange = (isOnline) =>
    console.log(isOnline ? "We are back online" : "We just got offline");

  const isOnline = useNetwork(onNetworkChange);

  return <h1>{isOnline ? "We are online" : "We are offline"}</h1>;
}
```

### Arguments

| Argument        | Type     | Description                                           | Arguments          | Required |
| --------------- | -------- | ----------------------------------------------------- | ------------------ | -------- |
| onNetworkChange | function | Function to be called when the network status changes | isOnline : Boolean | no       |

### Return

| Return value | Type    | Description                                         | Default value |
| ------------ | ------- | --------------------------------------------------- | ------------- |
| isOnline     | Boolean | A boolean representing if the user is online or not | true          |
npm package: @ib-hooks/use-notification
Description: React Hook to use browser notification easier.
Author: Inwook Baek
Latest version: 1.0.3

# @ib-hooks/use-notification

React Hook to **use browser notification easier.**

## Installation

#### yarn

`yarn add @ib-hooks/use-notification`

#### npm

`npm i @ib-hooks/use-notification`

## Usage

```js
import React from "react";
import useNotification from "@ib-hooks/use-notification";

function App() {
  const sendNotification = useNotification("Hello!");

  return <button onClick={sendNotification}>Send Hello</button>;
}
```

### Arguments

| **Argument** | **Type** | **Description**                                                                         | **Required** |
| ------------ | -------- | --------------------------------------------------------------------------------------- | ------------ |
| title        | string   | The text you want to notice.                                                            | yes          |
| options      | object   | [Reference](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) | no           |

### Return

| **Return value** | **Type** | **Description**                                                              |
| ---------------- | -------- | ---------------------------------------------------------------------------- |
| Functions        | object   | If a user grants a permission, notification can be send using this function. |
npm package: @ib-hooks/use-prevent-leave
Description: React Hook to prompt the user for confirmation before leaving the page.
Author: Inwook Baek
Latest version: 1.0.1

# @ib-hooks/use-prevent-leave

React Hook to **prompt the user for confirmation before leaving the page.**

## Installation

#### yarn

`yarn add @ib-hooks/use-prevent-leave`

#### npm

`npm i @ib-hooks/use-prevent-leave`

## Usage

```js
import React from "react";
import usePreventLeave from "@ib-hooks/use-prevent-leave";

function App() {
  const { enablePrevent, disablePrevent } = usePreventLeave();

  const saveChanges = async () => {
    enablePrevent();
    await sendToApi();
    disablePrevent();
  };

  return <button onClick={saveChanges}>Save Changes</button>;
}
```

### Return

| **Return value** | **Type** | **Description**                                                                                                                   |
| ---------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------- |
| Functions        | object   | An object containing functions `enablePrevent` and `disablePrevent`, use this functions to enable/disable the leaving prevention. |
npm package: @ib-hooks/use-scroll
Description: React Hook to get X/Y coordinates of current position of the scroll.
Author: Inwook Baek
Latest version: 1.0.3

# @ib-hooks/use-scroll

React Hook to **get X/Y coordinates of current position of the scroll.**

## Installation

#### yarn

`yarn add @ib-hooks/use-scroll`

#### npm

`npm i @ib-hooks/use-scroll`

## Usage

```js
import React from "react";
import useScroll from "@ib-hooks/use-scroll";

function App() {
  const { scrollX, scrollY } = useScroll();

  return (
    <h1>
      Scroll Location: {scrollX} / {scrollY}
    </h1>
  );
}
```

### Return

| Return value | Type   | Description                                                              | Default value            |
| ------------ | ------ | ------------------------------------------------------------------------ | ------------------------ |
| Coords       | object | An object containing the x, y coordinates of the current scroll position | `{scrollX:0, scrollY:0}` |
npm package: @ib-hooks/use-title
Description: React Hook to update your document's title
Author: Inwook Baek
Latest version: 1.0.2

# @ib-hooks/use-title

React Hook to **update your document's title.**

## Installation

#### yarn

`yarn add @ib-hooks/use-title`

#### npm

`npm i @ib-hooks/use-title`

## Usage

```js
import React from "react";
import useTitle from "@ib-hooks/use-title";

function App() {
  useTitle("Hello World");
  return <h1>Hello World</h1>;
}
```

### Arguments

| **Argument** | **Type** | **Description**                            | **Required** |
| ------------ | -------- | ------------------------------------------ | ------------ |
| title        | string   | The title you want to set on your document | yes          |