use-window-orientation
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,2 +0,2 @@ | ||
var e,t=require("react"),r=(e=require("lodash.debounce"))&&"object"==typeof e&&"default"in e?e.default:e;module.exports=function(e={}){if("object"!=typeof e)throw new TypeError("The options argument must be formatted as an object.");const{defaultOrientation:n="portrait"}=e;if("portrait"!==n&&"landscape"!==n){const e="string"==typeof n;throw new TypeError(`${e?'"':""}${n}${e?'"':""} is not a valid defaultOrientation. Use "portrait" or "landscape".`)}const[o,i]=t.useState(n);return t.useEffect(()=>{function e(){window.innerWidth<=window.innerHeight?i("portrait"):i("landscape")}return e(),window.addEventListener("resize",r(e,400)),()=>{window.removeEventListener("resize",r(e,400))}},[]),{orientation:o,portrait:"portrait"===o,landscape:"landscape"===o}}; | ||
var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=t(require("lodash.debounce"));module.exports=function(t={}){if("object"!=typeof t)throw new TypeError("The options argument must be formatted as an object.");const{defaultOrientation:n="portrait"}=t;if("portrait"!==n&&"landscape"!==n){const e="string"==typeof n;throw new TypeError(`${e?'"':""}${n}${e?'"':""} is not a valid defaultOrientation. Use "portrait" or "landscape".`)}const[o,a]=e.useState(n);return e.useEffect(()=>{const e=r.default(()=>{window.innerWidth<=window.innerHeight?a("portrait"):a("landscape")},400,{leading:!0,trailing:!0});return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),e.cancel()}},[]),{orientation:o,portrait:"portrait"===o,landscape:"landscape"===o}}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{useState as t,useEffect as e}from"react";import r from"lodash.debounce";export default function(n={}){if("object"!=typeof n)throw new TypeError("The options argument must be formatted as an object.");const{defaultOrientation:o="portrait"}=n;if("portrait"!==o&&"landscape"!==o){const t="string"==typeof o;throw new TypeError(`${t?'"':""}${o}${t?'"':""} is not a valid defaultOrientation. Use "portrait" or "landscape".`)}const[i,a]=t(o);return e(()=>{function t(){window.innerWidth<=window.innerHeight?a("portrait"):a("landscape")}return t(),window.addEventListener("resize",r(t,400)),()=>{window.removeEventListener("resize",r(t,400))}},[]),{orientation:i,portrait:"portrait"===i,landscape:"landscape"===i}} | ||
import{useState as t,useEffect as e}from"react";import r from"lodash.debounce";function n(n={}){if("object"!=typeof n)throw new TypeError("The options argument must be formatted as an object.");const{defaultOrientation:o="portrait"}=n;if("portrait"!==o&&"landscape"!==o){const t="string"==typeof o;throw new TypeError(`${t?'"':""}${o}${t?'"':""} is not a valid defaultOrientation. Use "portrait" or "landscape".`)}const[i,a]=t(o);return e(()=>{const t=r(()=>{window.innerWidth<=window.innerHeight?a("portrait"):a("landscape")},400,{leading:!0,trailing:!0});return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),t.cancel()}},[]),{orientation:i,portrait:"portrait"===i,landscape:"landscape"===i}}export default n; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import{useState as t,useEffect as e}from"react";import r from"lodash.debounce";export default function(n={}){if("object"!=typeof n)throw new TypeError("The options argument must be formatted as an object.");const{defaultOrientation:o="portrait"}=n;if("portrait"!==o&&"landscape"!==o){const t="string"==typeof o;throw new TypeError(`${t?'"':""}${o}${t?'"':""} is not a valid defaultOrientation. Use "portrait" or "landscape".`)}const[i,a]=t(o);return e(()=>{function t(){window.innerWidth<=window.innerHeight?a("portrait"):a("landscape")}return t(),window.addEventListener("resize",r(t,400)),()=>{window.removeEventListener("resize",r(t,400))}},[]),{orientation:i,portrait:"portrait"===i,landscape:"landscape"===i}} | ||
import{useState as t,useEffect as e}from"react";import r from"lodash.debounce";function n(n={}){if("object"!=typeof n)throw new TypeError("The options argument must be formatted as an object.");const{defaultOrientation:o="portrait"}=n;if("portrait"!==o&&"landscape"!==o){const t="string"==typeof o;throw new TypeError(`${t?'"':""}${o}${t?'"':""} is not a valid defaultOrientation. Use "portrait" or "landscape".`)}const[i,a]=t(o);return e(()=>{const t=r(()=>{window.innerWidth<=window.innerHeight?a("portrait"):a("landscape")},400,{leading:!0,trailing:!0});return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),t.cancel()}},[]),{orientation:i,portrait:"portrait"===i,landscape:"landscape"===i}}export default n; | ||
//# sourceMappingURL=index.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("lodash.debounce")):"function"==typeof define&&define.amd?define(["react","lodash.debounce"],t):(e=e||self).useWindowOrientation=t(e.react,e.debounce)}(this,function(e,t){return t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,function(n={}){if("object"!=typeof n)throw new TypeError("The options argument must be formatted as an object.");const{defaultOrientation:o="portrait"}=n;if("portrait"!==o&&"landscape"!==o){const e="string"==typeof o;throw new TypeError(`${e?'"':""}${o}${e?'"':""} is not a valid defaultOrientation. Use "portrait" or "landscape".`)}const[r,i]=e.useState(o);return e.useEffect(()=>{function e(){window.innerWidth<=window.innerHeight?i("portrait"):i("landscape")}return e(),window.addEventListener("resize",t(e,400)),()=>{window.removeEventListener("resize",t(e,400))}},[]),{orientation:r,portrait:"portrait"===r,landscape:"landscape"===r}}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("lodash.debounce")):"function"==typeof define&&define.amd?define(["react","lodash.debounce"],t):(e||self).useWindowOrientation=t(e.react,e.debounce)}(this,function(e,t){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(t);return function(t={}){if("object"!=typeof t)throw new TypeError("The options argument must be formatted as an object.");const{defaultOrientation:n="portrait"}=t;if("portrait"!==n&&"landscape"!==n){const e="string"==typeof n;throw new TypeError(`${e?'"':""}${n}${e?'"':""} is not a valid defaultOrientation. Use "portrait" or "landscape".`)}const[r,i]=e.useState(n);return e.useEffect(()=>{const e=o.default(()=>{window.innerWidth<=window.innerHeight?i("portrait"):i("landscape")},400,{leading:!0,trailing:!0});return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),e.cancel()}},[]),{orientation:r,portrait:"portrait"===r,landscape:"landscape"===r}}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "use-window-orientation", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A React hook for using window orientation.", | ||
@@ -20,4 +20,8 @@ "author": "Ty Mick <ty@tymick.me> (https://tymick.me)", | ||
"dev": "microbundle watch", | ||
"test": "npm run build && jest --verbose" | ||
"test": "jest --verbose", | ||
"version": "npm run build && git add dist" | ||
}, | ||
"jest": { | ||
"testEnvironment": "jsdom" | ||
}, | ||
"np": { | ||
@@ -33,16 +37,17 @@ "yarn": false | ||
"devDependencies": { | ||
"@babel/core": "^7.12.10", | ||
"@babel/preset-env": "^7.12.11", | ||
"@babel/preset-react": "^7.12.10", | ||
"@babel/core": "^7.14.3", | ||
"@babel/preset-env": "^7.14.4", | ||
"@babel/preset-typescript": "^7.13.0", | ||
"@testing-library/react": "^11.2.7", | ||
"@testing-library/react-hooks": "^7.0.0", | ||
"@types/jest": "^26.0.23", | ||
"@types/lodash.debounce": "^4.0.6", | ||
"@types/react": "^16.14.2", | ||
"babel-jest": "^26.6.3", | ||
"enzyme": "^3.11.0", | ||
"enzyme-adapter-react-16": "^1.15.5", | ||
"jest": "^26.6.3", | ||
"microbundle": "^0.12.4", | ||
"prettier": "^2.2.1", | ||
"react": "^16.14.0", | ||
"react-dom": "^16.14.0", | ||
"typescript": "^3.9.7" | ||
"@types/react": "^17.0.9", | ||
"babel-jest": "^27.0.2", | ||
"jest": "^27.0.4", | ||
"microbundle": "^0.13.1", | ||
"prettier": "^2.3.1", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"typescript": "^4.3.2" | ||
}, | ||
@@ -49,0 +54,0 @@ "keywords": [ |
@@ -86,29 +86,12 @@ # useWindowOrientation | ||
If you'd like to contribute to this project (which would be awesome), here's how to set it up: | ||
If you'd like to contribute to this project (which would be awesome), the easiest way to set it up would be to install the [GitHub CLI](https://cli.github.com/) and then run the following: | ||
1. [Fork this repository](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) to your own GitHub account. | ||
```sh | ||
gh repo fork tywmick/use-window-orientation --clone=true | ||
cd use-window-orientation | ||
npm install | ||
``` | ||
2. Clone it to your device. | ||
Now, you can build the package with `npm run build`, build _and_ watch for changes with `npm run dev` (automatically rebuilding on each change in the source), run the test suite with `npm run test`, and create pull requests with [`gh pr create`](https://cli.github.com/manual/gh_pr_create). | ||
```sh | ||
git clone https://github.com/YOUR_USERNAME/use-window-orientation.git | ||
``` | ||
3. Add this repository as a remote, so you can pull upstream changes in the future with `git pull upstream master`. | ||
```sh | ||
cd use-window-orientation | ||
git remote add upstream https://github.com/tywmick/use-window-orientation.git | ||
``` | ||
4. Install dependencies. | ||
```sh | ||
npm install | ||
``` | ||
- Don't worry about the [high security vulnerability](https://github.com/developit/microbundle/issues/695) in `serialize-javascript` that npm brings up—the vulnerable code [isn't used by Microbundle](https://github.com/developit/microbundle/issues/695#issuecomment-672773094). | ||
Now, you can build the package with `npm run build`, build _and_ watch for changes with `npm run dev` (automatically rebuilding on each change in the source), and run the test suite with `npm run test`. | ||
After building the package, you can test it in another project on your machine by [adding the local path](https://docs.npmjs.com/files/package.json#local-paths) as a dependency (e.g., by running `npm install /path/to/local/use-window-orientation` in that other project). | ||
@@ -115,0 +98,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
34595
35
15
101