Skip to content

Commit

Permalink
remove ramda
Browse files Browse the repository at this point in the history
  • Loading branch information
edelgarat committed Oct 8, 2023
1 parent 44fd1dd commit b84bcd0
Show file tree
Hide file tree
Showing 8 changed files with 4,275 additions and 2,913 deletions.
7,161 changes: 4,264 additions & 2,897 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@worksolutions/react-utils",
"private": false,
"version": "2.1.14",
"version": "2.2.1",
"description": "",
"types": "dist/esm/index.d.ts",
"main": "dist/cjs/index.js",
Expand All @@ -19,10 +19,9 @@
"sideEffects": false,
"dependencies": {
"mobx": "^6.*",
"@worksolutions/utils": "^1.3.30",
"@worksolutions/utils": "^1.4.3",
"lodash.debounce": "^4.*",
"lodash.throttle": "^4.*",
"ramda": "^0.*",
"react": "*",
"react-dom": "*",
"react-use": "^17.*",
Expand All @@ -33,7 +32,6 @@
"@types/lodash.debounce": "^4.*",
"@types/lodash.throttle": "^4.*",
"@types/node": "*",
"@types/ramda": "^0.*",
"@types/react": "*",
"@types/react-dom": "*",
"@types/resize-observer-browser": "^0.1.7",
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/scroll.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { identity } from "ramda";
import { identity } from "@worksolutions/utils";

function getWindowScrollPosition() {
return { x: document.documentElement.scrollLeft, y: document.documentElement.scrollTop };
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/useAsyncFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import React, { DependencyList, useCallback } from "react";
import { useMountedState } from "react-use";
import { assoc } from "ramda";

import { useSyncToRef } from "./useSyncToRef";

Expand Down Expand Up @@ -33,7 +32,7 @@ export function useAsyncFn<FUNC extends FunctionReturningPromise<any>>(
const callback = useCallback((...args: Parameters<FUNC>) => {
const callId = ++lastCallId.current;

if (!stateRef.current.loading && loadingAvailable.current) setState(assoc("loading", true));
if (!stateRef.current.loading && loadingAvailable.current) setState((value) => ({ ...value, loading: true }));

return func(...args).then(
(value) => {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useMemoizeCallback.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { DependencyList } from "react";
import { memoizeWith } from "ramda";
import { memoizeWith } from "@worksolutions/utils";

/**
* Memoize callback in React.useCallback hook
Expand Down
5 changes: 2 additions & 3 deletions src/hooks/useObservableAsDeferredMemo.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { DependencyList } from "react";
import {observe, toJS} from "mobx";
import { observe, toJS } from "mobx";
import { isPureObject } from "@worksolutions/utils";

import {deepObserve} from "mobx-utils";
import { deepObserve } from "mobx-utils";

export type UseObservableAsDeferredMemoOptions = { fireImmediately?: boolean; convertToJS?: boolean; deep?: boolean };

Expand Down Expand Up @@ -31,7 +31,6 @@ export function useObservableAsDeferredMemo<RESULT, TARGET>(
return value;
}


export function createObserverForStateHook(
target: any,
key: any,
Expand Down
7 changes: 3 additions & 4 deletions src/hooks/useStackState.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from "react";
import { append, remove, last } from "ramda";

export function useStackState<ELEMENT>(initialStack?: ELEMENT[]) {
const [stack, setStack] = React.useState(() => (initialStack ? [...initialStack] : []));
const stackLast = React.useMemo(() => last(stack), [stack]);
const push = React.useCallback((element: ELEMENT) => setStack(append(element)), []);
const pop = React.useCallback(() => setStack(remove(-1, 1)), []);
const stackLast = React.useMemo(() => stack[stack.length - 1], [stack]);
const push = React.useCallback((element: ELEMENT) => setStack((stack) => [...stack, element]), []);
const pop = React.useCallback(() => setStack((stack) => stack.slice(0, -1)), []);
const reset = React.useCallback((newStack: ELEMENT[] = []) => setStack(newStack), []);

return React.useMemo(
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useTimer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useRef } from "react";
import { isNil } from "ramda";
import { isNil } from "@worksolutions/utils";

import { useForceUpdate } from "./common";

Expand Down

0 comments on commit b84bcd0

Please sign in to comment.