Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-offline

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-offline

A tiny (174B) library to detect `offline` status & respond to changes in the browser.

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6K
decreased by-17.3%
Maintainers
1
Weekly downloads
 
Created
Source

is-offline Build Status

A tiny (174B) library to detect offline status & respond to changes in the browser.

This module exposes three module definitions:

  • ES Module: dist/is-offline.es.js
  • CommonJS: dist/is-offline.js
  • UMD: dist/is-offline.min.js

If using the UMD bundle, the library is exposed as is-offline globally.

Install

$ npm install --save is-offline

Usage

import { check, watch } from 'is-offline';

let foobar = bool => console.log('Am I offline?', bool);

// Check if currently offline
check().then(foobar);

// Setup a "watcher" to respond to all online/offline changes
let unwatch = watch(foobar);

// The "watcher" will be active until it's deactivated
unwatch();

API

isOffline.check()

Returns: Promise

Resolves a Boolean to indicate offline status. For clarity, true means that you are offline.

isOffline.watch(fn)

Returns: Function

Returns a function that is used to disable/unmount the event listeners.

fn

Type: Function

The function to run whenever the network status changes. It receives a Boolean value, just like isOffline.

License

MIT © Luke Edwards

Keywords

FAQs

Package last updated on 28 Dec 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc