npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bifrost-cors

v1.0.4

Published

A cross-domain utility lib, for sharing localStorage, cookie and many more over the cross domain

Downloads

392

Readme

Bifrost-CORS

A cross-domain communication solution to share data and many more functionalities with simple as just calling a method.

Get Started

NPM Install

npm install bifrost-cors

CDN Link (6.39KB)

https://cdn.jsdelivr.net/gh/spurushottam13/bifrost-cors/index.min.js

GZIP version of File (1.7KB)

https://cdn.jsdelivr.net/gh/spurushottam13/bifrost-cors/index.min.gz

Functionalities can be performed on CROS Domain


All above methods are wrapped in a promise.


Initialize Bifrost-CORS You have to Initialize Bifrost-CORS in both domain
var bifrostCors = new bifrostCors(address, iframeBoolean,iframeId)	

| Parameter | Required | Value | | :------------- |:---------------------|:-----| | address | YES | Exact Address of the other domain| | iframeBoolean| No | true :- If you already rendering the other domain in iframe false If you are not rendering the other domain in iframe Default false | | iframeId| No | if iframeBoolean is set to true then you need to pass the ID for your Iframe in which you loading the other domain |


Implementation of methods and how to handle promise
var bifrostCors = new bifrostCors("http://example.com/",false)

//Calling Methods without promise
var result = bifrostCors.getLocalStorage(key)

//Hanlde Promise

//1. Using .then()
bifrostCors.getLocalStorage(key).then((data) => {
	console.log(data)
 })

//2. Using async function
async function grabLocalStorage(){
	let result = await  bifrostCors.getLocalStorage(key)
}

Functionalities

  • Cookies

    • Get Cookies
    // return type Object, return all cookies
    bifrostCors.getCookie() 
      
    // return type string
    bifrostCors.getCookie("key")
    • Set Cookies
    bifrostCors.setCookie(name,value,days)   
    • Parameter
      • name String, name for cookie
      • value String, value for cookie
      • days int, expiration days for cookie
    • return type Boolean
  • LocalStorage

    • Get local Storage
    // return type stirng
    bifrostCors.getgetLocalStorage("key") 
      
    // return type array
    bifrostCors.getLocalStorage(["key1","key2"])
    • Set local Storage
    // return type Boolean
    bifrostCors.setLocalStorage({key: "user", value: "user-1"}) 
    • Delete local Storage
    // return type Boolean
    bifrostCors.deleteLocalStorage("key") 
      
    // return type Boolean
    bifrostCors.deleteLocalStorage(["key1","key2"])
  • Bi-directional message thread

    • Request Message Thread
    // return type Boolean, parameter type funtion
    bifrostCors.requestMessageThread(Listner)

    Listner is your custom function which will be invoked every time new message recivied, and it should expect a new message as a parameter

    Here's exapmle

    function myCustomListner(newMessage){
    	cosnole.log("Hurray I got new message ",newMessage)
     }
       
     bifrostCors.requestMessageThread(myCustomListner)
    • Send Message
    // return type Boolean, parameter type string|int|array|object
    bifrostCors.send(message)
  • Run JS expression

    // return type Boolean, parameter type string
    bifrostCors.runExpression(expression)
  • DOM Manipulation

    • DOM Manipulation by ID
    // return type Boolean, parameter type string
    bifrostCors.domManipulationById("yourElementID")
    • DOM Manipulation by class name
    // return type Boolean, parameter type string,int,Objet
    bifrostCors.domManipulationById(class,index,style)
    • Parameter
      • class String your element class name
      • index int index no of that element in class array
      • style Object Style object
    • Example:a if you can access element by document.getElementsByClassName("myElementClass)[4] so parameter will be
      • class "myElementClass"
      • index 4
      • style {background:"red"}