@axelarjs/utils
Advanced tools
Comparing version 0.0.0-snapshot.7aa3516 to 0.0.0-snapshot.8af9be9
@@ -7,9 +7,9 @@ "use strict"; | ||
exports.memoizeWith = exports.sortWith = exports.descend = exports.ascend = void 0; | ||
var ascend_1 = require("ramda/es/ascend"); | ||
var ascend_1 = require("ramda/src/ascend"); | ||
Object.defineProperty(exports, "ascend", { enumerable: true, get: function () { return __importDefault(ascend_1).default; } }); | ||
var descend_1 = require("ramda/es/descend"); | ||
var descend_1 = require("ramda/src/descend"); | ||
Object.defineProperty(exports, "descend", { enumerable: true, get: function () { return __importDefault(descend_1).default; } }); | ||
var sortWith_1 = require("ramda/es/sortWith"); | ||
var sortWith_1 = require("ramda/src/sortWith"); | ||
Object.defineProperty(exports, "sortWith", { enumerable: true, get: function () { return __importDefault(sortWith_1).default; } }); | ||
var memoizeWith_1 = require("ramda/es/memoizeWith"); | ||
var memoizeWith_1 = require("ramda/src/memoizeWith"); | ||
Object.defineProperty(exports, "memoizeWith", { enumerable: true, get: function () { return __importDefault(memoizeWith_1).default; } }); |
@@ -1,4 +0,4 @@ | ||
export { default as ascend } from "ramda/es/ascend"; | ||
export { default as descend } from "ramda/es/descend"; | ||
export { default as sortWith } from "ramda/es/sortWith"; | ||
export { default as memoizeWith } from "ramda/es/memoizeWith"; | ||
export { default as ascend } from "ramda/src/ascend"; | ||
export { default as descend } from "ramda/src/descend"; | ||
export { default as sortWith } from "ramda/src/sortWith"; | ||
export { default as memoizeWith } from "ramda/src/memoizeWith"; |
@@ -7,9 +7,9 @@ "use strict"; | ||
exports.memoizeWith = exports.sortWith = exports.descend = exports.ascend = void 0; | ||
var ascend_1 = require("ramda/es/ascend"); | ||
var ascend_1 = require("ramda/src/ascend"); | ||
Object.defineProperty(exports, "ascend", { enumerable: true, get: function () { return __importDefault(ascend_1).default; } }); | ||
var descend_1 = require("ramda/es/descend"); | ||
var descend_1 = require("ramda/src/descend"); | ||
Object.defineProperty(exports, "descend", { enumerable: true, get: function () { return __importDefault(descend_1).default; } }); | ||
var sortWith_1 = require("ramda/es/sortWith"); | ||
var sortWith_1 = require("ramda/src/sortWith"); | ||
Object.defineProperty(exports, "sortWith", { enumerable: true, get: function () { return __importDefault(sortWith_1).default; } }); | ||
var memoizeWith_1 = require("ramda/es/memoizeWith"); | ||
var memoizeWith_1 = require("ramda/src/memoizeWith"); | ||
Object.defineProperty(exports, "memoizeWith", { enumerable: true, get: function () { return __importDefault(memoizeWith_1).default; } }); |
@@ -12,3 +12,3 @@ "use strict"; | ||
camelCase: (input) => input.charAt(0).toLowerCase() + | ||
input.slice(1).replace(/_(\w)/g, (_, char) => char.toUpperCase()), | ||
input.slice(1).replace(/_(\w)/g, (_, char) => String(char).toUpperCase()), | ||
"kebab-case": (input) => input | ||
@@ -25,3 +25,3 @@ .split(/(?=[A-Z])/) | ||
CONSTANT_CASE: (input) => input.toUpperCase(), | ||
camelCase: (input) => input.replace(/_(\w)/g, (_, char) => char.toUpperCase()), | ||
camelCase: (input) => input.replace(/_(\w)/g, (_, char) => String(char).toUpperCase()), | ||
"kebab-case": (input) => input.replace(/_/g, "-"), | ||
@@ -50,3 +50,3 @@ }, | ||
.slice(1) | ||
.replace(/_(\w)/g, (_, char) => char.toUpperCase()) | ||
.replace(/_(\w)/g, (_, char) => String(char).toUpperCase()) | ||
.replace(/(\w)([A-Z])/g, (_, first, second) => `${first}${second}`), | ||
@@ -66,3 +66,3 @@ snake_case: (input) => input.replace(/(\w)([A-Z])/g, (_, first, second) => `${first}_${second}`), | ||
CONSTANT_CASE: (input) => input.toUpperCase().replace(/-/g, "_"), | ||
camelCase: (input) => input.replace(/-(\w)/g, (_, char) => char.toUpperCase()), | ||
camelCase: (input) => input.replace(/-(\w)/g, (_, char) => String(char).toUpperCase()), | ||
}, | ||
@@ -69,0 +69,0 @@ }; |
export { default as throttle } from "lodash.throttle"; | ||
export { default as debounce } from "lodash.debounce"; | ||
type FN<T, R> = (arg: T) => R; | ||
/** | ||
* Memoize a function | ||
* | ||
* memoized function will cache the result of the function call | ||
* | ||
* @param func function to memoize | ||
* @returns memoized function | ||
*/ | ||
export declare function memoize<T, R>(func: FN<T, R>): FN<T, R>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.debounce = exports.throttle = void 0; | ||
exports.memoize = exports.debounce = exports.throttle = void 0; | ||
var lodash_throttle_1 = require("lodash.throttle"); | ||
@@ -12,1 +12,22 @@ Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return __importDefault(lodash_throttle_1).default; } }); | ||
Object.defineProperty(exports, "debounce", { enumerable: true, get: function () { return __importDefault(lodash_debounce_1).default; } }); | ||
/** | ||
* Memoize a function | ||
* | ||
* memoized function will cache the result of the function call | ||
* | ||
* @param func function to memoize | ||
* @returns memoized function | ||
*/ | ||
function memoize(func) { | ||
const cache = new Map(); | ||
return (arg) => { | ||
const cachedResult = cache.get(arg); | ||
if (cachedResult !== undefined) { | ||
return cachedResult; | ||
} | ||
const result = func(arg); | ||
cache.set(arg, result); | ||
return result; | ||
}; | ||
} | ||
exports.memoize = memoize; |
@@ -1,2 +0,1 @@ | ||
export * from "./array"; | ||
export * from "./guard"; | ||
@@ -10,2 +9,4 @@ export * from "./monad"; | ||
export * from "./hex"; | ||
export * from "./poll"; | ||
export * from "./sleep"; | ||
export { default as invariant } from "tiny-invariant"; |
@@ -21,3 +21,2 @@ "use strict"; | ||
exports.invariant = void 0; | ||
__exportStar(require("./array"), exports); | ||
__exportStar(require("./guard"), exports); | ||
@@ -31,3 +30,5 @@ __exportStar(require("./monad"), exports); | ||
__exportStar(require("./hex"), exports); | ||
__exportStar(require("./poll"), exports); | ||
__exportStar(require("./sleep"), exports); | ||
var tiny_invariant_1 = require("tiny-invariant"); | ||
Object.defineProperty(exports, "invariant", { enumerable: true, get: function () { return __importDefault(tiny_invariant_1).default; } }); |
@@ -1,2 +0,2 @@ | ||
import { DependencyList, EffectCallback } from "react"; | ||
import { type DependencyList, type EffectCallback } from "react"; | ||
export declare const useChangedEffect: (effect: EffectCallback, deps?: DependencyList) => void; |
@@ -1,4 +0,4 @@ | ||
import { Draft } from "immer"; | ||
import { type Draft } from "immer"; | ||
export declare function usePersistedState<T>(storage: Storage, key: string, defaultValue: T): readonly [T, (valueOrProducerFn: T | ((draft: Draft<T>) => void)) => void]; | ||
export declare function useLocalStorageState<T>(key: string, defaultValue: T): readonly [T, (valueOrProducerFn: T | ((draft: Draft<T>) => void)) => void]; | ||
export declare function useSessionStorageState<T>(key: string, defaultValue: T): readonly [T, (valueOrProducerFn: T | ((draft: Draft<T>) => void)) => void]; |
@@ -8,3 +8,5 @@ "use strict"; | ||
function usePersistedState(storage, key, defaultValue) { | ||
const [state, _setState] = (0, react_1.useState)(() => monad_1.Maybe.of(storage.getItem(key)).mapOr(defaultValue, JSON.parse)); | ||
const [state, _setState] = (0, react_1.useState)(() => | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
monad_1.Maybe.of(storage.getItem(key)).mapOr(defaultValue, JSON.parse)); | ||
(0, react_1.useEffect)(() => { | ||
@@ -11,0 +13,0 @@ storage.setItem(key, JSON.stringify(state)); |
@@ -8,2 +8,3 @@ "use strict"; | ||
(0, react_1.useEffect)(() => { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
ref.current = value; | ||
@@ -10,0 +11,0 @@ }, [value]); |
import type { AnyRecord, PluralizeKeys } from "./types"; | ||
export declare const caseInsensitiveRecord: <T>(record: Record<string, T>) => Record<string, T>; | ||
export declare function pluralizeKeys<T extends AnyRecord>(obj: T): PluralizeKeys<T>; | ||
export declare const invert: <T extends Record<string, string>>(obj: T) => { [K in keyof T as T[K]]: K; }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pluralizeKeys = exports.caseInsensitiveRecord = void 0; | ||
exports.invert = exports.pluralizeKeys = exports.caseInsensitiveRecord = void 0; | ||
const caseInsensitiveRecord = (record) => new Proxy(record, { | ||
@@ -21,8 +21,7 @@ get(target, p) { | ||
function pluralizeKeys(obj) { | ||
const nextEntries = Object.entries(obj).map(([key, value]) => [ | ||
`${key}s`, | ||
value, | ||
]); | ||
const nextEntries = Object.entries(obj).map(([key, value]) => [`${key}s`, value]); | ||
return Object.fromEntries(nextEntries); | ||
} | ||
exports.pluralizeKeys = pluralizeKeys; | ||
const invert = (obj) => Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k])); | ||
exports.invert = invert; |
@@ -10,1 +10,9 @@ export declare const isNilOrWhitespace: (value: string | undefined | null) => value is null | undefined; | ||
export declare function generateRandomHash(bits?: 8 | 16 | 24 | 32): `0x${string}`; | ||
/** | ||
* Compare two strings, ignoring case | ||
* | ||
* @param a | ||
* @param b | ||
* @returns | ||
*/ | ||
export declare function caseInsensitiveEqual(a: string | undefined, b: string | undefined): boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateRandomHash = exports.maskAddress = exports.unSluggify = exports.sluggify = exports.capitalize = exports.isNilOrWhitespace = void 0; | ||
exports.caseInsensitiveEqual = exports.generateRandomHash = exports.maskAddress = exports.unSluggify = exports.sluggify = exports.capitalize = exports.isNilOrWhitespace = void 0; | ||
const isNilOrWhitespace = (value) => { var _a; return ((_a = value === null || value === void 0 ? void 0 : value.trim()) !== null && _a !== void 0 ? _a : "") === ""; }; | ||
@@ -26,1 +26,12 @@ exports.isNilOrWhitespace = isNilOrWhitespace; | ||
exports.generateRandomHash = generateRandomHash; | ||
/** | ||
* Compare two strings, ignoring case | ||
* | ||
* @param a | ||
* @param b | ||
* @returns | ||
*/ | ||
function caseInsensitiveEqual(a, b) { | ||
return (a === null || a === void 0 ? void 0 : a.toLowerCase()) === (b === null || b === void 0 ? void 0 : b.toLowerCase()); | ||
} | ||
exports.caseInsensitiveEqual = caseInsensitiveEqual; |
@@ -1,4 +0,4 @@ | ||
export { default as ascend } from "ramda/es/ascend"; | ||
export { default as descend } from "ramda/es/descend"; | ||
export { default as sortWith } from "ramda/es/sortWith"; | ||
export { default as memoizeWith } from "ramda/es/memoizeWith"; | ||
export { default as ascend } from "ramda/src/ascend"; | ||
export { default as descend } from "ramda/src/descend"; | ||
export { default as sortWith } from "ramda/src/sortWith"; | ||
export { default as memoizeWith } from "ramda/src/memoizeWith"; |
@@ -1,4 +0,4 @@ | ||
export { default as ascend } from "ramda/es/ascend"; | ||
export { default as descend } from "ramda/es/descend"; | ||
export { default as sortWith } from "ramda/es/sortWith"; | ||
export { default as memoizeWith } from "ramda/es/memoizeWith"; | ||
export { default as ascend } from "ramda/src/ascend"; | ||
export { default as descend } from "ramda/src/descend"; | ||
export { default as sortWith } from "ramda/src/sortWith"; | ||
export { default as memoizeWith } from "ramda/src/memoizeWith"; |
@@ -9,3 +9,3 @@ export const CONVERTERS = { | ||
camelCase: (input) => input.charAt(0).toLowerCase() + | ||
input.slice(1).replace(/_(\w)/g, (_, char) => char.toUpperCase()), | ||
input.slice(1).replace(/_(\w)/g, (_, char) => String(char).toUpperCase()), | ||
"kebab-case": (input) => input | ||
@@ -22,3 +22,3 @@ .split(/(?=[A-Z])/) | ||
CONSTANT_CASE: (input) => input.toUpperCase(), | ||
camelCase: (input) => input.replace(/_(\w)/g, (_, char) => char.toUpperCase()), | ||
camelCase: (input) => input.replace(/_(\w)/g, (_, char) => String(char).toUpperCase()), | ||
"kebab-case": (input) => input.replace(/_/g, "-"), | ||
@@ -47,3 +47,3 @@ }, | ||
.slice(1) | ||
.replace(/_(\w)/g, (_, char) => char.toUpperCase()) | ||
.replace(/_(\w)/g, (_, char) => String(char).toUpperCase()) | ||
.replace(/(\w)([A-Z])/g, (_, first, second) => `${first}${second}`), | ||
@@ -63,3 +63,3 @@ snake_case: (input) => input.replace(/(\w)([A-Z])/g, (_, first, second) => `${first}_${second}`), | ||
CONSTANT_CASE: (input) => input.toUpperCase().replace(/-/g, "_"), | ||
camelCase: (input) => input.replace(/-(\w)/g, (_, char) => char.toUpperCase()), | ||
camelCase: (input) => input.replace(/-(\w)/g, (_, char) => String(char).toUpperCase()), | ||
}, | ||
@@ -66,0 +66,0 @@ }; |
export { default as throttle } from "lodash.throttle"; | ||
export { default as debounce } from "lodash.debounce"; | ||
type FN<T, R> = (arg: T) => R; | ||
/** | ||
* Memoize a function | ||
* | ||
* memoized function will cache the result of the function call | ||
* | ||
* @param func function to memoize | ||
* @returns memoized function | ||
*/ | ||
export declare function memoize<T, R>(func: FN<T, R>): FN<T, R>; |
export { default as throttle } from "lodash.throttle"; | ||
export { default as debounce } from "lodash.debounce"; | ||
/** | ||
* Memoize a function | ||
* | ||
* memoized function will cache the result of the function call | ||
* | ||
* @param func function to memoize | ||
* @returns memoized function | ||
*/ | ||
export function memoize(func) { | ||
const cache = new Map(); | ||
return (arg) => { | ||
const cachedResult = cache.get(arg); | ||
if (cachedResult !== undefined) { | ||
return cachedResult; | ||
} | ||
const result = func(arg); | ||
cache.set(arg, result); | ||
return result; | ||
}; | ||
} |
@@ -1,2 +0,1 @@ | ||
export * from "./array"; | ||
export * from "./guard"; | ||
@@ -10,2 +9,4 @@ export * from "./monad"; | ||
export * from "./hex"; | ||
export * from "./poll"; | ||
export * from "./sleep"; | ||
export { default as invariant } from "tiny-invariant"; |
@@ -1,2 +0,1 @@ | ||
export * from "./array"; | ||
export * from "./guard"; | ||
@@ -10,2 +9,4 @@ export * from "./monad"; | ||
export * from "./hex"; | ||
export * from "./poll"; | ||
export * from "./sleep"; | ||
export { default as invariant } from "tiny-invariant"; |
@@ -1,2 +0,2 @@ | ||
import { DependencyList, EffectCallback } from "react"; | ||
import { type DependencyList, type EffectCallback } from "react"; | ||
export declare const useChangedEffect: (effect: EffectCallback, deps?: DependencyList) => void; |
@@ -1,2 +0,2 @@ | ||
import { useEffect, useRef } from "react"; | ||
import { useEffect, useRef, } from "react"; | ||
export const useChangedEffect = (effect, deps) => { | ||
@@ -3,0 +3,0 @@ const isFirstMountRef = useRef(true); |
@@ -1,4 +0,4 @@ | ||
import { Draft } from "immer"; | ||
import { type Draft } from "immer"; | ||
export declare function usePersistedState<T>(storage: Storage, key: string, defaultValue: T): readonly [T, (valueOrProducerFn: T | ((draft: Draft<T>) => void)) => void]; | ||
export declare function useLocalStorageState<T>(key: string, defaultValue: T): readonly [T, (valueOrProducerFn: T | ((draft: Draft<T>) => void)) => void]; | ||
export declare function useSessionStorageState<T>(key: string, defaultValue: T): readonly [T, (valueOrProducerFn: T | ((draft: Draft<T>) => void)) => void]; |
@@ -5,3 +5,5 @@ import { useEffect, useState } from "react"; | ||
export function usePersistedState(storage, key, defaultValue) { | ||
const [state, _setState] = useState(() => Maybe.of(storage.getItem(key)).mapOr(defaultValue, JSON.parse)); | ||
const [state, _setState] = useState(() => | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
Maybe.of(storage.getItem(key)).mapOr(defaultValue, JSON.parse)); | ||
useEffect(() => { | ||
@@ -8,0 +10,0 @@ storage.setItem(key, JSON.stringify(state)); |
@@ -5,2 +5,3 @@ import { useEffect, useRef } from "react"; | ||
useEffect(() => { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
ref.current = value; | ||
@@ -7,0 +8,0 @@ }, [value]); |
import type { AnyRecord, PluralizeKeys } from "./types"; | ||
export declare const caseInsensitiveRecord: <T>(record: Record<string, T>) => Record<string, T>; | ||
export declare function pluralizeKeys<T extends AnyRecord>(obj: T): PluralizeKeys<T>; | ||
export declare const invert: <T extends Record<string, string>>(obj: T) => { [K in keyof T as T[K]]: K; }; |
@@ -17,7 +17,5 @@ export const caseInsensitiveRecord = (record) => new Proxy(record, { | ||
export function pluralizeKeys(obj) { | ||
const nextEntries = Object.entries(obj).map(([key, value]) => [ | ||
`${key}s`, | ||
value, | ||
]); | ||
const nextEntries = Object.entries(obj).map(([key, value]) => [`${key}s`, value]); | ||
return Object.fromEntries(nextEntries); | ||
} | ||
export const invert = (obj) => Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k])); |
@@ -10,1 +10,9 @@ export declare const isNilOrWhitespace: (value: string | undefined | null) => value is null | undefined; | ||
export declare function generateRandomHash(bits?: 8 | 16 | 24 | 32): `0x${string}`; | ||
/** | ||
* Compare two strings, ignoring case | ||
* | ||
* @param a | ||
* @param b | ||
* @returns | ||
*/ | ||
export declare function caseInsensitiveEqual(a: string | undefined, b: string | undefined): boolean; |
@@ -17,1 +17,11 @@ export const isNilOrWhitespace = (value) => { var _a; return ((_a = value === null || value === void 0 ? void 0 : value.trim()) !== null && _a !== void 0 ? _a : "") === ""; }; | ||
} | ||
/** | ||
* Compare two strings, ignoring case | ||
* | ||
* @param a | ||
* @param b | ||
* @returns | ||
*/ | ||
export function caseInsensitiveEqual(a, b) { | ||
return (a === null || a === void 0 ? void 0 : a.toLowerCase()) === (b === null || b === void 0 ? void 0 : b.toLowerCase()); | ||
} |
@@ -12,3 +12,3 @@ "use strict"; | ||
camelCase: (input) => input.charAt(0).toLowerCase() + | ||
input.slice(1).replace(/_(\w)/g, (_, char) => char.toUpperCase()), | ||
input.slice(1).replace(/_(\w)/g, (_, char) => String(char).toUpperCase()), | ||
"kebab-case": (input) => input | ||
@@ -25,3 +25,3 @@ .split(/(?=[A-Z])/) | ||
CONSTANT_CASE: (input) => input.toUpperCase(), | ||
camelCase: (input) => input.replace(/_(\w)/g, (_, char) => char.toUpperCase()), | ||
camelCase: (input) => input.replace(/_(\w)/g, (_, char) => String(char).toUpperCase()), | ||
"kebab-case": (input) => input.replace(/_/g, "-"), | ||
@@ -50,3 +50,3 @@ }, | ||
.slice(1) | ||
.replace(/_(\w)/g, (_, char) => char.toUpperCase()) | ||
.replace(/_(\w)/g, (_, char) => String(char).toUpperCase()) | ||
.replace(/(\w)([A-Z])/g, (_, first, second) => `${first}${second}`), | ||
@@ -66,3 +66,3 @@ snake_case: (input) => input.replace(/(\w)([A-Z])/g, (_, first, second) => `${first}_${second}`), | ||
CONSTANT_CASE: (input) => input.toUpperCase().replace(/-/g, "_"), | ||
camelCase: (input) => input.replace(/-(\w)/g, (_, char) => char.toUpperCase()), | ||
camelCase: (input) => input.replace(/-(\w)/g, (_, char) => String(char).toUpperCase()), | ||
}, | ||
@@ -69,0 +69,0 @@ }; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.debounce = exports.throttle = void 0; | ||
exports.memoize = exports.debounce = exports.throttle = void 0; | ||
var lodash_throttle_1 = require("lodash.throttle"); | ||
@@ -12,1 +12,22 @@ Object.defineProperty(exports, "throttle", { enumerable: true, get: function () { return __importDefault(lodash_throttle_1).default; } }); | ||
Object.defineProperty(exports, "debounce", { enumerable: true, get: function () { return __importDefault(lodash_debounce_1).default; } }); | ||
/** | ||
* Memoize a function | ||
* | ||
* memoized function will cache the result of the function call | ||
* | ||
* @param func function to memoize | ||
* @returns memoized function | ||
*/ | ||
function memoize(func) { | ||
const cache = new Map(); | ||
return (arg) => { | ||
const cachedResult = cache.get(arg); | ||
if (cachedResult !== undefined) { | ||
return cachedResult; | ||
} | ||
const result = func(arg); | ||
cache.set(arg, result); | ||
return result; | ||
}; | ||
} | ||
exports.memoize = memoize; |
@@ -21,3 +21,2 @@ "use strict"; | ||
exports.invariant = void 0; | ||
__exportStar(require("./array"), exports); | ||
__exportStar(require("./guard"), exports); | ||
@@ -31,3 +30,5 @@ __exportStar(require("./monad"), exports); | ||
__exportStar(require("./hex"), exports); | ||
__exportStar(require("./poll"), exports); | ||
__exportStar(require("./sleep"), exports); | ||
var tiny_invariant_1 = require("tiny-invariant"); | ||
Object.defineProperty(exports, "invariant", { enumerable: true, get: function () { return __importDefault(tiny_invariant_1).default; } }); |
{ | ||
"name": "@axelarjs/utils", | ||
"version": "0.0.0-snapshot.7aa3516", | ||
"version": "0.0.0-snapshot.8af9be9", | ||
"publishConfig": { | ||
@@ -12,3 +12,2 @@ "access": "public" | ||
}, | ||
"type": "module", | ||
"files": [ | ||
@@ -18,11 +17,23 @@ "./build", | ||
"./index.js", | ||
"./index.d.ts", | ||
"./array.js", | ||
"./array.d.ts", | ||
"./case-conversion.js", | ||
"./case-conversion.d.ts", | ||
"./function.js", | ||
"./function.d.ts", | ||
"./guard.js", | ||
"./guard.d.ts", | ||
"./hex.js", | ||
"./hex.d.ts", | ||
"./http-client.js", | ||
"./http-client.d.ts", | ||
"./monad.js", | ||
"./monad.d.ts", | ||
"./record.js", | ||
"./record.d.ts", | ||
"./string.js", | ||
"./types.js" | ||
"./string.d.ts", | ||
"./types.js", | ||
"./types.d.ts" | ||
], | ||
@@ -48,29 +59,30 @@ "exports": { | ||
"@testing-library/jest-dom": "^5.17.0", | ||
"@testing-library/react": "^14.0.0", | ||
"@testing-library/react": "^14.1.2", | ||
"@tsconfig/strictest": "^2.0.2", | ||
"@types/lodash.debounce": "^4.0.7", | ||
"@types/lodash.throttle": "^4.1.7", | ||
"@types/node": "18.15.3", | ||
"@types/ramda": "^0.29.4", | ||
"@types/react": "^18.2.21", | ||
"@types/react-dom": "^18.2.7", | ||
"@types/lodash.debounce": "^4.0.9", | ||
"@types/lodash.throttle": "^4.1.9", | ||
"@types/node": "^20.11.5", | ||
"@types/ramda": "^0.29.10", | ||
"@types/react": "18.2.21", | ||
"@types/react-dom": "18.2.7", | ||
"@types/testing-library__jest-dom": "^5.14.9", | ||
"@vitejs/plugin-react": "^4.0.4", | ||
"fast-check": "^3.13.0", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"fast-check": "^3.15.0", | ||
"happy-dom": "^9.20.3", | ||
"matchers": "link:@testing-library/jest-dom/matchers", | ||
"rambda": "^7.5.0", | ||
"rambda": "^9.0.1", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"rimraf": "^5.0.1", | ||
"typescript": "^5.2.2", | ||
"vite": "4.4.9", | ||
"vitest": "^0.34.4", | ||
"@axelarjs/config": "0.0.0-snapshot.7aa3516" | ||
"rimraf": "^5.0.5", | ||
"typescript": "^5.3.3", | ||
"vite": "^5.0.12", | ||
"vitest": "^1.2.1", | ||
"@axelarjs/config": "0.0.0-snapshot.8af9be9" | ||
}, | ||
"dependencies": { | ||
"immer": "^10.0.2", | ||
"immer": "^10.0.3", | ||
"isomorphic-unfetch": "^4.0.2", | ||
"lodash.debounce": "^4.0.8", | ||
"lodash.throttle": "^4.1.1", | ||
"ramda": "^0.29.0", | ||
"ramda": "^0.29.1", | ||
"tiny-invariant": "^1.3.1" | ||
@@ -82,4 +94,6 @@ }, | ||
"build": "scripts/build.sh", | ||
"clean": "scripts/clean.sh" | ||
"clean": "scripts/clean.sh", | ||
"lint": "eslint src --ext .ts", | ||
"lint:fix": "eslint src --ext .ts --fix" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { DependencyList, EffectCallback } from "react"; | ||
import { type DependencyList, type EffectCallback } from "react"; | ||
export declare const useChangedEffect: (effect: EffectCallback, deps?: DependencyList) => void; |
@@ -1,4 +0,4 @@ | ||
import { Draft } from "immer"; | ||
import { type Draft } from "immer"; | ||
export declare function usePersistedState<T>(storage: Storage, key: string, defaultValue: T): readonly [T, (valueOrProducerFn: T | ((draft: Draft<T>) => void)) => void]; | ||
export declare function useLocalStorageState<T>(key: string, defaultValue: T): readonly [T, (valueOrProducerFn: T | ((draft: Draft<T>) => void)) => void]; | ||
export declare function useSessionStorageState<T>(key: string, defaultValue: T): readonly [T, (valueOrProducerFn: T | ((draft: Draft<T>) => void)) => void]; |
@@ -8,3 +8,5 @@ "use strict"; | ||
function usePersistedState(storage, key, defaultValue) { | ||
const [state, _setState] = (0, react_1.useState)(() => monad_1.Maybe.of(storage.getItem(key)).mapOr(defaultValue, JSON.parse)); | ||
const [state, _setState] = (0, react_1.useState)(() => | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
monad_1.Maybe.of(storage.getItem(key)).mapOr(defaultValue, JSON.parse)); | ||
(0, react_1.useEffect)(() => { | ||
@@ -11,0 +13,0 @@ storage.setItem(key, JSON.stringify(state)); |
@@ -8,2 +8,3 @@ "use strict"; | ||
(0, react_1.useEffect)(() => { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
ref.current = value; | ||
@@ -10,0 +11,0 @@ }, [value]); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pluralizeKeys = exports.caseInsensitiveRecord = void 0; | ||
exports.invert = exports.pluralizeKeys = exports.caseInsensitiveRecord = void 0; | ||
const caseInsensitiveRecord = (record) => new Proxy(record, { | ||
@@ -21,8 +21,7 @@ get(target, p) { | ||
function pluralizeKeys(obj) { | ||
const nextEntries = Object.entries(obj).map(([key, value]) => [ | ||
`${key}s`, | ||
value, | ||
]); | ||
const nextEntries = Object.entries(obj).map(([key, value]) => [`${key}s`, value]); | ||
return Object.fromEntries(nextEntries); | ||
} | ||
exports.pluralizeKeys = pluralizeKeys; | ||
const invert = (obj) => Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k])); | ||
exports.invert = invert; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateRandomHash = exports.maskAddress = exports.unSluggify = exports.sluggify = exports.capitalize = exports.isNilOrWhitespace = void 0; | ||
exports.caseInsensitiveEqual = exports.generateRandomHash = exports.maskAddress = exports.unSluggify = exports.sluggify = exports.capitalize = exports.isNilOrWhitespace = void 0; | ||
const isNilOrWhitespace = (value) => { var _a; return ((_a = value === null || value === void 0 ? void 0 : value.trim()) !== null && _a !== void 0 ? _a : "") === ""; }; | ||
@@ -26,1 +26,12 @@ exports.isNilOrWhitespace = isNilOrWhitespace; | ||
exports.generateRandomHash = generateRandomHash; | ||
/** | ||
* Compare two strings, ignoring case | ||
* | ||
* @param a | ||
* @param b | ||
* @returns | ||
*/ | ||
function caseInsensitiveEqual(a, b) { | ||
return (a === null || a === void 0 ? void 0 : a.toLowerCase()) === (b === null || b === void 0 ? void 0 : b.toLowerCase()); | ||
} | ||
exports.caseInsensitiveEqual = caseInsensitiveEqual; |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
124620
113
3041
1
5
6
No
+ Addedisomorphic-unfetch@^4.0.2
+ Addeddata-uri-to-buffer@4.0.1(transitive)
+ Addedfetch-blob@3.2.0(transitive)
+ Addedformdata-polyfill@4.0.10(transitive)
+ Addedisomorphic-unfetch@4.0.2(transitive)
+ Addednode-domexception@1.0.0(transitive)
+ Addednode-fetch@3.3.2(transitive)
+ Addedunfetch@5.0.0(transitive)
+ Addedweb-streams-polyfill@3.3.3(transitive)
Updatedimmer@^10.0.3
Updatedramda@^0.29.1