# crossbow-of-cors

> A cross-domain utility lib, for sharing localStorage (LiSa Team)

Latest version **1.0.1** (published 2022-11-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install crossbow-of-cors
pnpm add crossbow-of-cors
yarn add crossbow-of-cors
bun add crossbow-of-cors
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-11-29 |
| First published | 2022-11-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Torikul Azis |
| Maintainers | thoriq29 |

## Links

- npm: https://www.npmjs.com/package/crossbow-of-cors
- npm.io page: https://npm.io/package/crossbow-of-cors

## Recent versions

- 1.0.1 (latest) — 2022-11-29
- 1.0.0 — 2022-11-29

## README

# Crossbow of CORS
###### A simple cross-domain communication solution to share data .

## Get Started

### NPM Install
> __npm i crossbow-of-cors__

#### Functionalities can be performed on CROSS Domain
 -------------
- ###### [Get, Set & Delete  Local Storage]

#### How to implement methods and promise handling


| Parameter        | Required           | Value  |
| :------------- |:---------------------|:-----|
| host      | Yes | Exact Address of the other domain|
| useIframe| No     |  <b>true</b> : If you want to create & render other iframe domain <br> <b>false</b>: If you are not rendering the other domain in iframe (use message listener only) <br> Default <b>false</b> |
| iframeID | No     |  If you want to render iframe that you created in outside lib, set __useIframe__=false, and pass your iframe element ID to __iframeID__    |

---

#### Setup
```javascript
    // publisher or messenger (example.com)
    var crossbow = new  CrossbowPublisher("http://example2.com", true)
    
    // receiver or listener (example2.com)
    new CrossbowListener("http://example.com").init()
```
#### Example
```javascript
var crossbow = new  CrossbowPublisher("http://localhost:3001", true)

//Calling Methods without promise
var result = crossbow.getLocalStorage(key)

//Promise
//1. Using .then()
crossbow.getLocalStorage(key).then((data) => {
	console.log(data)
 })

//2. Using async function
async function getData(){
	let result = await  crossbow.getLocalStorage(key)
}
```

#### Functionalities
* __LocalStorage__	
	* __Get local Storage__
	```javascript
    // return type string
    crossbow.getLocalStorage("key") 
    
    // return type array
    crossbow.getLocalStorage(["key1","key2"])
    ```
    
    * __Set local Storage__
	```javascript
    // return type Boolean
    crossbow.setLocalStorage({key: "user", value: "user-1"}) 
    ```
    
    * __Delete local Storage__
	```javascript
    // return type Boolean
    crossbow.deleteLocalStorage("key") 
    
    // return type Boolean
    crossbow.deleteLocalStorage(["key1","key2"])
    ```

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