Socket
Socket
Sign inDemoInstall

safe-window

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    safe-window

A utility for safely getting properties from the window object in projects that render on both the server and the client.


Version published
Weekly downloads
550
decreased by-36.49%
Maintainers
1
Install size
3.74 kB
Created
Weekly downloads
 

Readme

Source

safe-window

npm version

A utility for safely getting properties from the window object in projects that render on both the server and the client.

Installation

npm i -S safe-window

Usage

import safeWindow from 'safe-window';

window.foo = {bar: 'baz'}
safeWindow('foo.bar')
=> 'baz'
Works with arrays
window.foo = [{bar: 'baz'}]
safeWindow('foo.0.bar')
=> 'baz'
Window doesn't exist (server side)
safeWindow('foo.bar')
=> null

// With default
safeWindow('foo.bar', 'qux')
=> 'qux'

FAQs

Last updated on 08 Mar 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc