UNPKG

@redux-ts-starter-kit/slice

Version:
17 lines (14 loc) 5.48 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("reselect"),t=require("immer"),n=require("memoize-state");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(t),i=r(n),u="production"===process.env.NODE_ENV;function a(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return""!==e[0]?Object.assign((function(){return function(t){return c(e,t)}}),{bindToInput:function(){return function(t){return c(e,t)}}}):Object.assign((function(){return function(t){return c(e.slice(1),t)}}),{bindToInput:function(){return function(t){return c(e.slice(1),t)}}})}function c(e,t){if(0===e.length)return t;for(var n=t,r=e.length,o=0;o<r;o+=1){var i=e[o];if(null==n)return 0!==o?u||console.warn('There is a possible mis-match between the "paths" and "object" in a getter resulting in an undefined value before the last path, The potentially bad path is "%s". The combined path leading up to here is "%s"',"['"+e[o-1]+"']","['"+e.slice(0,o).join("']['")+"']"):u||console.warn("A getter was called on an undefined or null value"),n;"object"!=typeof n&&(u||console.warn('Warning: You attempted to call a getter on a Non-Object value, The value is "%s", and the path to the value is "%s"',n,0===o?"":"['"+e.slice(0,o).join("']['")+"']")),n=n[i],r===o+1&&null==n&&(u||console.warn('There is a possible mis-match between the final "path" argument and "object" in a getter resulting in an undefined value, The potentially bad final path is "%s". The combined path leading up to here is "%s"',"['"+i+"']","['"+e.join("']['")+"']"))}return n}function s(e){return function(){return function(e){var t=function(t){return{type:e,payload:t}};return t.type=""+e,t.toString=function(){return""+e},t}(e)}}function f(e){var t=e.initialState,n=e.cases;return function(e,r){return void 0===e&&(e=t),o.default(e,(function(e){var t=n[r.type];return t?t(e,r.payload):e}))}} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var l=function(){return(l=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function p(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||t)}var d=function(e){var t={};return Object.keys(e).forEach((function(n){t[n]=i.default(e[n].bind(t))})),t};function v(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=a.apply(void 0,t)();return"function"==typeof e?function(t){return e(r(t))}:Object.keys(e).reduce((function(t,n){var o,i=e[n];return l(l({},t),((o={})[n]=function(e){return i(r(e))},o))}),{})}function y(e){return""===e}function h(e,t){var n=e[t];return"string"==typeof n&&""!==n?n:t}Object.defineProperty(exports,"createNextState",{enumerable:!0,get:function(){return t.produce}}),Object.defineProperty(exports,"memoize",{enumerable:!0,get:function(){return i.default}}),exports.createReducer=f,exports.createSlice=function(e){var t=e.cases,n=e.name,r=e.initialState,o=e.computed,i=void 0===o?{}:o,u=e.typeOverrides,c=void 0===u?{}:u,b=Object.keys(t),g=function(e,t,n,r){return void 0===n&&(n={}),void 0===r&&(r=""),f({initialState:e,cases:Object.keys(t).reduce((function(e,o){var i=h(n,o);return y(r)?(e[i]=t[o],e):(e[r+"/"+i]=t[o],e)}),{})})}(r,t,c,n),j=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n=""),e.reduce((function(e,r){var o=h(t,r);return y(n)?(e[r]=s(o)(),e):(e[r]=s(n+"/"+o)(),e)}),{})}(b,c,n),m=function(e,t){return void 0===t&&(t={}),function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return v.apply(void 0,p([l(l({},e),d(t))],n))}}(function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=("object"!=typeof e||null===e||Array.isArray(e)?[]:Object.keys(e)).reduce((function(e,n){var r;return l(l({},e),((r={})[n]=a.apply(void 0,p(p([],t),[n]))(),r))}),{});return l({selectSlice:a.apply(void 0,t)()},r)}(r),i);return{name:n,actions:j,reducer:g,selectors:m(n),reMapSelectorsTo:m}},exports.createSliceAction=function(e,t){return function(){var n=function(n){return{type:e,payload:n,slice:t}};return n.type=String(e),n.slice=String(t),n.toString=function(){return String(e)},n}},exports.createType=function(e){return String(e)!==e&&(u||console.error("The argument to createType must be a string, But a(n) "+typeof e+" was received instead.")),e},exports.createTypeSafeActionCreator=s,exports.getActionType=function(e){return""+e},Object.keys(e).forEach((function(t){"default"===t||exports.hasOwnProperty(t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})); //# sourceMappingURL=redux-ts-starter-kit-slice.cjs.js.map