Skip to content

Commit

Permalink
Remove idx
Browse files Browse the repository at this point in the history
  • Loading branch information
kelsonpw committed Jul 11, 2023
1 parent b456dfc commit 32423a0
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 70 deletions.
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

module.exports = {
presets: ['@babel/preset-flow', '@babel/preset-react', '@babel/preset-env'],
plugins: ['@babel/plugin-proposal-object-rest-spread', 'babel-plugin-idx'],
plugins: ['@babel/plugin-proposal-object-rest-spread'],
env: {
test: {
presets: [
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-jest": "^24.8.0",
"babel-plugin-idx": "^2.4.0",
"codecov": "^3.5.0",
"flow-bin": "^0.100.0",
"husky": "^1.3.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/redux-query-interface-superagent/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6158,10 +6158,10 @@ realpath-native@^2.0.0:
resolved "https://registry.yarnpkg.com/realpath-native/-/realpath-native-2.0.0.tgz#7377ac429b6e1fd599dc38d08ed942d0d7beb866"
integrity sha512-v1SEYUOXXdbBZK8ZuNgO4TBjamPsiSgcFr0aP+tEKpQZK8vooEUqV6nm6Cv502mX4NF2EfsnVqtNAHG+/6Ur1Q==

redux-query@^3.5.0-alpha.1:
version "3.5.0-alpha.3"
resolved "https://registry.yarnpkg.com/redux-query/-/redux-query-3.5.0-alpha.3.tgz#3aad3415599d57229a3ef982b241bae1948d7168"
integrity sha512-oqzScFf3/TaQI2p7h6t1IapcAZ+q59BHYVURwjFJQsoBpfdKK9a2JJRY3yw8SfYm9PeFTq4xg+3cM9+dBm2kiw==
redux-query@^3.5.1-alpha.1:
version "3.5.1-alpha.1"
resolved "https://registry.yarnpkg.com/redux-query/-/redux-query-3.5.1-alpha.1.tgz#bd3d1109e0a8dc8b0c8c96fa03bd2631979b57e9"
integrity sha512-YqbdV2qamE9+LD2u7r557s1q6zS1LJy6L7a7vArAgIWwLeHGu8TOi5BShZQmu62w9Zuob+4MM324wFDBZuL3Hg==
dependencies:
backo "^1.1.0"
idx "^2.5.6"
Expand Down
16 changes: 8 additions & 8 deletions packages/redux-query-react/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6333,10 +6333,10 @@ q@^1.0.1:
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=

qs@6.2.4, qs@^1.2.1, qs@~6.5.2:
version "6.2.4"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.4.tgz#d90821bb8537cecc140e6c34f54ec76e54b39b22"
integrity sha512-E57gmgKXqDda+qWTkUJgIwgJICK7zgMfqZZopTRKZ6mY9gzLlmJN9EpXNnDrTxXFlOM/a+I28kJkF/60rqgnYw==
qs@6.9.7, qs@^1.2.1, qs@~6.5.2:
version "6.9.7"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.7.tgz#4610846871485e1e048f44ae3b94033f0e675afe"
integrity sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==

querystring-es3@^0.2.0:
version "0.2.1"
Expand Down Expand Up @@ -6502,10 +6502,10 @@ realpath-native@^2.0.0:
resolved "https://registry.yarnpkg.com/realpath-native/-/realpath-native-2.0.0.tgz#7377ac429b6e1fd599dc38d08ed942d0d7beb866"
integrity sha512-v1SEYUOXXdbBZK8ZuNgO4TBjamPsiSgcFr0aP+tEKpQZK8vooEUqV6nm6Cv502mX4NF2EfsnVqtNAHG+/6Ur1Q==

redux-query@^3.5.0-alpha.1:
version "3.5.0-alpha.3"
resolved "https://registry.yarnpkg.com/redux-query/-/redux-query-3.5.0-alpha.3.tgz#3aad3415599d57229a3ef982b241bae1948d7168"
integrity sha512-oqzScFf3/TaQI2p7h6t1IapcAZ+q59BHYVURwjFJQsoBpfdKK9a2JJRY3yw8SfYm9PeFTq4xg+3cM9+dBm2kiw==
redux-query@^3.5.1-alpha.1:
version "3.5.1-alpha.1"
resolved "https://registry.yarnpkg.com/redux-query/-/redux-query-3.5.1-alpha.1.tgz#bd3d1109e0a8dc8b0c8c96fa03bd2631979b57e9"
integrity sha512-YqbdV2qamE9+LD2u7r557s1q6zS1LJy6L7a7vArAgIWwLeHGu8TOi5BShZQmu62w9Zuob+4MM324wFDBZuL3Hg==
dependencies:
backo "^1.1.0"
idx "^2.5.6"
Expand Down
2 changes: 0 additions & 2 deletions packages/redux-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"license": "MIT",
"dependencies": {
"backo": "^1.1.0",
"idx": "^2.5.6",
"invariant": "^2.2.0",
"json-stable-stringify": "^1.0.0",
"reselect": "^4.0.0"
Expand All @@ -53,7 +52,6 @@
"babel-eslint": "^10.0.1",
"babel-jest": "^24.8.0",
"babel-loader": "^8.0.2",
"babel-plugin-idx": "^2.4.0",
"cross-env": "^1.0.7",
"eslint": "^5.11.1",
"eslint-plugin-flowtype": "^3.10.1",
Expand Down
5 changes: 2 additions & 3 deletions packages/redux-query/src/middleware/query.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow

import Backoff from 'backo';
import idx from 'idx';

import {
requestStart,
Expand Down Expand Up @@ -137,8 +136,8 @@ const queryMiddleware = (
const queries = queriesSelector(state);

const queriesState = queries[queryKey];
const isPending = idx(queriesState, _ => _.isPending);
const status = idx(queriesState, _ => _.status);
const isPending = queriesState?.isPending;
const status = queriesState?.status;
const hasSucceeded = isStatusOk(status);

if (force || !queriesState || (retry && !isPending && !hasSucceeded)) {
Expand Down
8 changes: 3 additions & 5 deletions packages/redux-query/src/selectors/error.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @flow

import idx from 'idx';

import type { State as ErrorsState } from '../reducers/errors';
import { getQueryKey } from '../lib/query-key';
import type { QueryConfig } from '../types';
Expand All @@ -16,7 +14,7 @@ export const responseBody = (
return null;
}

return idx(errorsState, _ => _[queryKey].responseBody);
return errorsState?.[queryKey]?.responseBody;
};

export const responseText = (errorsState: ErrorsState, queryConfig: QueryConfig): ?string => {
Expand All @@ -26,7 +24,7 @@ export const responseText = (errorsState: ErrorsState, queryConfig: QueryConfig)
return null;
}

return idx(errorsState, _ => _[queryKey].responseText);
return errorsState?.[queryKey]?.responseText;
};

export const responseHeaders = (
Expand All @@ -39,5 +37,5 @@ export const responseHeaders = (
return null;
}

return idx(errorsState, _ => _[queryKey].responseHeaders);
return errorsState?.[queryKey]?.responseHeaders;
};
34 changes: 7 additions & 27 deletions packages/redux-query/src/selectors/query.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @flow

import idx from 'idx';

import type { State as QueriesState } from '../reducers/queries';
import { getQueryKey } from '../lib/query-key';
import type { QueryConfig, QueryDetails } from '../types';
Expand All @@ -24,53 +22,35 @@ export const getQueryDetails: (
return defaultDetailsObject;
}

return idx(queriesState, _ => _[queryKey]) || defaultDetailsObject;
return queriesState?.[queryKey] ?? defaultDetailsObject;
};

export const isFinished: (
queriesState: QueriesState,
queryConfig: ?QueryConfig,
) => boolean = createSelector(
getQueryDetails,
query => query.isFinished,
);
) => boolean = createSelector(getQueryDetails, query => query.isFinished);

export const isPending: (
queriesState: QueriesState,
queryConfig: ?QueryConfig,
) => boolean = createSelector(
getQueryDetails,
query => query.isPending,
);
) => boolean = createSelector(getQueryDetails, query => query.isPending);

export const status: (
queriesState: QueriesState,
queryConfig: ?QueryConfig,
) => ?number = createSelector(
getQueryDetails,
query => query.status,
);
) => ?number = createSelector(getQueryDetails, query => query.status);

export const headers: (
queriesState: QueriesState,
queryConfig: ?QueryConfig,
) => ?{ [key: string]: any } = createSelector(
getQueryDetails,
query => query.headers,
);
) => ?{ [key: string]: any } = createSelector(getQueryDetails, query => query.headers);

export const lastUpdated: (
queriesState: QueriesState,
queryConfig: ?QueryConfig,
) => ?number = createSelector(
getQueryDetails,
query => query.lastUpdated,
);
) => ?number = createSelector(getQueryDetails, query => query.lastUpdated);

