@rybr/lenses
Version:
a simple and light package meant to ease data traversal, manipulation, mutation, and transformation
1 lines • 4.93 kB
JavaScript
(()=>{var t={472:(t,n,r)=>{function o(t,n,r){return(o=e()?Reflect.construct:function(t,n,r){var o=[null];o.push.apply(o,n);var e=new(Function.bind.apply(t,o));return r&&u(e,r.prototype),e}).apply(null,arguments)}function e(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,n){return(u=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}var c=r(743),i=c.loadGlobal,f=c.getConstructorName,p=c.TYPES,a=function(t){if(!p.FUNCTION.is(t))throw new Error("func must take a function as an input, received ".concat(f(t)," instead"));return function(n){return null==n?n:t(n)}},l=function(){return function(t){return!!t}},s=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(t){return parseInt.apply(void 0,[t].concat(n))}},y=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(t){return parseFloat.apply(void 0,[t].concat(n))}},N=function(){return function(t){return null==t?0:Number(t).valueOf()}},O=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(t){return JSON.stringify.apply(JSON,[t].concat(n))}},g=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(t){return JSON.parse.apply(JSON,[t].concat(n))}},b=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 function(n){return o(t,[n].concat(r))}};t.exports.func=a,t.exports.log=function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function(r){var o=t?"".concat(t," ").concat(r):r;return console.log(n?JSON.stringify(o,null,2):JSON.stringify(o)),r}},t.exports.parse=function(){return a(g.apply(void 0,arguments))},t.exports.stringify=function(){return a(O.apply(void 0,arguments))},t.exports.tryParse=function(){try{return a(g.apply(void 0,arguments))}catch(t){return null}},t.exports.toBool=function(){return a(l.apply(void 0,arguments))},t.exports.toNum=function(){return a(N.apply(void 0,arguments))},t.exports.toInt=function(){return a(s.apply(void 0,arguments))},t.exports.toFloat=function(){return a(y.apply(void 0,arguments))},t.exports.toType=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return a(b.apply(void 0,[t].concat(r)))},t.exports.forceBool=l,t.exports.forceInt=s,t.exports.forceFloat=y,t.exports.forceNum=N,t.exports.forceString=O,t.exports.forceType=b,i(t.exports)},743:t=>{function n(t,n){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),r.push.apply(r,o)}return r}function r(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?n(Object(e),!0).forEach((function(n){o(t,n,e[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):n(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}))}return t}function o(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function e(t){return(e="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 u=function(t){return null==t?"".concat(t):t.constructor?t.constructor.name:"Unknown"},c=function(t,n,r,o){return t===n||t instanceof o||u(t)===o.name||e(t)===r},i={STRING:{is:function(t){return c(t,i.STRING,"string",String)},toString:function(){return"STRING"}},FUNCTION:{is:function(t){return c(t,i.FUNCTION,"function",Function)},toString:function(){return"FUNCTION"}},NUMBER:{is:function(t){return c(t,i.NUMBER,"number",Number)},toString:function(){return"NUMBER"}},OBJECT:{is:function(t){return c(t,i.OBJECT,"object",Object)},toString:function(){return"OBJECT"}},ARRAY:{is:function(t){return t===i.ARRAY||Array.isArray(t)},toString:function(){return"ARRAY"}},HTML_ELEMENT:{is:function(t){return c(t,i.HTML_ELEMENT,"object",HTMLElement)},toString:function(){return"HTML_ELEMENT"}},INVALID:{is:function(t){return t===i.INVALID},toString:function(){return"INVALID"}}};t.exports={getConstructorName:u,getOperationType:function(t){return i.STRING.is(t)&&t.trim().length>0?i.STRING:i.NUMBER.is(t)&&t>=0?i.NUMBER:i.FUNCTION.is(t)?i.FUNCTION:i.INVALID},TYPES:i,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(o){if(n[o])return n[o].exports;var e=n[o]={exports:{}};return t[o](e,e.exports,r),e.exports}(472)})();