New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-hook-array

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hook-array - npm Package Compare versions

Comparing version
0.1.7
to
0.1.8
dist/.DS_Store

Sorry, the diff of this file is not supported yet

+7
-1
import React from "react";
export declare const useArray: <T>(initialValue: T[]) => readonly [T[], React.Dispatch<React.SetStateAction<T[]>>, (index: number, update: React.SetStateAction<T>) => void, (value: T) => void, () => T | undefined];
export declare const useArray: <T>(initialValue: T[]) => {
arr: T[];
setArr: React.Dispatch<React.SetStateAction<T[]>>;
setArrByIndex: (index: number, update: React.SetStateAction<T>) => void;
pushArr: (value: T) => void;
popArr: () => T | undefined;
};
+1
-16

@@ -1,16 +0,1 @@

import React from "react";
const isFunction = (x) => typeof x === "function";
const updateFn = (update, x) => isFunction(update) ? update(x) : update;
export const useArray = (initialValue) => {
const [arr, setArr] = React.useState(initialValue);
const setArrByIndex = React.useCallback((index, update) => {
setArr((old) => old.map((x, idx) => (idx === index ? updateFn(update, x) : x)));
}, [setArr]);
const pushArr = React.useCallback((value) => setArr((old) => [...old, value]), [setArr]);
const popArr = React.useCallback(() => {
const last = arr[arr.length - 1];
setArr((old) => old.filter((x, idx) => idx !== arr.length - 1));
return last;
}, [arr, setArr]);
return [arr, setArr, setArrByIndex, pushArr, popArr];
};
import React from"react";const isFunction=t=>"function"==typeof t,updateFn=(t,e)=>isFunction(t)?t(e):t;export const useArray=t=>{const[e,r]=React.useState(t),a=React.useCallback(((t,e)=>{r((r=>r.map(((r,a)=>a===t?updateFn(e,r):r))))}),[r]),n=React.useCallback((t=>r((e=>[...e,t]))),[r]),c=React.useCallback((()=>{const t=e[e.length-1];return r((t=>t.filter(((t,r)=>r!==e.length-1)))),t}),[e,r]);return{arr:e,setArr:r,setArrByIndex:a,pushArr:n,popArr:c}};
{
"name": "react-hook-array",
"version": "0.1.7",
"version": "0.1.8",
"author": {

@@ -19,8 +19,8 @@ "name": "Victor Moraes",

"scripts": {
"minify": "npx uglify-js --compress --output dist/index.js -- dist/index.js"
"minify": "npx terser --compress --mangle --output dist/index.js -- dist/index.js"
},
"devDependencies": {
"@types/react": "^18.0.26",
"uglify-js": "^3.17.4"
"terser": "^5.16.3"
}
}
}