@rybr/lenses
Version:
a simple and light package meant to ease data traversal, manipulation, mutation, and transformation
1 lines • 3.39 kB
JavaScript
(()=>{var t={399:(t,n,r)=>{var e=r(743),o=e.loadGlobal,i=e.getConstructorName,u=e.TYPES,c=e.getOperationType,f=function(t,n,r){if(!u.FUNCTION.is(t))throw new Error("At index ".concat(r,": cannot apply function since it is not a Function"));return t(n)},a=function(t,n,r){var e=t.operation,o=t.type;return null==n?u.FUNCTION.is(o)?f(e,n,r):n:u.STRING.is(o)||u.NUMBER.is(o)?function(t,n){return null==n?n:Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0}(e,n):u.FUNCTION.is(o)?f(e,n,r):n},p=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(t){return 0===n.length?t:[].concat(n).map((function(t,n){var r=c(t);if(u.INVALID.is(r))throw new Error("Invalid Get operation at index ".concat(n,": expecting String, Number, or Function but received ").concat(i(t)));return{operation:t,type:r}})).reduce((function(t,n,r){return a(n,t,r)}),t)}};t.exports._get=p,t.exports.defaults=function(t){return function(n){return null==n?t:n}},t.exports.get=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return p.apply(void 0,r)(t)},o(t.exports)},743:t=>{function n(t,n){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),r.push.apply(r,e)}return r}function r(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(n){e(t,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(o,n))}))}return t}function e(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var i=function(t){return null==t?"".concat(t):t.constructor?t.constructor.name:"Unknown"},u=function(t,n,r,e){return t===n||t instanceof e||i(t)===e.name||o(t)===r},c={STRING:{is:function(t){return u(t,c.STRING,"string",String)},toString:function(){return"STRING"}},FUNCTION:{is:function(t){return u(t,c.FUNCTION,"function",Function)},toString:function(){return"FUNCTION"}},NUMBER:{is:function(t){return u(t,c.NUMBER,"number",Number)},toString:function(){return"NUMBER"}},OBJECT:{is:function(t){return u(t,c.OBJECT,"object",Object)},toString:function(){return"OBJECT"}},ARRAY:{is:function(t){return t===c.ARRAY||Array.isArray(t)},toString:function(){return"ARRAY"}},HTML_ELEMENT:{is:function(t){return u(t,c.HTML_ELEMENT,"object",HTMLElement)},toString:function(){return"HTML_ELEMENT"}},INVALID:{is:function(t){return t===c.INVALID},toString:function(){return"INVALID"}}};t.exports={getConstructorName:i,getOperationType:function(t){return c.STRING.is(t)&&t.trim().length>0?c.STRING:c.NUMBER.is(t)&&t>=0?c.NUMBER:c.FUNCTION.is(t)?c.FUNCTION:c.INVALID},TYPES:c,loadGlobal:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"undefined"!=typeof window&&(window.L=r(r({},window.L),t))}}}},n={};!function r(e){if(n[e])return n[e].exports;var o=n[e]={exports:{}};return t[e](o,o.exports,r),o.exports}(399)})();