export const queryCount: (
queriesState: QueriesState,
queryConfig: ?QueryConfig,
) => number = createSelector(
getQueryDetails,
query => query.queryCount,
);
) => number = createSelector(getQueryDetails, query => query.queryCount);
18 changes: 4 additions & 14 deletions packages/redux-query/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1965,11 +1965,6 @@ babel-loader@^8.0.2:
make-dir "^3.1.0"
schema-utils "^2.6.5"

babel-plugin-idx@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/babel-plugin-idx/-/babel-plugin-idx-2.4.0.tgz#5d144eb337fb22c4bf1ff75cb2e1c051a76a0323"
integrity sha512-+rEYZgSCLh0suJDlgZ64isSLhDW7Qxu6AnUMGhl/mW1kyYvfwqLqsDmgj3e5QXH0oX7A4Hq2x0BgqdU8tiuo5A==

babel-plugin-istanbul@^5.1.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-5.2.0.tgz#df4ade83d897a92df069c4d9a25cf2671293c854"
Expand Down Expand Up @@ -3927,11 +3922,6 @@ iconv-lite@0.4.24, iconv-lite@^0.4.24:
dependencies:
safer-buffer ">= 2.1.2 < 3"

idx@^2.5.6:
version "2.5.6"
resolved "https://registry.yarnpkg.com/idx/-/idx-2.5.6.tgz#1f824595070100ae9ad585c86db08dc74f83a59d"
integrity sha512-WFXLF7JgPytbMgelpRY46nHz5tyDcedJ76pLV+RJWdb8h33bxFq4bdZau38DhNSzk5eVniBf1K3jwfK+Lb5nYA==

ieee754@^1.1.4:
version "1.2.1"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
Expand Down Expand Up @@ -6015,10 +6005,10 @@ punycode@^2.1.1:
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==

qs@~6.5.2:
version "6.5.3"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad"
integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==
qs@6.9.7, qs@~6.5.2:
version "6.9.7"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.7.tgz#4610846871485e1e048f44ae3b94033f0e675afe"
integrity sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==

querystring-es3@^0.2.0:
version "0.2.1"
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2295,11 +2295,6 @@ babel-jest@^25.5.1:
graceful-fs "^4.2.4"
slash "^3.0.0"

babel-plugin-idx@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/babel-plugin-idx/-/babel-plugin-idx-2.4.0.tgz#5d144eb337fb22c4bf1ff75cb2e1c051a76a0323"
integrity sha512-+rEYZgSCLh0suJDlgZ64isSLhDW7Qxu6AnUMGhl/mW1kyYvfwqLqsDmgj3e5QXH0oX7A4Hq2x0BgqdU8tiuo5A==

babel-plugin-istanbul@^5.1.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-5.2.0.tgz#df4ade83d897a92df069c4d9a25cf2671293c854"
Expand Down

0 comments on commit 32423a0

Please sign in to comment.