-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js.map
1 lines (1 loc) · 3.56 KB
/
index.js.map
1
{"version":3,"sources":["src/index.js"],"names":["typed","getStateSlice","state","scope","path","indexOf","split","reduce","value","pathSegment","scopedAction","actionCreator","meta","scopedSelector","selector","props","scopedReducer","reducer","action","undefined","createScopedAction","createScopedReducer","createScopedSelector"],"mappings":";;;;;;;;;AAAA;;IAAYA,K;;;;QACHA,K,GAAAA,K;;AAET;;;;;;;;AAOO,IAAMC,wCAAgB,SAAhBA,aAAgB,CAACC,KAAD,EAAQC,KAAR,EAAkB;AAC7C,MAAMC,OAAOD,MAAME,OAAN,CAAc,GAAd,MAAuB,CAAC,CAAxB,GAA4B,CAACF,KAAD,CAA5B,GAAsCA,MAAMG,KAAN,CAAY,GAAZ,CAAnD;AACA,SAAOF,KAAKG,MAAL,CAAY,UAACC,KAAD,EAAQC,WAAR;AAAA,WAAwBD,MAAMC,WAAN,CAAxB;AAAA,GAAZ,EAAwDP,KAAxD,CAAP;AACD,CAHM;;AAKP;;;;;;;;;AASO,IAAMQ,sCAAe,SAAfA,YAAe,CAACC,aAAD,EAAgBR,KAAhB;AAAA,SAC1B;AAAA,wBACKQ,yCADL;AAEEC,yBAAWD,0CAAuBC,IAAlC,IAAwCT,YAAxC;AAFF;AAAA,GAD0B;AAAA,CAArB;;AAMP;;;;;;;AAOO,IAAMU,0CAAiB,SAAjBA,cAAiB,CAACC,QAAD,EAAWX,KAAX;AAAA,SAAqB,UAACD,KAAD,EAAQa,KAAR;AAAA,WACjDD,SAASb,cAAcC,KAAd,EAAqBC,KAArB,CAAT,EAAsCY,KAAtC,CADiD;AAAA,GAArB;AAAA,CAAvB;;AAGP;;;;;;;;;;AAUO,IAAMC,wCAAgB,SAAhBA,aAAgB,CAACC,OAAD,EAAUd,KAAV;AAAA,SAAoB,UAACD,KAAD,EAAQgB,MAAR,EAAmB;AAClE,QAAIhB,UAAUiB,SAAV,IAAwBD,OAAON,IAAP,IAAeM,OAAON,IAAP,CAAYT,KAAZ,KAAsBA,KAAjE,EAAyE;AACvE,aAAOc,QAAQf,KAAR,EAAegB,MAAf,CAAP;AACD;AACD,WAAOhB,KAAP;AACD,GAL4B;AAAA,CAAtB;;AAOA,IAAMkB,kDAAqBV,YAA3B;AACA,IAAMW,oDAAsBL,aAA5B;AACA,IAAMM,sDAAuBT,cAA7B","file":"index.js","sourcesContent":["import * as typed from './typed';\nexport { typed };\n\n/**\n * Utility to grab a slice of the state based on the scope\n *\n * @param {object} state - A branch of a state object\n * @param {string} scope - A key pointing to a part of state\n * @return {object} - the slice of state\n */\nexport const getStateSlice = (state, scope) => {\n const path = scope.indexOf('/') === -1 ? [scope] : scope.split('/');\n return path.reduce((value, pathSegment) => value[pathSegment], state);\n};\n\n/**\n * Creates an action creator with predefined scope. This allows generic\n * action creators to be created for a specific part of state.\n *\n * @param {function} actionCreator - Function which creates an action. The `scope` must\n * be the last param.\n * @param {string} scope - State path\n * @return {function} Scoped action creator\n */\nexport const scopedAction = (actionCreator, scope) =>\n (...args) => ({\n ...actionCreator(...args),\n meta: { ...actionCreator(...args).meta, scope }\n })\n\n/**\n * Create a selector with a predefined scope. This allows generic selectors\n * to be created for a specific part of state.\n * @param {function} selector - Selector which is relative to a slice of state\n * @param {string} scope - State path\n * @return {function} Scoped selector\n */\nexport const scopedSelector = (selector, scope) => (state, props) =>\n selector(getStateSlice(state, scope), props);\n\n/**\n * A helper to manage scoped actions. This utility acts as a gatekeeper.\n * The reducer will only be invoked if the scope matches or when the reducer\n * is initialized with an undefined state. The second case allows the\n * initialState to be applied.\n *\n * @param {function} reducer - Reducer function to scope\n * @param {string} scope - State path\n * @return {function}\n */\nexport const scopedReducer = (reducer, scope) => (state, action) => {\n if (state === undefined || (action.meta && action.meta.scope === scope)) {\n return reducer(state, action);\n }\n return state;\n};\n\nexport const createScopedAction = scopedAction;\nexport const createScopedReducer = scopedReducer;\nexport const createScopedSelector = scopedSelector;\n"]}