Socket
Socket
Sign inDemoInstall

react-request-hook

Package Overview
Dependencies
14
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 2.1.0

dist/index.d.ts

120

dist/index.es.js
import axios from 'axios';
import { createContext, useState, useCallback, useContext, useRef, useEffect, useReducer, useMemo } from 'react';
var isArray = Array.isArray;
var keyList = Object.keys;
var hasProp = Object.prototype.hasOwnProperty;
var fastDeepEqual = function equal(a, b) {
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
var arrA = isArray(a)
, arrB = isArray(b)
, i
, length
, key;
if (arrA && arrB) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (!equal(a[i], b[i])) return false;
return true;
}
if (arrA != arrB) return false;
var dateA = a instanceof Date
, dateB = b instanceof Date;
if (dateA != dateB) return false;
if (dateA && dateB) return a.getTime() == b.getTime();
var regexpA = a instanceof RegExp
, regexpB = b instanceof RegExp;
if (regexpA != regexpB) return false;
if (regexpA && regexpB) return a.toString() == b.toString();
var keys = keyList(a);
length = keys.length;
if (length !== keyList(b).length)
return false;
for (i = length; i-- !== 0;)
if (!hasProp.call(b, keys[i])) return false;
for (i = length; i-- !== 0;) {
key = keys[i];
if (!equal(a[key], b[key])) return false;
}
return true;
}
return a!==a && b!==b;
};
function request(config,
// we use 'payload' to enable non-ts applications to leverage type safety and
// as a argument sugar that allow us to extract the payload type easily
// @ts-ignore
paylaod) {
_payload) {
// we also ignore it here, so the payload value won't propagate as a possible
// undefined, where its default value is actually `null`.
// @ts-ignore
return config;

@@ -182,56 +238,2 @@ }

var isArray = Array.isArray;
var keyList = Object.keys;
var hasProp = Object.prototype.hasOwnProperty;
var fastDeepEqual = function equal(a, b) {
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
var arrA = isArray(a)
, arrB = isArray(b)
, i
, length
, key;
if (arrA && arrB) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (!equal(a[i], b[i])) return false;
return true;
}
if (arrA != arrB) return false;
var dateA = a instanceof Date
, dateB = b instanceof Date;
if (dateA != dateB) return false;
if (dateA && dateB) return a.getTime() == b.getTime();
var regexpA = a instanceof RegExp
, regexpB = b instanceof RegExp;
if (regexpA != regexpB) return false;
if (regexpA && regexpB) return a.toString() == b.toString();
var keys = keyList(a);
length = keys.length;
if (length !== keyList(b).length)
return false;
for (i = length; i-- !== 0;)
if (!hasProp.call(b, keys[i])) return false;
for (i = length; i-- !== 0;) {
key = keys[i];
if (!equal(a[key], b[key])) return false;
}
return true;
}
return a!==a && b!==b;
};
var REQUEST_CLEAR_MESSAGE = 'A new request has been made before completing the last one';

@@ -241,3 +243,3 @@ function getNextState(state, action) {

data: action.type === 'success' ? action.data : state.data,
error: action.type === 'error' ? action.error : null,
error: action.type === 'error' ? action.error : undefined,
isLoading: action.type === 'start' ? true : false,

@@ -249,4 +251,2 @@ };

var _b = useReducer(getNextState, {
error: null,
data: null,
isLoading: Boolean(defaultParams),

@@ -318,3 +318,3 @@ }), state = _b[0], dispatch = _b[1];

export { request, createRequestError, useRequest, useResource, RequestContext, RequestProvider, RequestConsumer };
export { fastDeepEqual as isEqual, request, createRequestError, useRequest, useResource, RequestContext, RequestProvider, RequestConsumer };
//# sourceMappingURL=index.es.js.map

@@ -10,7 +10,63 @@ 'use strict';

