UNPKG

selectorator

Version:

Simplified generator of reselect selectors

2 lines (1 loc) 2.57 kB
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("identitate"),require("fast-equals"),require("reselect"),require("unchanged")):"function"==typeof define&&define.amd?define(["exports","identitate","fast-equals","reselect","unchanged"],r):r((e=e||self).selectorator={},e.identitate,e.fe,e.Reselect,e.unchanged)}(this,function(e,w,j,q,i){"use strict";var x=["First parameter passed must be either an array or a plain object.","If you are creating a standard selector, pass an array of either","properties on the state to retrieve, or custom selector functions.","If creating a structured selector, pass a plain object with source","and destination properties, where source is an array of properties","or custom selector functions, and destination is an array of property","names to assign the values from source to."].join(" "),u='\nWhen providing an object path, you must provide the following properties:\n * path: the path to retrieve, e.g. "foo.bar"\n * argIndx: the index of the argument to retrieve the path from\n'.trim(),s='\nPath provided is of invalid type. It can be any one of the following values:\n * Dot-bracket notation, e.g. "foo.bar" or "bar[0].baz"\n * Number index, e.g. 0\n * Object {path, argIndex}, e.g. {path: "foo.bar", argIndex: 1}\n * Selector function\n'.trim(),c=Object.prototype.hasOwnProperty,I=function(r){var e,t,n,o=typeof r;if("function"===o)return r;if(e=r,"string"===(t=o)||"number"===t||Array.isArray(e))return function(e){return i.get(r,e)};if(n=o,r&&"object"===n){if(c.call(r,"path")&&c.call(r,"argIndex")){var a=w.createIdentity(r.argIndex);return function(){return i.get(r.path,a.apply(null,arguments))}}throw new ReferenceError(u)}throw new TypeError(s)};e.default=function(e,r,t){void 0===r&&(r=w.identity),void 0===t&&(t={});var n,o,a,i,u,s,c,f,p,d,l,h,y,m,v,g,b=(a=(n=t).deepEqual,i=void 0!==a&&a,u=n.isEqual,s=void 0===u?j.sameValueZeroEqual:u,c=n.memoizer,f=n.memoizerParams,p=void 0===f?[]:f,d=c||q.defaultMemoize,l=i?j.deepEqual:s,(o=q.createSelectorCreator).call.apply(o,[null,d,l].concat(p)));if(Array.isArray(e)){if(!e.length)throw new ReferenceError("You have not provided any values for paths, so no values can be retrieved from state.");return h=r,b(e.map(I),h)}if(e&&null!==e&&"object"==typeof e)return y=e,m=b,g=Object.keys(y),m(g.map(function(e){return I(y[e])}),(v=g,function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return v.reduce(function(e,r,t){return e[r]=n[t],e},{})}));throw new TypeError(x)},Object.defineProperty(e,"__esModule",{value:!0})});