New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

web-instance

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web-instance

Manager the instances of a web page open multiple tabs/windows

latest
npmnpm
Version
1.0.7
Version published
Maintainers
1
Created
Source

web-instance

Manager the instances of a web page open multiple tabs/windows

Install

npm install web-instance

Usage

import WebInstance from 'web-instance'

// The basic
WebInstance
    .done((nodetype, status) => {
        console.log(nodetype) // master or slave
        console.log(status) // online or offline
    })
    .nextTick(() => {
        // this function will be called every x miliseconds, only while online
        // check WebInstance.tickMs
    })
    .on(WebInstance.ON_NODETYPE_CHANGED, (nodetype) => {
        console.log(nodetype) // master or slave
    })
    .on(WebInstance.ON_CONNECTION_STATUS, (status) => {
        console.log(status) // online or offline
    })

// Listening to a specific message
WebInstance
    .on('hi', (event) => {
        console.log('received', event.message)

        // Response
        return `hi ${event.from}, my uuid is ${WebInstance.uuid()}`
    })

// Listening to a localStorage key
    .watch('key', (event) => {
        console.log('value of key is', event.message)
    })

// Sending message
WebInstance
    .send('hi', `hi i'm ${WebInstance.uuid()}`)
    .then(responses => {
        // responses is an Array with all responses
        console.log('responses from "hi" message', responses)
    })

// Outhers methods
WebInstance.broadcast()    // return all nodes (Promisse)
WebInstance.exists('uuid') // return true if uuid exists (Promisse)
WebInstance.timeout(400)   // set timeout for responses, default is 400ms

Keywords

web

FAQs

Package last updated on 01 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts