New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@react-hookz/web

Package Overview
Dependencies
Maintainers
2
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-hookz/web - npm Package Compare versions

Comparing version 12.1.0 to 12.1.1

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [12.1.1](https://github.com/react-hookz/web/compare/v12.1.0...v12.1.1) (2022-01-11)
### Bug Fixes
* **`useLocalStorage`, `useSessionStorage`:** replace hook with noop in case of storage absence. ([#540](https://github.com/react-hookz/web/issues/540)) ([790b302](https://github.com/react-hookz/web/commit/790b30257a15e936f5c4d776917fc2dd6dcad931)), closes [#521](https://github.com/react-hookz/web/issues/521)
# [12.1.0](https://github.com/react-hookz/web/compare/v12.0.3...v12.1.0) (2022-01-11)

@@ -2,0 +9,0 @@

21

cjs/useLocalStorageValue/useLocalStorageValue.d.ts
import { IHookReturn, IUseStorageValueOptions } from '../useStorageValue/useStorageValue';
export declare function useLocalStorageValue<T = unknown>(key: string, defaultValue?: null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
export declare function useLocalStorageValue<T = unknown>(key: string, defaultValue: null, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
export declare function useLocalStorageValue<T>(key: string, defaultValue: T, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
export declare function useLocalStorageValue<T>(key: string, defaultValue: T, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
export declare function useLocalStorageValue<T>(key: string, defaultValue?: T | null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, typeof options>;
interface IUseLocalStorageValue {
<T = unknown>(key: string, defaultValue?: null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
<T = unknown>(key: string, defaultValue: null, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
<T>(key: string, defaultValue: T, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
<T>(key: string, defaultValue: T, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
<T>(key: string, defaultValue?: T | null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, typeof options>;
}
/**
* Manages a single localStorage key.
*
* @param key Storage key to manage
* @param defaultValue Default value to yield in case the key is not in storage
* @param options
*/
export declare const useLocalStorageValue: IUseLocalStorageValue;
export {};

@@ -6,2 +6,11 @@ "use strict";

var const_1 = require("../util/const");
var IS_LOCAL_STORAGE_AVAILABLE = false;
try {
IS_LOCAL_STORAGE_AVAILABLE = const_1.isBrowser && !!window.localStorage;
}
catch (_a) {
// no need to test this flag leads to noop behaviour
/* istanbul ignore next */
IS_LOCAL_STORAGE_AVAILABLE = false;
}
/**

@@ -14,7 +23,16 @@ * Manages a single localStorage key.

*/
function useLocalStorageValue(key, defaultValue, options) {
if (defaultValue === void 0) { defaultValue = null; }
if (options === void 0) { options = {}; }
return (0, useStorageValue_1.useStorageValue)(const_1.isBrowser ? localStorage : {}, key, defaultValue, options);
}
exports.useLocalStorageValue = useLocalStorageValue;
exports.useLocalStorageValue = IS_LOCAL_STORAGE_AVAILABLE
? function (key, defaultValue, options) {
if (defaultValue === void 0) { defaultValue = null; }
if (options === void 0) { options = {}; }
return (0, useStorageValue_1.useStorageValue)(const_1.isBrowser ? localStorage : {}, key, defaultValue, options);
}
: function (key, defaultValue, options) {
if (defaultValue === void 0) { defaultValue = null; }
if (options === void 0) { options = {}; }
/* istanbul ignore next */
if (const_1.isBrowser && process.env.NODE_ENV === 'development') {
console.warn('LocalStorage is not available in this environment');
}
return [undefined, const_1.noop, const_1.noop, const_1.noop];
};
import { IHookReturn, IUseStorageValueOptions } from '../useStorageValue/useStorageValue';
export declare function useSessionStorageValue<T = unknown>(key: string, defaultValue?: null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
export declare function useSessionStorageValue<T = unknown>(key: string, defaultValue: null, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
export declare function useSessionStorageValue<T>(key: string, defaultValue: T, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
export declare function useSessionStorageValue<T>(key: string, defaultValue: T, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
export declare function useSessionStorageValue<T>(key: string, defaultValue?: T | null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, typeof options>;
interface IUseSessionStorageValue {
<T = unknown>(key: string, defaultValue?: null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
<T = unknown>(key: string, defaultValue: null, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
<T>(key: string, defaultValue: T, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
<T>(key: string, defaultValue: T, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
<T>(key: string, defaultValue?: T | null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, typeof options>;
}
/**
* Manages a single sessionStorage key.
*
* @param key Storage key to manage
* @param defaultValue Default value to yield in case the key is not in storage
* @param options
*/
export declare const useSessionStorageValue: IUseSessionStorageValue;
export {};

@@ -6,2 +6,11 @@ "use strict";

var const_1 = require("../util/const");
var IS_SESSION_STORAGE_AVAILABLE = false;
try {
IS_SESSION_STORAGE_AVAILABLE = const_1.isBrowser && !!window.sessionStorage;
}
catch (_a) {
// no need to test this flag leads to noop behaviour
/* istanbul ignore next */
IS_SESSION_STORAGE_AVAILABLE = false;
}
/**

@@ -14,7 +23,16 @@ * Manages a single sessionStorage key.

*/
function useSessionStorageValue(key, defaultValue, options) {
if (defaultValue === void 0) { defaultValue = null; }
if (options === void 0) { options = {}; }
return (0, useStorageValue_1.useStorageValue)(const_1.isBrowser ? sessionStorage : {}, key, defaultValue, options);
}
exports.useSessionStorageValue = useSessionStorageValue;
exports.useSessionStorageValue = IS_SESSION_STORAGE_AVAILABLE
? function (key, defaultValue, options) {
if (defaultValue === void 0) { defaultValue = null; }
if (options === void 0) { options = {}; }
return (0, useStorageValue_1.useStorageValue)(const_1.isBrowser ? sessionStorage : {}, key, defaultValue, options);
}
: function (key, defaultValue, options) {
if (defaultValue === void 0) { defaultValue = null; }
if (options === void 0) { options = {}; }
/* istanbul ignore next */
if (const_1.isBrowser && process.env.NODE_ENV === 'development') {
console.warn('SessionStorage is not available in this environment');
}
return [undefined, const_1.noop, const_1.noop, const_1.noop];
};
import { IHookReturn, IUseStorageValueOptions } from '../useStorageValue/useStorageValue';
export declare function useLocalStorageValue<T = unknown>(key: string, defaultValue?: null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
export declare function useLocalStorageValue<T = unknown>(key: string, defaultValue: null, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
export declare function useLocalStorageValue<T>(key: string, defaultValue: T, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
export declare function useLocalStorageValue<T>(key: string, defaultValue: T, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
export declare function useLocalStorageValue<T>(key: string, defaultValue?: T | null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, typeof options>;
interface IUseLocalStorageValue {
<T = unknown>(key: string, defaultValue?: null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
<T = unknown>(key: string, defaultValue: null, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
<T>(key: string, defaultValue: T, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
<T>(key: string, defaultValue: T, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
<T>(key: string, defaultValue?: T | null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, typeof options>;
}
/**
* Manages a single localStorage key.
*
* @param key Storage key to manage
* @param defaultValue Default value to yield in case the key is not in storage
* @param options
*/
export declare const useLocalStorageValue: IUseLocalStorageValue;
export {};
import { useStorageValue, } from "../useStorageValue/useStorageValue.js";
import { isBrowser } from "../util/const.js";
import { isBrowser, noop } from "../util/const.js";
var IS_LOCAL_STORAGE_AVAILABLE = false;
try {
IS_LOCAL_STORAGE_AVAILABLE = isBrowser && !!window.localStorage;
}
catch (_a) {
// no need to test this flag leads to noop behaviour
/* istanbul ignore next */
IS_LOCAL_STORAGE_AVAILABLE = false;
}
/**

@@ -10,6 +19,16 @@ * Manages a single localStorage key.

*/
export function useLocalStorageValue(key, defaultValue, options) {
if (defaultValue === void 0) { defaultValue = null; }
if (options === void 0) { options = {}; }
return useStorageValue(isBrowser ? localStorage : {}, key, defaultValue, options);
}
export var useLocalStorageValue = IS_LOCAL_STORAGE_AVAILABLE
? function (key, defaultValue, options) {
if (defaultValue === void 0) { defaultValue = null; }
if (options === void 0) { options = {}; }
return useStorageValue(isBrowser ? localStorage : {}, key, defaultValue, options);
}
: function (key, defaultValue, options) {
if (defaultValue === void 0) { defaultValue = null; }
if (options === void 0) { options = {}; }
/* istanbul ignore next */
if (isBrowser && process.env.NODE_ENV === 'development') {
console.warn('LocalStorage is not available in this environment');
}
return [undefined, noop, noop, noop];
};
import { IHookReturn, IUseStorageValueOptions } from '../useStorageValue/useStorageValue';
export declare function useSessionStorageValue<T = unknown>(key: string, defaultValue?: null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
export declare function useSessionStorageValue<T = unknown>(key: string, defaultValue: null, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
export declare function useSessionStorageValue<T>(key: string, defaultValue: T, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
export declare function useSessionStorageValue<T>(key: string, defaultValue: T, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
export declare function useSessionStorageValue<T>(key: string, defaultValue?: T | null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, typeof options>;
interface IUseSessionStorageValue {
<T = unknown>(key: string, defaultValue?: null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
<T = unknown>(key: string, defaultValue: null, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
<T>(key: string, defaultValue: T, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
<T>(key: string, defaultValue: T, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
<T>(key: string, defaultValue?: T | null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, typeof options>;
}
/**
* Manages a single sessionStorage key.
*
* @param key Storage key to manage
* @param defaultValue Default value to yield in case the key is not in storage
* @param options
*/
export declare const useSessionStorageValue: IUseSessionStorageValue;
export {};
import { useStorageValue, } from "../useStorageValue/useStorageValue.js";
import { isBrowser } from "../util/const.js";
import { isBrowser, noop } from "../util/const.js";
var IS_SESSION_STORAGE_AVAILABLE = false;
try {
IS_SESSION_STORAGE_AVAILABLE = isBrowser && !!window.sessionStorage;
}
catch (_a) {
// no need to test this flag leads to noop behaviour
/* istanbul ignore next */
IS_SESSION_STORAGE_AVAILABLE = false;
}
/**

@@ -10,6 +19,16 @@ * Manages a single sessionStorage key.

*/
export function useSessionStorageValue(key, defaultValue, options) {
if (defaultValue === void 0) { defaultValue = null; }
if (options === void 0) { options = {}; }
return useStorageValue(isBrowser ? sessionStorage : {}, key, defaultValue, options);
}
export var useSessionStorageValue = IS_SESSION_STORAGE_AVAILABLE
? function (key, defaultValue, options) {
if (defaultValue === void 0) { defaultValue = null; }
if (options === void 0) { options = {}; }
return useStorageValue(isBrowser ? sessionStorage : {}, key, defaultValue, options);
}
: function (key, defaultValue, options) {
if (defaultValue === void 0) { defaultValue = null; }
if (options === void 0) { options = {}; }
/* istanbul ignore next */
if (isBrowser && process.env.NODE_ENV === 'development') {
console.warn('SessionStorage is not available in this environment');
}
return [undefined, noop, noop, noop];
};
import { IHookReturn, IUseStorageValueOptions } from '../useStorageValue/useStorageValue';
export declare function useLocalStorageValue<T = unknown>(key: string, defaultValue?: null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
export declare function useLocalStorageValue<T = unknown>(key: string, defaultValue: null, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
export declare function useLocalStorageValue<T>(key: string, defaultValue: T, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
export declare function useLocalStorageValue<T>(key: string, defaultValue: T, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
export declare function useLocalStorageValue<T>(key: string, defaultValue?: T | null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, typeof options>;
interface IUseLocalStorageValue {
<T = unknown>(key: string, defaultValue?: null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
<T = unknown>(key: string, defaultValue: null, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
<T>(key: string, defaultValue: T, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
<T>(key: string, defaultValue: T, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
<T>(key: string, defaultValue?: T | null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, typeof options>;
}
/**
* Manages a single localStorage key.
*
* @param key Storage key to manage
* @param defaultValue Default value to yield in case the key is not in storage
* @param options
*/
export declare const useLocalStorageValue: IUseLocalStorageValue;
export {};
import { useStorageValue, } from "../useStorageValue/useStorageValue.js";
import { isBrowser } from "../util/const.js";
import { isBrowser, noop } from "../util/const.js";
let IS_LOCAL_STORAGE_AVAILABLE = false;
try {
IS_LOCAL_STORAGE_AVAILABLE = isBrowser && !!window.localStorage;
}
catch {
// no need to test this flag leads to noop behaviour
/* istanbul ignore next */
IS_LOCAL_STORAGE_AVAILABLE = false;
}
/**

@@ -10,4 +19,10 @@ * Manages a single localStorage key.

*/
export function useLocalStorageValue(key, defaultValue = null, options = {}) {
return useStorageValue(isBrowser ? localStorage : {}, key, defaultValue, options);
}
export const useLocalStorageValue = IS_LOCAL_STORAGE_AVAILABLE
? (key, defaultValue = null, options = {}) => useStorageValue(isBrowser ? localStorage : {}, key, defaultValue, options)
: (key, defaultValue = null, options = {}) => {
/* istanbul ignore next */
if (isBrowser && process.env.NODE_ENV === 'development') {
console.warn('LocalStorage is not available in this environment');
}
return [undefined, noop, noop, noop];
};
import { IHookReturn, IUseStorageValueOptions } from '../useStorageValue/useStorageValue';
export declare function useSessionStorageValue<T = unknown>(key: string, defaultValue?: null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
export declare function useSessionStorageValue<T = unknown>(key: string, defaultValue: null, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
export declare function useSessionStorageValue<T>(key: string, defaultValue: T, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
export declare function useSessionStorageValue<T>(key: string, defaultValue: T, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
export declare function useSessionStorageValue<T>(key: string, defaultValue?: T | null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, typeof options>;
interface IUseSessionStorageValue {
<T = unknown>(key: string, defaultValue?: null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
<T = unknown>(key: string, defaultValue: null, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
<T>(key: string, defaultValue: T, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, IUseStorageValueOptions<true | undefined>>;
<T>(key: string, defaultValue: T, options: IUseStorageValueOptions<false>): IHookReturn<T, typeof defaultValue, typeof options>;
<T>(key: string, defaultValue?: T | null, options?: IUseStorageValueOptions): IHookReturn<T, typeof defaultValue, typeof options>;
}
/**
* Manages a single sessionStorage key.
*
* @param key Storage key to manage
* @param defaultValue Default value to yield in case the key is not in storage
* @param options
*/
export declare const useSessionStorageValue: IUseSessionStorageValue;
export {};
import { useStorageValue, } from "../useStorageValue/useStorageValue.js";
import { isBrowser } from "../util/const.js";
import { isBrowser, noop } from "../util/const.js";
let IS_SESSION_STORAGE_AVAILABLE = false;
try {
IS_SESSION_STORAGE_AVAILABLE = isBrowser && !!window.sessionStorage;
}
catch {
// no need to test this flag leads to noop behaviour
/* istanbul ignore next */
IS_SESSION_STORAGE_AVAILABLE = false;
}
/**

@@ -10,4 +19,10 @@ * Manages a single sessionStorage key.

*/
export function useSessionStorageValue(key, defaultValue = null, options = {}) {
return useStorageValue(isBrowser ? sessionStorage : {}, key, defaultValue, options);
}
export const useSessionStorageValue = IS_SESSION_STORAGE_AVAILABLE
? (key, defaultValue = null, options = {}) => useStorageValue(isBrowser ? sessionStorage : {}, key, defaultValue, options)
: (key, defaultValue = null, options = {}) => {
/* istanbul ignore next */
if (isBrowser && process.env.NODE_ENV === 'development') {
console.warn('SessionStorage is not available in this environment');
}
return [undefined, noop, noop, noop];
};
{
"name": "@react-hookz/web",
"version": "12.1.0",
"version": "12.1.1",
"description": "React hooks done right, for browser and SSR.",

@@ -5,0 +5,0 @@ "keywords": [

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