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

@react-hookz/web

Package Overview
Dependencies
Maintainers
2
Versions
128
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 19.0.0 to 19.1.0

8

cjs/useStorageValue/useStorageValue.d.ts

@@ -15,2 +15,10 @@ import { NextState } from '../util/resolveHookState';

initializeWithValue?: InitializeWithValue;
/**
* Custom function to parse storage value with.
*/
parse?: (str: string | null, fallback: T | null) => T | null;
/**
* Custom function to stringify value to store with.
*/
stringify?: (data: unknown) => string | null;
}

@@ -17,0 +25,0 @@ declare type UseStorageValueValue<Type, Default extends Type = Type, Initialize extends boolean | undefined = boolean | undefined, N = Default extends null | undefined ? null | Type : Type, U = Initialize extends false | undefined ? undefined | N : N> = U;

14

cjs/useStorageValue/useStorageValue.js

@@ -88,2 +88,12 @@ "use strict";

var optionsRef = (0, useSyncedRef_1.useSyncedRef)(__assign(__assign({}, DEFAULT_OPTIONS), options));
var parse = function (str, fallback) {
var _a;
var parseFunction = (_a = optionsRef.current.parse) !== null && _a !== void 0 ? _a : defaultParse;
return parseFunction(str, fallback);
};
var stringify = function (data) {
var _a;
var stringifyFunction = (_a = optionsRef.current.stringify) !== null && _a !== void 0 ? _a : defaultStringify;
return stringifyFunction(data);
};
var storageActions = (0, useSyncedRef_1.useSyncedRef)({

@@ -165,3 +175,3 @@ fetchRaw: function () { return storage.getItem(key); },

exports.useStorageValue = useStorageValue;
var stringify = function (data) {
var defaultStringify = function (data) {
if (data === null) {

@@ -186,3 +196,3 @@ /* istanbul ignore next */

};
var parse = function (str, fallback) {
var defaultParse = function (str, fallback) {
if (str === null)

@@ -189,0 +199,0 @@ return fallback;

@@ -15,2 +15,10 @@ import { NextState } from '../util/resolveHookState';

initializeWithValue?: InitializeWithValue;
/**
* Custom function to parse storage value with.
*/
parse?: (str: string | null, fallback: T | null) => T | null;
/**
* Custom function to stringify value to store with.
*/
stringify?: (data: unknown) => string | null;
}

@@ -17,0 +25,0 @@ declare type UseStorageValueValue<Type, Default extends Type = Type, Initialize extends boolean | undefined = boolean | undefined, N = Default extends null | undefined ? null | Type : Type, U = Initialize extends false | undefined ? undefined | N : N> = U;

@@ -85,2 +85,12 @@ var __assign = (this && this.__assign) || function () {

var optionsRef = useSyncedRef(__assign(__assign({}, DEFAULT_OPTIONS), options));
var parse = function (str, fallback) {
var _a;
var parseFunction = (_a = optionsRef.current.parse) !== null && _a !== void 0 ? _a : defaultParse;
return parseFunction(str, fallback);
};
var stringify = function (data) {
var _a;
var stringifyFunction = (_a = optionsRef.current.stringify) !== null && _a !== void 0 ? _a : defaultStringify;
return stringifyFunction(data);
};
var storageActions = useSyncedRef({

@@ -161,3 +171,3 @@ fetchRaw: function () { return storage.getItem(key); },

}
var stringify = function (data) {
var defaultStringify = function (data) {
if (data === null) {

@@ -182,3 +192,3 @@ /* istanbul ignore next */

};
var parse = function (str, fallback) {
var defaultParse = function (str, fallback) {
if (str === null)

@@ -185,0 +195,0 @@ return fallback;

@@ -15,2 +15,10 @@ import { NextState } from '../util/resolveHookState';

initializeWithValue?: InitializeWithValue;
/**
* Custom function to parse storage value with.
*/
parse?: (str: string | null, fallback: T | null) => T | null;
/**
* Custom function to stringify value to store with.
*/
stringify?: (data: unknown) => string | null;
}

@@ -17,0 +25,0 @@ declare type UseStorageValueValue<Type, Default extends Type = Type, Initialize extends boolean | undefined = boolean | undefined, N = Default extends null | undefined ? null | Type : Type, U = Initialize extends false | undefined ? undefined | N : N> = U;

@@ -74,2 +74,10 @@ /* eslint-disable @typescript-eslint/no-use-before-define,no-use-before-define */

const optionsRef = useSyncedRef({ ...DEFAULT_OPTIONS, ...options });
const parse = (str, fallback) => {
const parseFunction = optionsRef.current.parse ?? defaultParse;
return parseFunction(str, fallback);
};
const stringify = (data) => {
const stringifyFunction = optionsRef.current.stringify ?? defaultStringify;
return stringifyFunction(data);
};
const storageActions = useSyncedRef({

@@ -151,3 +159,3 @@ fetchRaw: () => storage.getItem(key),

}
const stringify = (data) => {
const defaultStringify = (data) => {
if (data === null) {

@@ -172,3 +180,3 @@ /* istanbul ignore next */

};
const parse = (str, fallback) => {
const defaultParse = (str, fallback) => {
if (str === null)

@@ -175,0 +183,0 @@ return fallback;

2

package.json
{
"name": "@react-hookz/web",
"version": "19.0.0",
"version": "19.1.0",
"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