@washingtonpost/red-react-lib
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -1,1 +0,1 @@ | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),React__default=_interopDefault(React),reactRouterDom=require("react-router-dom"),qs=_interopDefault(require("qs"));function usePrevious(e){var r=React.useRef();return React.useEffect(function(){r.current=e},[e]),r.current}function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(e){_defineProperty(r,e,t[e])})}return r}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_nonIterableRest()}function _toArray(e){return _arrayWithHoles(e)||_iterableToArray(e)||_nonIterableRest()}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var r=0,t=new Array(e.length);r<e.length;r++)t[r]=e[r];return t}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _iterableToArrayLimit(e,r){var t=[],n=!0,o=!1,a=void 0;try{for(var u,i=e[Symbol.iterator]();!(n=(u=i.next()).done)&&(t.push(u.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return t}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var setLoading=function(e){return{result:e.result,loading:!0}};function usePromiseCallback(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,n=_slicedToArray(React.useState({}),2),o=n[0],a=n[1],u=React.useRef(0),i=React.useRef(0),c=React.useCallback(function(){t?(clearTimeout(u.current),u.current=setTimeout(function(){return a(setLoading)},t)):a(setLoading);var r=++i.current;e.apply(void 0,arguments).then(function(e){return r===i.current&&a({result:e})}).catch(function(e){return r===i.current&&a({err:e})}).finally(function(){return r===i.current&&clearTimeout(u.current)})},r);return React.useEffect(function(){i.current=0,clearTimeout(u.current)},[]),[c,o.result,o.loading,o.err]}function usePromise(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],t=_toArray(usePromiseCallback(e,r,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)),n=t[0],o=t.slice(1),a=React.useCallback(function(){return n.apply(void 0,_toConsumableArray(r))},[n]);return React.useEffect(function(){a.apply(void 0,_toConsumableArray(r))},[a]),[a].concat(_toConsumableArray(o))}var defaultOptions={ignoreQueryPrefix:!0,interpretNumericEntities:!0};function useRouter(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:defaultOptions,r=reactRouterDom.useParams(),t=reactRouterDom.useLocation(),i=reactRouterDom.useHistory(),n=reactRouterDom.useRouteMatch();return React__default.useMemo(function(){var u=qs.parse(t.search,e);return{push:i.push,replace:i.replace,pathname:t.pathname,query:u,setQuery:function(r,e){var t=(1<arguments.length&&void 0!==e?e:{}).method,n=void 0===t?"push":t,o="function"==typeof r?r:function(e){return _objectSpread({},e,r)},a=qs.stringify(o(u));i[n]("?".concat(a))},params:r,match:n,location:t,history:i}},[r,n,t,i,e])}var index=Object.freeze({usePrevious:usePrevious,usePromise:usePromise,usePromiseCallback:usePromiseCallback,useRouter:useRouter});exports.hooks=index; | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),React__default=_interopDefault(React),reactRouterDom=require("react-router-dom"),qs=_interopDefault(require("qs"));function usePrevious(e){var r=React.useRef();return React.useEffect(function(){r.current=e},[e]),r.current}function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(e){_defineProperty(r,e,t[e])})}return r}function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_nonIterableRest()}function _toArray(e){return _arrayWithHoles(e)||_iterableToArray(e)||_nonIterableRest()}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var r=0,t=new Array(e.length);r<e.length;r++)t[r]=e[r];return t}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _iterableToArrayLimit(e,r){var t=[],n=!0,o=!1,a=void 0;try{for(var u,i=e[Symbol.iterator]();!(n=(u=i.next()).done)&&(t.push(u.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return t}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var setLoading=function(e){return{result:e.result,loading:!0}};function usePromiseCallback(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,n=_slicedToArray(React.useState({}),2),o=n[0],a=n[1],u=React.useRef(0),i=React.useRef(0),c=React.useCallback(function(){t?(clearTimeout(u.current),u.current=setTimeout(function(){return a(setLoading)},t)):a(setLoading);var r=++i.current;return e.apply(void 0,arguments).then(function(e){return r===i.current&&a({result:e})}).catch(function(e){return r===i.current&&a({err:e})}).finally(function(){return r===i.current&&clearTimeout(u.current)})},r);return React.useEffect(function(){i.current=0,clearTimeout(u.current)},[]),[c,o.result,o.loading,o.err]}function usePromise(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],t=_toArray(usePromiseCallback(e,r,2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)),n=t[0],o=t.slice(1),a=React.useCallback(function(){return n.apply(void 0,_toConsumableArray(r))},[n]);return React.useEffect(function(){a.apply(void 0,_toConsumableArray(r))},[a]),[a].concat(_toConsumableArray(o))}var defaultOptions={ignoreQueryPrefix:!0,interpretNumericEntities:!0};function useRouter(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:defaultOptions,r=reactRouterDom.useParams(),t=reactRouterDom.useLocation(),i=reactRouterDom.useHistory(),n=reactRouterDom.useRouteMatch();return React__default.useMemo(function(){var u=qs.parse(t.search,e);return{push:i.push,replace:i.replace,pathname:t.pathname,query:u,setQuery:function(r,e){var t=(1<arguments.length&&void 0!==e?e:{}).method,n=void 0===t?"push":t,o="function"==typeof r?r:function(e){return _objectSpread({},e,r)},a=qs.stringify(o(u));i[n]("?".concat(a))},params:r,match:n,location:t,history:i}},[r,n,t,i,e])}var index=Object.freeze({usePrevious:usePrevious,usePromise:usePromise,usePromiseCallback:usePromiseCallback,useRouter:useRouter});exports.hooks=index; |
@@ -98,4 +98,4 @@ { | ||
}, | ||
"version": "2.0.2", | ||
"gitHead": "42453fc9504ca5f9d56b4db8ab58ae1670b0ad64" | ||
"version": "2.0.3", | ||
"gitHead": "10856de0f9063fce3373f0f3f77773778a0ec653" | ||
} |
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
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
Sorry, the diff of this file is not supported yet
243345
3