var isArray = Array.isArray;
var keyList = Object.keys;
var hasProp = Object.prototype.hasOwnProperty;
var fastDeepEqual = function equal(a, b) {
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
var arrA = isArray(a)
, arrB = isArray(b)
, i
, length
, key;
if (arrA && arrB) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (!equal(a[i], b[i])) return false;
return true;
}
if (arrA != arrB) return false;
var dateA = a instanceof Date
, dateB = b instanceof Date;
if (dateA != dateB) return false;
if (dateA && dateB) return a.getTime() == b.getTime();
var regexpA = a instanceof RegExp
, regexpB = b instanceof RegExp;
if (regexpA != regexpB) return false;
if (regexpA && regexpB) return a.toString() == b.toString();
var keys = keyList(a);
length = keys.length;
if (length !== keyList(b).length)
return false;
for (i = length; i-- !== 0;)
if (!hasProp.call(b, keys[i])) return false;
for (i = length; i-- !== 0;) {
key = keys[i];
if (!equal(a[key], b[key])) return false;
}
return true;
}
return a!==a && b!==b;
};
function request(config,
// we use 'payload' to enable non-ts applications to leverage type safety and
// as a argument sugar that allow us to extract the payload type easily
// @ts-ignore
paylaod) {
_payload) {
// we also ignore it here, so the payload value won't propagate as a possible
// undefined, where its default value is actually `null`.
// @ts-ignore
return config;

@@ -189,56 +245,2 @@ }

var isArray = Array.isArray;
var keyList = Object.keys;
var hasProp = Object.prototype.hasOwnProperty;
var fastDeepEqual = function equal(a, b) {
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
var arrA = isArray(a)
, arrB = isArray(b)
, i
, length
, key;
if (arrA && arrB) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (!equal(a[i], b[i])) return false;
return true;
}
if (arrA != arrB) return false;
var dateA = a instanceof Date
, dateB = b instanceof Date;
if (dateA != dateB) return false;
if (dateA && dateB) return a.getTime() == b.getTime();
var regexpA = a instanceof RegExp
, regexpB = b instanceof RegExp;
if (regexpA != regexpB) return false;
if (regexpA && regexpB) return a.toString() == b.toString();
var keys = keyList(a);
length = keys.length;
if (length !== keyList(b).length)
return false;
for (i = length; i-- !== 0;)
if (!hasProp.call(b, keys[i])) return false;
for (i = length; i-- !== 0;) {
key = keys[i];
if (!equal(a[key], b[key])) return false;
}
return true;
}
return a!==a && b!==b;
};
var REQUEST_CLEAR_MESSAGE = 'A new request has been made before completing the last one';

@@ -248,3 +250,3 @@ function getNextState(state, action) {

data: action.type === 'success' ? action.data : state.data,
error: action.type === 'error' ? action.error : null,
error: action.type === 'error' ? action.error : undefined,
isLoading: action.type === 'start' ? true : false,

@@ -256,4 +258,2 @@ };

var _b = react.useReducer(getNextState, {
error: null,
data: null,
isLoading: Boolean(defaultParams),

@@ -325,2 +325,3 @@ }), state = _b[0], dispatch = _b[1];

exports.isEqual = fastDeepEqual;
exports.request = request;

@@ -327,0 +328,0 @@ exports.createRequestError = createRequestError;

{
"name": "react-request-hook",
"version": "2.0.1",
"version": "2.1.0",
"description": "Managed request calls made easy by React Hooks",
"author": "Matheus Schettino",
"author": {
"name": "Matheus Schettino",
"email": "schettino2@gmail.com"
},
"license": "MIT",
"repository": "schettino/react-request-hook",
"repository": "https://github.com/schettino/react-request-hook.git",
"main": "dist/index.js",
"module": "dist/index.es.js",
"jsnext:main": "dist/index.es.js",
"types": "dist/src/index.d.ts",
"types": "dist/index.d.ts",
"engines": {

@@ -13,0 +16,0 @@ "node": ">=8",

@@ -15,3 +15,3 @@ <p align="center">

[Codesandbox][codesandbox]
[![Edit react-request-hook-examples](https://codesandbox.io/static/img/play-codesandbox.svg)][codesandbox]

@@ -52,4 +52,4 @@ <!-- prettier-ignore-end -->

const axiosInstance = axios.create({
baseURL: 'https://example.com/'
})
baseURL: 'https://example.com/',
});

@@ -284,4 +284,4 @@ ReactDOM.render(

[bundle-size-badge]: https://badgen.net/bundlephobia/minzip/react-request-hook@latest
[codesandbox]: https://codesandbox.io/s/github/schettino/react-request-hook/tree/master/example
[codesandbox]: https://codesandbox.io/s/github/schettino/react-request-hook-examples/tree/master/?fontsize=14&view=preview
<!-- prettier-ignore-end -->

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc