Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iteam/hooks

Package Overview
Dependencies
Maintainers
5
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iteam/hooks - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

src/__tests__/useDebounce.spec.ts

22

dist/hooks.cjs.js

@@ -474,13 +474,18 @@ 'use strict';

var useQueryParam = function useQueryParam(param) {
var useQueryParams = function useQueryParams() {
var _useState = react.useState(function () {
var params = queryString.parse(window.location.search);
return params[param] || '';
return params || {};
}),
_useState2 = _slicedToArray(_useState, 1),
queryParam = _useState2[0];
queryParams = _useState2[0];
return queryParam;
return queryParams;
};
var useQueryParam = function useQueryParam(param) {
var queryParams = useQueryParams();
return queryParams[param] || '';
};
var useDebounce = function useDebounce(value, delay) {

@@ -537,10 +542,5 @@ var _useState = react.useState(value),

var useLocalStorage = function useLocalStorage(key, initialValue) {
var _useStorage = useStorage(key, {
return useStorage(key, {
initialValue: initialValue
}),
_useStorage2 = _slicedToArray(_useStorage, 2),
value = _useStorage2[0],
setValue = _useStorage2[1];
return [value, setValue];
});
};

@@ -547,0 +547,0 @@

@@ -470,13 +470,18 @@ import { useState, useEffect } from 'react';

var useQueryParam = function useQueryParam(param) {
var useQueryParams = function useQueryParams() {
var _useState = useState(function () {
var params = queryString.parse(window.location.search);
return params[param] || '';
return params || {};
}),
_useState2 = _slicedToArray(_useState, 1),
queryParam = _useState2[0];
queryParams = _useState2[0];
return queryParam;
return queryParams;
};
var useQueryParam = function useQueryParam(param) {
var queryParams = useQueryParams();
return queryParams[param] || '';
};
var useDebounce = function useDebounce(value, delay) {

@@ -533,12 +538,7 @@ var _useState = useState(value),

var useLocalStorage = function useLocalStorage(key, initialValue) {
var _useStorage = useStorage(key, {
return useStorage(key, {
initialValue: initialValue
}),
_useStorage2 = _slicedToArray(_useStorage, 2),
value = _useStorage2[0],
setValue = _useStorage2[1];
return [value, setValue];
});
};
export { useToggle, useQueryParam, useDebounce, useLocalStorage, useStorage };

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

import 'jest-dom/extend-expect';
export {};

@@ -1,1 +0,2 @@

export declare const useQueryParams: (param: string) => string | string[];
import queryString from 'query-string';
export declare const useQueryParams: () => queryString.OutputParams;
{
"name": "@iteam/hooks",
"version": "0.4.0",
"version": "0.5.0",
"main": "dist/hooks.cjs.js",
"module": "dist/hooks.esm.js",
"types": "dist/types/index.d.ts",
"description": "A collection of reusable hooks",
"publishConfig": {

@@ -29,30 +30,37 @@ "access": "public"

"devDependencies": {
"@babel/core": "^7.3.3",
"@babel/core": "7.3.3",
"@babel/preset-env": "7.3.1",
"@babel/preset-react": "7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@types/jest": "^24.0.6",
"@babel/preset-typescript": "7.3.3",
"@types/jest": "24.0.6",
"@types/query-string": "6.2.0",
"@types/react": "^16.8.4",
"eslint": "^5.14.1",
"@types/react": "16.8.4",
"eslint": "5.14.1",
"husky": "1.3.1",
"is-ci-cli": "1.1.1",
"jest": "24.1.0",
"jest-dom": "^3.1.2",
"jest-dom": "3.1.2",
"jest-environment-jsdom": "24.0.0",
"jest-environment-jsdom-global": "^1.1.1",
"jest-environment-jsdom-global": "1.1.1",
"jest-localstorage-mock": "2.4.0",
"lint-staged": "^8.1.4",
"lint-staged": "8.1.4",
"prettier": "1.16.4",
"react": "^16.8.2",
"react-dom": "^16.8.2",
"react-testing-library": "^5.9.0",
"rollup": "^1.2.2",
"react": "16.8.2",
"react-dom": "16.8.2",
"react-testing-library": "5.9.0",
"rollup": "1.2.2",
"rollup-plugin-babel": "4.3.2",
"rollup-plugin-commonjs": "9.2.0",
"rollup-plugin-node-resolve": "4.0.0",
"ts-jest": "^24.0.0",
"typescript": "^3.3.3"
"ts-jest": "24.0.0",
"typescript": "3.3.3"
},
"description": ""
"bugs": {
"url": "https://github.com/Iteam1337/hooks/issues"
},
"homepage": "https://github.com/Iteam1337/hooks#readme",
"repository": {
"type": "git",
"url": "https://github.com/Iteam1337/hooks.git"
}
}

@@ -14,6 +14,15 @@ # Iteam Hooks

## Features
## Available Hooks
### useToggle
- [useToggle](#useToggle)
- [useQueryParams](#useQueryParams)
- [useQueryParam](#useQueryParam)
- [useDebounce](#useDebounce)
- [useLocalStorage](#useLocalStorage)
- [useStorage](#useStorage)
---
### [useToggle](#useToggle)
Uses `useState` but returns a setter function that toggles the value.

@@ -38,7 +47,34 @@

### useQueryParam
### [useQueryParams](#useQueryParams)
Gets a value from a specified query param
Gets all the query param values
```js
useQueryParams(): { [key: string]: string | string[] | undefined }
```
#### Example
```js
// https://awesome.domain/?name=cookie&lastName=monster
import React from 'react'
import { useQueryParams } from '@iteam/hooks'
export const NeedsABunchOfParams = () => {
const params = useQueryParams()
console.log(params)
// { name: 'cookie', lastName: 'monster' }
return null
}
```
### [useQueryParam](#useQueryParam)
Gets a value from a specified query param, useful if you only require one value
out of a bunch. Uses `useQueryParams` under the hood.
```js
useQueryParam(param: string): string | string[]

@@ -66,3 +102,3 @@ ```

### useDebounce
### [useDebounce](#useDebounce)

@@ -99,3 +135,3 @@ Debounce the updating of a value

### useLocalStorage
### [useLocalStorage](#useLocalStorage)

@@ -132,3 +168,3 @@ Get and set values in `localStorage`. Uses `useStorage` under the hood.

### useStorage
### [useStorage](#useStorage)

@@ -139,3 +175,3 @@ Get and set values in any store with a `getItem` or `setItem`. Defaults to

```js
useStorage(key: string, { initialValue?: any, store?: Storage }): [string, (newValue: string) => void]
useStorage(key: string, options?: { initialValue?: any, store?: Storage }): [string, (newValue: string) => void]
```

@@ -142,0 +178,0 @@

@@ -6,6 +6,2 @@ import { useStorage } from './useStorage'

initialValue?: any
): [string, (newValue: string) => void] => {
const [value, setValue] = useStorage(key, { initialValue })
return [value, setValue]
}
): [string, (newValue: string) => void] => useStorage(key, { initialValue })

@@ -1,11 +0,7 @@

import { useState } from 'react'
import queryString from 'query-string'
import { useQueryParams } from './useQueryParams'
export const useQueryParam = (param: string) => {
const [queryParam] = useState(() => {
const params = queryString.parse(window.location.search)
return params[param] || ''
})
const queryParams = useQueryParams()
return queryParam
return queryParams[param] || ''
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc