Socket
Socket
Sign inDemoInstall

@poppinss/utils

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poppinss/utils - npm Package Compare versions

Comparing version 2.5.10 to 3.0.0

build/helpers.d.ts

12

build/index.d.ts

@@ -1,18 +0,8 @@

export { base64 } from './src/base64';
export { compose, NormalizeConstructor } from './src/compose';
export * as lodash from './src/lodash';
export { Exception } from './src/Exception';
export { safeEqual } from './src/safeEqual';
export { safeParse } from './src/safeParse';
export { safeStringify } from './src/safeStringify';
export { fsReadAll } from './src/fsReadAll';
export { resolveDir } from './src/resolveDir';
export { requireAll } from './src/requireAll';
export { esmRequire } from './src/esmRequire';
export { interpolate } from './src/interpolate';
export { esmResolver } from './src/esmResolver';
export { resolveFrom } from './src/resolveFrom';
export { randomString } from './src/randomString';
export { MessageBuilder } from './src/MessageBuilder';
export { safeStringify } from './src/safeStringify';
export { defineStaticProperty } from './src/defineStaticProperty';
export { ManagerConfigValidator } from './src/ManagerConfigValidator';

@@ -30,35 +30,14 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ManagerConfigValidator = exports.defineStaticProperty = exports.MessageBuilder = exports.randomString = exports.resolveFrom = exports.esmResolver = exports.interpolate = exports.esmRequire = exports.requireAll = exports.resolveDir = exports.fsReadAll = exports.safeStringify = exports.safeParse = exports.safeEqual = exports.Exception = exports.lodash = exports.compose = exports.base64 = void 0;
var base64_1 = require("./src/base64");
Object.defineProperty(exports, "base64", { enumerable: true, get: function () { return base64_1.base64; } });
var compose_1 = require("./src/compose");
Object.defineProperty(exports, "compose", { enumerable: true, get: function () { return compose_1.compose; } });
// @ts-ignore
exports.ManagerConfigValidator = exports.defineStaticProperty = exports.safeStringify = exports.esmResolver = exports.esmRequire = exports.safeParse = exports.Exception = exports.lodash = void 0;
exports.lodash = __importStar(require("./src/lodash"));
var Exception_1 = require("./src/Exception");
Object.defineProperty(exports, "Exception", { enumerable: true, get: function () { return Exception_1.Exception; } });
var safeEqual_1 = require("./src/safeEqual");
Object.defineProperty(exports, "safeEqual", { enumerable: true, get: function () { return safeEqual_1.safeEqual; } });
var safeParse_1 = require("./src/safeParse");
Object.defineProperty(exports, "safeParse", { enumerable: true, get: function () { return safeParse_1.safeParse; } });
var safeStringify_1 = require("./src/safeStringify");
Object.defineProperty(exports, "safeStringify", { enumerable: true, get: function () { return safeStringify_1.safeStringify; } });
var fsReadAll_1 = require("./src/fsReadAll");
Object.defineProperty(exports, "fsReadAll", { enumerable: true, get: function () { return fsReadAll_1.fsReadAll; } });
var resolveDir_1 = require("./src/resolveDir");
Object.defineProperty(exports, "resolveDir", { enumerable: true, get: function () { return resolveDir_1.resolveDir; } });
var requireAll_1 = require("./src/requireAll");
Object.defineProperty(exports, "requireAll", { enumerable: true, get: function () { return requireAll_1.requireAll; } });
var esmRequire_1 = require("./src/esmRequire");
Object.defineProperty(exports, "esmRequire", { enumerable: true, get: function () { return esmRequire_1.esmRequire; } });
var interpolate_1 = require("./src/interpolate");
Object.defineProperty(exports, "interpolate", { enumerable: true, get: function () { return interpolate_1.interpolate; } });
var esmResolver_1 = require("./src/esmResolver");
Object.defineProperty(exports, "esmResolver", { enumerable: true, get: function () { return esmResolver_1.esmResolver; } });
var resolveFrom_1 = require("./src/resolveFrom");
Object.defineProperty(exports, "resolveFrom", { enumerable: true, get: function () { return resolveFrom_1.resolveFrom; } });
var randomString_1 = require("./src/randomString");
Object.defineProperty(exports, "randomString", { enumerable: true, get: function () { return randomString_1.randomString; } });
var MessageBuilder_1 = require("./src/MessageBuilder");
Object.defineProperty(exports, "MessageBuilder", { enumerable: true, get: function () { return MessageBuilder_1.MessageBuilder; } });
var safeStringify_1 = require("./src/safeStringify");
Object.defineProperty(exports, "safeStringify", { enumerable: true, get: function () { return safeStringify_1.safeStringify; } });
var defineStaticProperty_1 = require("./src/defineStaticProperty");

@@ -65,0 +44,0 @@ Object.defineProperty(exports, "defineStaticProperty", { enumerable: true, get: function () { return defineStaticProperty_1.defineStaticProperty; } });

@@ -12,3 +12,3 @@ "use strict";

exports.defineStaticProperty = void 0;
const klona_1 = require("klona");
const lodash_1 = require("./lodash");
/**

@@ -48,3 +48,3 @@ * Define static properties on a class with inheritance in play.

Object.defineProperty(self, propertyName, {
value: typeof strategy === 'function' ? strategy(value) : klona_1.klona(value),
value: typeof strategy === 'function' ? strategy(value) : lodash_1.cloneDeep(value),
configurable: true,

@@ -51,0 +51,0 @@ enumerable: true,

/**
* @license
* Lodash (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
* Build: `lodash exports="node" include="pick,omit,get,set,unset,mergeWith,merge,snakeCase,camelCase,startCase" -o build/src/lodash/index.js --production`
* Build: `lodash exports="node" include="pick,omit,get,set,unset,mergeWith,merge,has,size,clone,cloneDeep" -o src/lodash/index.js --production`
*/
;(function(){function t(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}function n(t,n){for(var r=-1,e=null==t?0:t.length;++r<e&&n(t[r],r,t)!==false;);return t}function r(t,n){for(var r=-1,e=null==t?0:t.length,u=0,o=[];++r<e;){var c=t[r];n(c,r,t)&&(o[u++]=c)}return o}function e(t,n){for(var r=-1,e=null==t?0:t.length,u=Array(e);++r<e;)u[r]=n(t[r],r,t);return u}function u(t,n){for(var r=-1,e=n.length,u=t.length;++r<e;)t[u+r]=n[r];
return t}function o(t,n,r,e){var u=-1,o=null==t?0:t.length;for(e&&o&&(r=t[++u]);++u<o;)r=n(r,t[u],u,t);return r}function c(t){return t.split("")}function i(t){return t.match(Ir)||[]}function a(t){return function(n){return null==t?Tn:t[n]}}function f(t,n){for(var r=-1,e=Array(t);++r<t;)e[r]=n(r);return e}function l(t){return function(n){return t(n)}}function s(t,n){return null==t?Tn:t[n]}function h(t){return ze.test(t)}function p(t){return Ee.test(t)}function b(t,n){return function(r){return t(n(r));
}}function y(t,n){return"__proto__"==n?Tn:t[n]}function v(t){return h(t)?_(t):c(t)}function _(t){return t.match(we)||[]}function g(t){return t.match(me)||[]}function d(){}function j(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}function x(){this.__data__=ju?ju(null):{},this.size=0}function A(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}function O(t){var n=this.__data__;if(ju){var r=n[t];return r===Fn?Tn:r}return Ye.call(n,t)?n[t]:Tn;
}function w(t){var n=this.__data__;return ju?n[t]!==Tn:Ye.call(n,t)}function m(t,n){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=ju&&n===Tn?Fn:n,this}function z(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}function E(){this.__data__=[],this.size=0}function S(t){var n=this.__data__,r=H(n,t);return!(r<0)&&(r==n.length-1?n.pop():cu.call(n,r,1),--this.size,true)}function I(t){var n=this.__data__,r=H(n,t);return r<0?Tn:n[r][1]}function C(t){return H(this.__data__,t)>-1;
}function U(t,n){var r=this.__data__,e=H(r,t);return e<0?(++this.size,r.push([t,n])):r[e][1]=n,this}function L(t){var n=-1,r=null==t?0:t.length;for(this.clear();++n<r;){var e=t[n];this.set(e[0],e[1])}}function k(){this.size=0,this.__data__={hash:new j,map:new(vu||z),string:new j}}function R(t){var n=Ft(this,t).delete(t);return this.size-=n?1:0,n}function T(t){return Ft(this,t).get(t)}function $(t){return Ft(this,t).has(t)}function P(t,n){var r=Ft(this,t),e=r.size;return r.set(t,n),this.size+=r.size==e?0:1,
this}function D(t){this.size=(this.__data__=new z(t)).size}function F(){this.__data__=new z,this.size=0}function Z(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}function N(t){return this.__data__.get(t)}function M(t){return this.__data__.has(t)}function B(t,n){var r=this.__data__;if(r instanceof z){var e=r.__data__;if(!vu||e.length<Pn-1)return e.push([t,n]),this.size=++r.size,this;r=this.__data__=new L(e)}return r.set(t,n),this.size=r.size,this}function G(t,n){var r=Du(t),e=!r&&Pu(t),u=!r&&!e&&Fu(t),o=!r&&!e&&!u&&Mu(t),c=r||e||u||o,i=c?f(t.length,String):[],a=i.length;
for(var l in t)!n&&!Ye.call(t,l)||c&&("length"==l||u&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Ht(l,a))||i.push(l);return i}function V(t,n,r){(r===Tn||sn(t[n],r))&&(r!==Tn||n in t)||q(t,n,r)}function W(t,n,r){var e=t[n];Ye.call(t,n)&&sn(e,r)&&(r!==Tn||n in t)||q(t,n,r)}function H(t,n){for(var r=t.length;r--;)if(sn(t[r][0],n))return r;return-1}function Y(t,n){return t&&St(n,wn(n),t)}function J(t,n){return t&&St(n,mn(n),t)}function q(t,n,r){"__proto__"==n&&fu?fu(t,n,{
configurable:true,enumerable:true,value:r,writable:true}):t[n]=r}function K(t,r,e,u,o,c){var i,a=r&Nn,f=r&Mn,l=r&Bn;if(e&&(i=o?e(t,u,o,c):e(t)),i!==Tn)return i;if(!vn(t))return t;var s=Du(t);if(s){if(i=Bt(t),!a)return Et(t,i)}else{var h=Ru(t),p=h==tr||h==nr;if(Fu(t))return xt(t,a);if(h==or||h==Yn||p&&!o){if(i=f||p?{}:Gt(t),!a)return f?Ct(t,J(i,t)):It(t,Y(i,t))}else{if(!Ie[h])return o?t:{};i=Vt(t,h,a)}}c||(c=new D);var b=c.get(t);if(b)return b;if(c.set(t,i),Nu(t))return t.forEach(function(n){i.add(K(n,r,e,n,t,c));
}),i;if(Zu(t))return t.forEach(function(n,u){i.set(u,K(n,r,e,u,t,c))}),i;var y=l?f?Dt:Pt:f?mn:wn,v=s?Tn:y(t);return n(v||t,function(n,u){v&&(u=n,n=t[u]),W(i,u,K(n,r,e,u,t,c))}),i}function Q(t,n,r,e,o){var c=-1,i=t.length;for(r||(r=Wt),o||(o=[]);++c<i;){var a=t[c];n>0&&r(a)?n>1?Q(a,n-1,r,e,o):u(o,a):e||(o[o.length]=a)}return o}function X(t,n){n=dt(n,t);for(var r=0,e=n.length;null!=t&&r<e;)t=t[on(n[r++])];return r&&r==e?t:Tn}function tt(t,n,r){var e=n(t);return Du(t)?e:u(e,r(t))}function nt(t){return null==t?t===Tn?hr:ur:au&&au in Object(t)?Nt(t):nn(t);
}function rt(t,n){return null!=t&&n in Object(t)}function et(t){return _n(t)&&nt(t)==Yn}function ut(t){return _n(t)&&Ru(t)==rr}function ot(t){return!(!vn(t)||Kt(t))&&(bn(t)?Qe:Lr).test(cn(t))}function ct(t){return _n(t)&&Ru(t)==fr}function it(t){return _n(t)&&yn(t.length)&&!!Se[nt(t)]}function at(t){if(!Qt(t))return hu(t);var n=[];for(var r in Object(t))Ye.call(t,r)&&"constructor"!=r&&n.push(r);return n}function ft(t){if(!vn(t))return tn(t);var n=Qt(t),r=[];for(var e in t)("constructor"!=e||!n&&Ye.call(t,e))&&r.push(e);
return r}function lt(t,n,r,e,u){t!==n&&Cu(n,function(o,c){if(vn(o))u||(u=new D),st(t,n,c,r,lt,e,u);else{var i=e?e(y(t,c),o,c+"",t,n,u):Tn;i===Tn&&(i=o),V(t,c,i)}},mn)}function st(t,n,r,e,u,o,c){var i=y(t,r),a=y(n,r),f=c.get(a);if(f)return V(t,r,f),Tn;var l=o?o(i,a,r+"",t,n,c):Tn,s=l===Tn;if(s){var h=Du(a),p=!h&&Fu(a),b=!h&&!p&&Mu(a);l=a,h||p||b?Du(i)?l=i:pn(i)?l=Et(i):p?(s=false,l=xt(a,true)):b?(s=false,l=zt(a,true)):l=[]:gn(a)||Pu(a)?(l=i,Pu(i)?l=jn(i):(!vn(i)||e&&bn(i))&&(l=Gt(a))):s=false}s&&(c.set(a,l),u(l,a,e,o,c),
c.delete(a)),V(t,r,l)}function ht(t,n){return pt(t,n,function(n,r){return On(t,r)})}function pt(t,n,r){for(var e=-1,u=n.length,o={};++e<u;){var c=n[e],i=X(t,c);r(i,c)&&yt(o,dt(c,t),i)}return o}function bt(t,n){return Tu(rn(t,n,Ln),t+"")}function yt(t,n,r,e){if(!vn(t))return t;n=dt(n,t);for(var u=-1,o=n.length,c=o-1,i=t;null!=i&&++u<o;){var a=on(n[u]),f=r;if(u!=c){var l=i[a];f=e?e(l,a,i):Tn,f===Tn&&(f=vn(l)?l:Ht(n[u+1])?[]:{})}W(i,a,f),i=i[a]}return t}function vt(t,n,r){var e=-1,u=t.length;n<0&&(n=-n>u?0:u+n),
r=r>u?u:r,r<0&&(r+=u),u=n>r?0:r-n>>>0,n>>>=0;for(var o=Array(u);++e<u;)o[e]=t[e+n];return o}function _t(t){if(typeof t=="string")return t;if(Du(t))return e(t,_t)+"";if(dn(t))return Su?Su.call(t):"";var n=t+"";return"0"==n&&1/t==-Wn?"-0":n}function gt(t,n){return n=dt(n,t),t=en(t,n),null==t||delete t[on(fn(n))]}function dt(t,n){return Du(t)?t:Jt(t,n)?[t]:$u(xn(t))}function jt(t,n,r){var e=t.length;return r=r===Tn?e:r,!n&&r>=e?t:vt(t,n,r)}function xt(t,n){if(n)return t.slice();var r=t.length,e=ru?ru(r):new t.constructor(r);
return t.copy(e),e}function At(t){var n=new t.constructor(t.byteLength);return new nu(n).set(new nu(t)),n}function Ot(t,n){return new t.constructor(n?At(t.buffer):t.buffer,t.byteOffset,t.byteLength)}function wt(t){var n=new t.constructor(t.source,Ur.exec(t));return n.lastIndex=t.lastIndex,n}function mt(t){return Eu?Object(Eu.call(t)):{}}function zt(t,n){return new t.constructor(n?At(t.buffer):t.buffer,t.byteOffset,t.length)}function Et(t,n){var r=-1,e=t.length;for(n||(n=Array(e));++r<e;)n[r]=t[r];
return n}function St(t,n,r,e){var u=!r;r||(r={});for(var o=-1,c=n.length;++o<c;){var i=n[o],a=e?e(r[i],t[i],i,r,t):Tn;a===Tn&&(a=t[i]),u?q(r,i,a):W(r,i,a)}return r}function It(t,n){return St(t,Lu(t),n)}function Ct(t,n){return St(t,ku(t),n)}function Ut(t){return bt(function(n,r){var e=-1,u=r.length,o=u>1?r[u-1]:Tn,c=u>2?r[2]:Tn;for(o=t.length>3&&typeof o=="function"?(u--,o):Tn,c&&Yt(r[0],r[1],c)&&(o=u<3?Tn:o,u=1),n=Object(n);++e<u;){var i=r[e];i&&t(n,i,e,o)}return n})}function Lt(t){return function(n,r,e){
for(var u=-1,o=Object(n),c=e(n),i=c.length;i--;){var a=c[t?i:++u];if(r(o[a],a,o)===false)break}return n}}function kt(t){return function(n){n=xn(n);var r=h(n)?v(n):Tn,e=r?r[0]:n.charAt(0),u=r?jt(r,1).join(""):n.slice(1);return e[t]()+u}}function Rt(t){return function(n){return o(Cn(In(n).replace(Ae,"")),t,"")}}function Tt(t){return gn(t)?Tn:t}function $t(t){return Tu(rn(t,Tn,an),t+"")}function Pt(t){return tt(t,wn,Lu)}function Dt(t){return tt(t,mn,ku)}function Ft(t,n){var r=t.__data__;return qt(n)?r[typeof n=="string"?"string":"hash"]:r.map;
}function Zt(t,n){var r=s(t,n);return ot(r)?r:Tn}function Nt(t){var n=Ye.call(t,au),r=t[au];try{t[au]=Tn;var e=true}catch(t){}var u=qe.call(t);return e&&(n?t[au]=r:delete t[au]),u}function Mt(t,n,r){n=dt(n,t);for(var e=-1,u=n.length,o=false;++e<u;){var c=on(n[e]);if(!(o=null!=t&&r(t,c)))break;t=t[c]}return o||++e!=u?o:(u=null==t?0:t.length,!!u&&yn(u)&&Ht(c,u)&&(Du(t)||Pu(t)))}function Bt(t){var n=t.length,r=new t.constructor(n);return n&&"string"==typeof t[0]&&Ye.call(t,"index")&&(r.index=t.index,r.input=t.input),
r}function Gt(t){return typeof t.constructor!="function"||Qt(t)?{}:Iu(eu(t))}function Vt(t,n,r){var e=t.constructor;switch(n){case br:return At(t);case Kn:case Qn:return new e(+t);case yr:return Ot(t,r);case vr:case _r:case gr:case dr:case jr:case xr:case Ar:case Or:case wr:return zt(t,r);case rr:return new e;case er:case lr:return new e(t);case ar:return wt(t);case fr:return new e;case sr:return mt(t)}}function Wt(t){return Du(t)||Pu(t)||!!(iu&&t&&t[iu])}function Ht(t,n){var r=typeof t;return n=null==n?Hn:n,
!!n&&("number"==r||"symbol"!=r&&kr.test(t))&&t>-1&&t%1==0&&t<n}function Yt(t,n,r){if(!vn(r))return false;var e=typeof n;return!!("number"==e?hn(r)&&Ht(n,r.length):"string"==e&&n in r)&&sn(r[n],t)}function Jt(t,n){if(Du(t))return false;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!dn(t))||(zr.test(t)||!mr.test(t)||null!=n&&t in Object(n))}function qt(t){var n=typeof t;return"string"==n||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==t:null===t}function Kt(t){return!!Je&&Je in t;
}function Qt(t){var n=t&&t.constructor;return t===(typeof n=="function"&&n.prototype||Ve)}function Xt(t){var n=ln(t,function(t){return r.size===Zn&&r.clear(),t}),r=n.cache;return n}function tn(t){var n=[];if(null!=t)for(var r in Object(t))n.push(r);return n}function nn(t){return qe.call(t)}function rn(n,r,e){return r=pu(r===Tn?n.length-1:r,0),function(){for(var u=arguments,o=-1,c=pu(u.length-r,0),i=Array(c);++o<c;)i[o]=u[r+o];o=-1;for(var a=Array(r+1);++o<r;)a[o]=u[o];return a[r]=e(i),t(n,this,a);
}}function en(t,n){return n.length<2?t:X(t,vt(n,0,-1))}function un(t){var n=0,r=0;return function(){var e=bu(),u=Vn-(e-r);if(r=e,u>0){if(++n>=Gn)return arguments[0]}else n=0;return t.apply(Tn,arguments)}}function on(t){if(typeof t=="string"||dn(t))return t;var n=t+"";return"0"==n&&1/t==-Wn?"-0":n}function cn(t){if(null!=t){try{return He.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function an(t){return(null==t?0:t.length)?Q(t,1):[]}function fn(t){var n=null==t?0:t.length;return n?t[n-1]:Tn;
}function ln(t,n){if(typeof t!="function"||null!=n&&typeof n!="function")throw new TypeError(Dn);var r=function(){var e=arguments,u=n?n.apply(this,e):e[0],o=r.cache;if(o.has(u))return o.get(u);var c=t.apply(this,e);return r.cache=o.set(u,c)||o,c};return r.cache=new(ln.Cache||L),r}function sn(t,n){return t===n||t!==t&&n!==n}function hn(t){return null!=t&&yn(t.length)&&!bn(t)}function pn(t){return _n(t)&&hn(t)}function bn(t){if(!vn(t))return false;var n=nt(t);return n==tr||n==nr||n==qn||n==ir}function yn(t){
return typeof t=="number"&&t>-1&&t%1==0&&t<=Hn}function vn(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}function _n(t){return null!=t&&typeof t=="object"}function gn(t){if(!_n(t)||nt(t)!=or)return false;var n=eu(t);if(null===n)return true;var r=Ye.call(n,"constructor")&&n.constructor;return typeof r=="function"&&r instanceof r&&He.call(r)==Ke}function dn(t){return typeof t=="symbol"||_n(t)&&nt(t)==sr}function jn(t){return St(t,mn(t))}function xn(t){return null==t?"":_t(t)}function An(t,n,r){
var e=null==t?Tn:X(t,n);return e===Tn?r:e}function On(t,n){return null!=t&&Mt(t,n,rt)}function wn(t){return hn(t)?G(t):at(t)}function mn(t){return hn(t)?G(t,true):ft(t)}function zn(t,n,r){return null==t?t:yt(t,n,r)}function En(t,n){return null==t||gt(t,n)}function Sn(t){return qu(xn(t).toLowerCase())}function In(t){return t=xn(t),t&&t.replace(Rr,Me).replace(Oe,"")}function Cn(t,n,r){return t=xn(t),n=r?Tn:n,n===Tn?p(t)?g(t):i(t):t.match(n)||[]}function Un(t){return function(){return t}}function Ln(t){
return t}function kn(){return[]}function Rn(){return false}var Tn,$n="4.17.5",Pn=200,Dn="Expected a function",Fn="__lodash_hash_undefined__",Zn=500,Nn=1,Mn=2,Bn=4,Gn=800,Vn=16,Wn=1/0,Hn=9007199254740991,Yn="[object Arguments]",Jn="[object Array]",qn="[object AsyncFunction]",Kn="[object Boolean]",Qn="[object Date]",Xn="[object Error]",tr="[object Function]",nr="[object GeneratorFunction]",rr="[object Map]",er="[object Number]",ur="[object Null]",or="[object Object]",cr="[object Promise]",ir="[object Proxy]",ar="[object RegExp]",fr="[object Set]",lr="[object String]",sr="[object Symbol]",hr="[object Undefined]",pr="[object WeakMap]",br="[object ArrayBuffer]",yr="[object DataView]",vr="[object Float32Array]",_r="[object Float64Array]",gr="[object Int8Array]",dr="[object Int16Array]",jr="[object Int32Array]",xr="[object Uint8Array]",Ar="[object Uint8ClampedArray]",Or="[object Uint16Array]",wr="[object Uint32Array]",mr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,zr=/^\w*$/,Er=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Sr=/[\\^$.*+?()[\]{}|]/g,Ir=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Cr=/\\(\\)?/g,Ur=/\w*$/,Lr=/^\[object .+?Constructor\]$/,kr=/^(?:0|[1-9]\d*)$/,Rr=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Tr="\\ud800-\\udfff",$r="\\u0300-\\u036f",Pr="\\ufe20-\\ufe2f",Dr="\\u20d0-\\u20ff",Fr=$r+Pr+Dr,Zr="\\u2700-\\u27bf",Nr="a-z\\xdf-\\xf6\\xf8-\\xff",Mr="\\xac\\xb1\\xd7\\xf7",Br="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Gr="\\u2000-\\u206f",Vr=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Wr="A-Z\\xc0-\\xd6\\xd8-\\xde",Hr="\\ufe0e\\ufe0f",Yr=Mr+Br+Gr+Vr,Jr="['\u2019]",qr="["+Tr+"]",Kr="["+Yr+"]",Qr="["+Fr+"]",Xr="\\d+",te="["+Zr+"]",ne="["+Nr+"]",re="[^"+Tr+Yr+Xr+Zr+Nr+Wr+"]",ee="\\ud83c[\\udffb-\\udfff]",ue="(?:"+Qr+"|"+ee+")",oe="[^"+Tr+"]",ce="(?:\\ud83c[\\udde6-\\uddff]){2}",ie="[\\ud800-\\udbff][\\udc00-\\udfff]",ae="["+Wr+"]",fe="\\u200d",le="(?:"+ne+"|"+re+")",se="(?:"+ae+"|"+re+")",he="(?:"+Jr+"(?:d|ll|m|re|s|t|ve))?",pe="(?:"+Jr+"(?:D|LL|M|RE|S|T|VE))?",be=ue+"?",ye="["+Hr+"]?",ve="(?:"+fe+"(?:"+[oe,ce,ie].join("|")+")"+ye+be+")*",_e="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ge="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",de=ye+be+ve,je="(?:"+[te,ce,ie].join("|")+")"+de,xe="(?:"+[oe+Qr+"?",Qr,ce,ie,qr].join("|")+")",Ae=RegExp(Jr,"g"),Oe=RegExp(Qr,"g"),we=RegExp(ee+"(?="+ee+")|"+xe+de,"g"),me=RegExp([ae+"?"+ne+"+"+he+"(?="+[Kr,ae,"$"].join("|")+")",se+"+"+pe+"(?="+[Kr,ae+le,"$"].join("|")+")",ae+"?"+le+"+"+he,ae+"+"+pe,ge,_e,Xr,je].join("|"),"g"),ze=RegExp("["+fe+Tr+Fr+Hr+"]"),Ee=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Se={};
Se[vr]=Se[_r]=Se[gr]=Se[dr]=Se[jr]=Se[xr]=Se[Ar]=Se[Or]=Se[wr]=true,Se[Yn]=Se[Jn]=Se[br]=Se[Kn]=Se[yr]=Se[Qn]=Se[Xn]=Se[tr]=Se[rr]=Se[er]=Se[or]=Se[ar]=Se[fr]=Se[lr]=Se[pr]=false;var Ie={};Ie[Yn]=Ie[Jn]=Ie[br]=Ie[yr]=Ie[Kn]=Ie[Qn]=Ie[vr]=Ie[_r]=Ie[gr]=Ie[dr]=Ie[jr]=Ie[rr]=Ie[er]=Ie[or]=Ie[ar]=Ie[fr]=Ie[lr]=Ie[sr]=Ie[xr]=Ie[Ar]=Ie[Or]=Ie[wr]=true,Ie[Xn]=Ie[tr]=Ie[pr]=false;var Ce={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a",
"\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae",
"\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g",
"\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O",
"\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w",
"\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"},Ue=typeof global=="object"&&global&&global.Object===Object&&global,Le=typeof self=="object"&&self&&self.Object===Object&&self,ke=Ue||Le||Function("return this")(),Re=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Te=Re&&typeof module=="object"&&module&&!module.nodeType&&module,$e=Te&&Te.exports===Re,Pe=$e&&Ue.process,De=function(){
try{return Pe&&Pe.binding&&Pe.binding("util")}catch(t){}}(),Fe=De&&De.isMap,Ze=De&&De.isSet,Ne=De&&De.isTypedArray,Me=a(Ce),Be=Array.prototype,Ge=Function.prototype,Ve=Object.prototype,We=ke["__core-js_shared__"],He=Ge.toString,Ye=Ve.hasOwnProperty,Je=function(){var t=/[^.]+$/.exec(We&&We.keys&&We.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),qe=Ve.toString,Ke=He.call(Object),Qe=RegExp("^"+He.call(Ye).replace(Sr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Xe=$e?ke.Buffer:Tn,tu=ke.Symbol,nu=ke.Uint8Array,ru=Xe?Xe.allocUnsafe:Tn,eu=b(Object.getPrototypeOf,Object),uu=Object.create,ou=Ve.propertyIsEnumerable,cu=Be.splice,iu=tu?tu.isConcatSpreadable:Tn,au=tu?tu.toStringTag:Tn,fu=function(){
try{var t=Zt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),lu=Object.getOwnPropertySymbols,su=Xe?Xe.isBuffer:Tn,hu=b(Object.keys,Object),pu=Math.max,bu=Date.now,yu=Zt(ke,"DataView"),vu=Zt(ke,"Map"),_u=Zt(ke,"Promise"),gu=Zt(ke,"Set"),du=Zt(ke,"WeakMap"),ju=Zt(Object,"create"),xu=cn(yu),Au=cn(vu),Ou=cn(_u),wu=cn(gu),mu=cn(du),zu=tu?tu.prototype:Tn,Eu=zu?zu.valueOf:Tn,Su=zu?zu.toString:Tn,Iu=function(){function t(){}return function(n){if(!vn(n))return{};if(uu)return uu(n);t.prototype=n;
var r=new t;return t.prototype=Tn,r}}();j.prototype.clear=x,j.prototype.delete=A,j.prototype.get=O,j.prototype.has=w,j.prototype.set=m,z.prototype.clear=E,z.prototype.delete=S,z.prototype.get=I,z.prototype.has=C,z.prototype.set=U,L.prototype.clear=k,L.prototype.delete=R,L.prototype.get=T,L.prototype.has=$,L.prototype.set=P,D.prototype.clear=F,D.prototype.delete=Z,D.prototype.get=N,D.prototype.has=M,D.prototype.set=B;var Cu=Lt(),Uu=fu?function(t,n){return fu(t,"toString",{configurable:true,enumerable:false,
value:Un(n),writable:true})}:Ln,Lu=lu?function(t){return null==t?[]:(t=Object(t),r(lu(t),function(n){return ou.call(t,n)}))}:kn,ku=lu?function(t){for(var n=[];t;)u(n,Lu(t)),t=eu(t);return n}:kn,Ru=nt;(yu&&Ru(new yu(new ArrayBuffer(1)))!=yr||vu&&Ru(new vu)!=rr||_u&&Ru(_u.resolve())!=cr||gu&&Ru(new gu)!=fr||du&&Ru(new du)!=pr)&&(Ru=function(t){var n=nt(t),r=n==or?t.constructor:Tn,e=r?cn(r):"";if(e)switch(e){case xu:return yr;case Au:return rr;case Ou:return cr;case wu:return fr;case mu:return pr}return n;
});var Tu=un(Uu),$u=Xt(function(t){var n=[];return 46===t.charCodeAt(0)&&n.push(""),t.replace(Er,function(t,r,e,u){n.push(e?u.replace(Cr,"$1"):r||t)}),n});ln.Cache=L;var Pu=et(function(){return arguments}())?et:function(t){return _n(t)&&Ye.call(t,"callee")&&!ou.call(t,"callee")},Du=Array.isArray,Fu=su||Rn,Zu=Fe?l(Fe):ut,Nu=Ze?l(Ze):ct,Mu=Ne?l(Ne):it,Bu=Ut(function(t,n,r){lt(t,n,r)}),Gu=Ut(function(t,n,r,e){lt(t,n,r,e)}),Vu=$t(function(t,n){var r={};if(null==t)return r;var u=false;n=e(n,function(n){return n=dt(n,t),
u||(u=n.length>1),n}),St(t,Dt(t),r),u&&(r=K(r,Nn|Mn|Bn,Tt));for(var o=n.length;o--;)gt(r,n[o]);return r}),Wu=$t(function(t,n){return null==t?{}:ht(t,n)}),Hu=Rt(function(t,n,r){return n=n.toLowerCase(),t+(r?Sn(n):n)}),Yu=Rt(function(t,n,r){return t+(r?"_":"")+n.toLowerCase()}),Ju=Rt(function(t,n,r){return t+(r?" ":"")+qu(n)}),qu=kt("toUpperCase");d.constant=Un,d.flatten=an,d.keys=wn,d.keysIn=mn,d.memoize=ln,d.merge=Bu,d.mergeWith=Gu,d.omit=Vu,d.pick=Wu,d.set=zn,d.toPlainObject=jn,d.unset=En,d.words=Cn,
d.camelCase=Hu,d.capitalize=Sn,d.deburr=In,d.eq=sn,d.get=An,d.hasIn=On,d.identity=Ln,d.isArguments=Pu,d.isArray=Du,d.isArrayLike=hn,d.isArrayLikeObject=pn,d.isBuffer=Fu,d.isFunction=bn,d.isLength=yn,d.isMap=Zu,d.isObject=vn,d.isObjectLike=_n,d.isPlainObject=gn,d.isSet=Nu,d.isSymbol=dn,d.isTypedArray=Mu,d.last=fn,d.stubArray=kn,d.stubFalse=Rn,d.snakeCase=Yu,d.startCase=Ju,d.toString=xn,d.upperFirst=qu,d.VERSION=$n,Te&&((Te.exports=d)._=d,Re._=d)}).call(this);
;
(function () {
function t(t, n, r) { switch (r.length) {
case 0: return t.call(n);
case 1: return t.call(n, r[0]);
case 2: return t.call(n, r[0], r[1]);
case 3: return t.call(n, r[0], r[1], r[2]);
} return t.apply(n, r); }
function n(t, n) { for (var r = -1, e = null == t ? 0 : t.length; ++r < e && n(t[r], r, t) !== false;)
; return t; }
function r(t, n) { for (var r = -1, e = null == t ? 0 : t.length, u = 0, o = []; ++r < e;) {
var i = t[r];
n(i, r, t) && (o[u++] = i);
} return o; }
function e(t, n) { for (var r = -1, e = null == t ? 0 : t.length, u = Array(e); ++r < e;)
u[r] = n(t[r], r, t); return u; }
function u(t, n) {
for (var r = -1, e = n.length, u = t.length; ++r < e;)
t[u + r] = n[r];
return t;
}
function o(t) { return function (n) { return null == n ? In : n[t]; }; }
function i(t, n) { for (var r = -1, e = Array(t); ++r < t;)
e[r] = n(r); return e; }
function c(t) { return function (n) { return t(n); }; }
function a(t, n) { return null == t ? In : t[n]; }
function f(t) { return Jr.test(t); }
function l(t, n) { return function (r) { return t(n(r)); }; }
function s(t, n) { return "__proto__" == n ? In : t[n]; }
function h(t) { return f(t) ? p(t) : ae(t); }
function p(t) { for (var n = Hr.lastIndex = 0; Hr.test(t);)
++n; return n; }
function y() { }
function v(t) {
var n = -1, r = null == t ? 0 : t.length;
for (this.clear(); ++n < r;) {
var e = t[n];
this.set(e[0], e[1]);
}
}
function b() { this.__data__ = Re ? Re(null) : {}, this.size = 0; }
function _(t) { var n = this.has(t) && delete this.__data__[t]; return this.size -= n ? 1 : 0, n; }
function g(t) { var n = this.__data__; if (Re) {
var r = n[t];
return r === Ln ? In : r;
} return ye.call(n, t) ? n[t] : In; }
function d(t) { var n = this.__data__; return Re ? n[t] !== In : ye.call(n, t); }
function j(t, n) { var r = this.__data__; return this.size += this.has(t) ? 0 : 1, r[t] = Re && n === In ? Ln : n, this; }
function w(t) {
var n = -1, r = null == t ? 0 : t.length;
for (this.clear(); ++n < r;) {
var e = t[n];
this.set(e[0], e[1]);
}
}
function O() { this.__data__ = [], this.size = 0; }
function m(t) { var n = this.__data__, r = N(n, t); return !(r < 0) && (r == n.length - 1 ? n.pop() : xe.call(n, r, 1), --this.size, true); }
function A(t) { var n = this.__data__, r = N(n, t); return r < 0 ? In : n[r][1]; }
function z(t) { return N(this.__data__, t) > -1; }
function x(t, n) { var r = this.__data__, e = N(r, t); return e < 0 ? (++this.size, r.push([t, n])) : r[e][1] = n, this; }
function S(t) { var n = -1, r = null == t ? 0 : t.length; for (this.clear(); ++n < r;) {
var e = t[n];
this.set(e[0], e[1]);
} }
function k() {
this.size = 0, this.__data__ = { hash: new v, map: new (Te || w), string: new v };
}
function E(t) { var n = $t(this, t).delete(t); return this.size -= n ? 1 : 0, n; }
function I(t) { return $t(this, t).get(t); }
function P(t) { return $t(this, t).has(t); }
function $(t, n) { var r = $t(this, t), e = r.size; return r.set(t, n), this.size += r.size == e ? 0 : 1, this; }
function F(t) { this.size = (this.__data__ = new w(t)).size; }
function L() { this.__data__ = new w, this.size = 0; }
function M(t) { var n = this.__data__, r = n.delete(t); return this.size = n.size, r; }
function T(t) {
return this.__data__.get(t);
}
function U(t) { return this.__data__.has(t); }
function B(t, n) { var r = this.__data__; if (r instanceof w) {
var e = r.__data__;
if (!Te || e.length < $n - 1)
return e.push([t, n]), this.size = ++r.size, this;
r = this.__data__ = new S(e);
} return r.set(t, n), this.size = r.size, this; }
function C(t, n) {
var r = uu(t), e = !r && eu(t), u = !r && !e && ou(t), o = !r && !e && !u && au(t), c = r || e || u || o, a = c ? i(t.length, String) : [], f = a.length;
for (var l in t)
!n && !ye.call(t, l) || c && ("length" == l || u && ("offset" == l || "parent" == l) || o && ("buffer" == l || "byteLength" == l || "byteOffset" == l) || Rt(l, f)) || a.push(l);
return a;
}
function R(t, n, r) { (r === In || cn(t[n], r)) && (r !== In || n in t) || q(t, n, r); }
function D(t, n, r) { var e = t[n]; ye.call(t, n) && cn(e, r) && (r !== In || n in t) || q(t, n, r); }
function N(t, n) { for (var r = t.length; r--;)
if (cn(t[r][0], n))
return r; return -1; }
function V(t, n) { return t && mt(n, On(n), t); }
function W(t, n) { return t && mt(n, mn(n), t); }
function q(t, n, r) { "__proto__" == n && Ee ? Ee(t, n, { configurable: true, enumerable: true, value: r, writable: true }) : t[n] = r; }
function G(t, r, e, u, o, i) {
var c, a = r & Tn, f = r & Un, l = r & Bn;
if (e && (c = o ? e(t, u, o, i) : e(t)), c !== In)
return c;
if (!hn(t))
return t;
var s = uu(t);
if (s) {
if (c = Tt(t), !a)
return Ot(t, c);
}
else {
var h = tu(t), p = h == Kn || h == Qn;
if (ou(t))
return bt(t, a);
if (h == tr || h == Vn || p && !o) {
if (c = f || p ? {} : Ut(t), !a)
return f ? zt(t, W(c, t)) : At(t, V(c, t));
}
else {
if (!Qr[h])
return o ? t : {};
c = Bt(t, h, a);
}
}
i || (i = new F);
var y = i.get(t);
if (y)
return y;
if (i.set(t, c), cu(t))
return t.forEach(function (n) { c.add(G(n, r, e, n, t, i)); }), c;
if (iu(t))
return t.forEach(function (n, u) { c.set(u, G(n, r, e, u, t, i)); }), c;
var v = l ? f ? Pt : It : f ? mn : On, b = s ? In : v(t);
return n(b || t, function (n, u) {
b && (u = n,
n = t[u]), D(c, u, G(n, r, e, u, t, i));
}), c;
}
function H(t, n, r, e, o) { var i = -1, c = t.length; for (r || (r = Ct), o || (o = []); ++i < c;) {
var a = t[i];
n > 0 && r(a) ? n > 1 ? H(a, n - 1, r, e, o) : u(o, a) : e || (o[o.length] = a);
} return o; }
function J(t, n) { n = vt(n, t); for (var r = 0, e = n.length; null != t && r < e;)
t = t[Yt(n[r++])]; return r && r == e ? t : In; }
function K(t, n, r) { var e = n(t); return uu(t) ? e : u(e, r(t)); }
function Q(t) { return null == t ? t === In ? cr : Zn : ke && ke in Object(t) ? Lt(t) : Jt(t); }
function X(t, n) { return null != t && ye.call(t, n); }
function Y(t, n) {
return null != t && n in Object(t);
}
function Z(t) { return pn(t) && Q(t) == Vn; }
function tt(t) { return pn(t) && tu(t) == Xn; }
function nt(t) { return !(!hn(t) || Wt(t)) && (ln(t) ? ge : xr).test(Zt(t)); }
function rt(t) { return pn(t) && tu(t) == ur; }
function et(t) { return pn(t) && sn(t.length) && !!Kr[Q(t)]; }
function ut(t) { if (!qt(t))
return $e(t); var n = []; for (var r in Object(t))
ye.call(t, r) && "constructor" != r && n.push(r); return n; }
function ot(t) { if (!hn(t))
return Ht(t); var n = qt(t), r = []; for (var e in t)
("constructor" != e || !n && ye.call(t, e)) && r.push(e); return r; }
function it(t, n, r, e, u) {
t !== n && Qe(n, function (o, i) { if (hn(o))
u || (u = new F), ct(t, n, i, r, it, e, u);
else {
var c = e ? e(s(t, i), o, i + "", t, n, u) : In;
c === In && (c = o), R(t, i, c);
} }, mn);
}
function ct(t, n, r, e, u, o, i) {
var c = s(t, r), a = s(n, r), f = i.get(a);
if (f)
return R(t, r, f), In;
var l = o ? o(c, a, r + "", t, n, i) : In, h = l === In;
if (h) {
var p = uu(a), y = !p && ou(a), v = !p && !y && au(a);
l = a, p || y || v ? uu(c) ? l = c : fn(c) ? l = Ot(c) : y ? (h = false, l = bt(a, true)) : v ? (h = false, l = wt(a, true)) : l = [] : yn(a) || eu(a) ? (l = c, eu(c) ? l = _n(c) : (!hn(c) || e && ln(c)) && (l = Ut(a))) : h = false;
}
h && (i.set(a, l), u(l, a, e, o, i), i.delete(a)), R(t, r, l);
}
function at(t, n) { return ft(t, n, function (n, r) { return wn(t, r); }); }
function ft(t, n, r) { for (var e = -1, u = n.length, o = {}; ++e < u;) {
var i = n[e], c = J(t, i);
r(c, i) && st(o, vt(i, t), c);
} return o; }
function lt(t, n) { return nu(Kt(t, n, Sn), t + ""); }
function st(t, n, r, e) { if (!hn(t))
return t; n = vt(n, t); for (var u = -1, o = n.length, i = o - 1, c = t; null != c && ++u < o;) {
var a = Yt(n[u]), f = r;
if (u != i) {
var l = c[a];
f = e ? e(l, a, c) : In, f === In && (f = hn(l) ? l : Rt(n[u + 1]) ? [] : {});
}
D(c, a, f), c = c[a];
} return t; }
function ht(t, n, r) {
var e = -1, u = t.length;
n < 0 && (n = -n > u ? 0 : u + n), r = r > u ? u : r,
r < 0 && (r += u), u = n > r ? 0 : r - n >>> 0, n >>>= 0;
for (var o = Array(u); ++e < u;)
o[e] = t[e + n];
return o;
}
function pt(t) { if (typeof t == "string")
return t; if (uu(t))
return e(t, pt) + ""; if (bn(t))
return Je ? Je.call(t) : ""; var n = t + ""; return "0" == n && 1 / t == -Dn ? "-0" : n; }
function yt(t, n) { return n = vt(n, t), t = Qt(t, n), null == t || delete t[Yt(nn(n))]; }
function vt(t, n) { return uu(t) ? t : Nt(t, n) ? [t] : ru(gn(t)); }
function bt(t, n) { if (n)
return t.slice(); var r = t.length, e = Oe ? Oe(r) : new t.constructor(r); return t.copy(e), e; }
function _t(t) {
var n = new t.constructor(t.byteLength);
return new we(n).set(new we(t)), n;
}
function gt(t, n) { return new t.constructor(n ? _t(t.buffer) : t.buffer, t.byteOffset, t.byteLength); }
function dt(t) { var n = new t.constructor(t.source, zr.exec(t)); return n.lastIndex = t.lastIndex, n; }
function jt(t) { return He ? Object(He.call(t)) : {}; }
function wt(t, n) { return new t.constructor(n ? _t(t.buffer) : t.buffer, t.byteOffset, t.length); }
function Ot(t, n) { var r = -1, e = t.length; for (n || (n = Array(e)); ++r < e;)
n[r] = t[r]; return n; }
function mt(t, n, r, e) {
var u = !r;
r || (r = {});
for (var o = -1, i = n.length; ++o < i;) {
var c = n[o], a = e ? e(r[c], t[c], c, r, t) : In;
a === In && (a = t[c]), u ? q(r, c, a) : D(r, c, a);
}
return r;
}
function At(t, n) { return mt(t, Ye(t), n); }
function zt(t, n) { return mt(t, Ze(t), n); }
function xt(t) { return lt(function (n, r) { var e = -1, u = r.length, o = u > 1 ? r[u - 1] : In, i = u > 2 ? r[2] : In; for (o = t.length > 3 && typeof o == "function" ? (u--, o) : In, i && Dt(r[0], r[1], i) && (o = u < 3 ? In : o, u = 1), n = Object(n); ++e < u;) {
var c = r[e];
c && t(n, c, e, o);
} return n; }); }
function St(t) {
return function (n, r, e) {
for (var u = -1, o = Object(n), i = e(n), c = i.length; c--;) {
var a = i[t ? c : ++u];
if (r(o[a], a, o) === false)
break;
}
return n;
};
}
function kt(t) { return yn(t) ? In : t; }
function Et(t) { return nu(Kt(t, In, tn), t + ""); }
function It(t) { return K(t, On, Ye); }
function Pt(t) { return K(t, mn, Ze); }
function $t(t, n) { var r = t.__data__; return Vt(n) ? r[typeof n == "string" ? "string" : "hash"] : r.map; }
function Ft(t, n) { var r = a(t, n); return nt(r) ? r : In; }
function Lt(t) { var n = ye.call(t, ke), r = t[ke]; try {
t[ke] = In;
var e = true;
}
catch (t) { } var u = be.call(t); return e && (n ? t[ke] = r : delete t[ke]), u; }
function Mt(t, n, r) {
n = vt(n, t);
for (var e = -1, u = n.length, o = false; ++e < u;) {
var i = Yt(n[e]);
if (!(o = null != t && r(t, i)))
break;
t = t[i];
}
return o || ++e != u ? o : (u = null == t ? 0 : t.length, !!u && sn(u) && Rt(i, u) && (uu(t) || eu(t)));
}
function Tt(t) { var n = t.length, r = new t.constructor(n); return n && "string" == typeof t[0] && ye.call(t, "index") && (r.index = t.index, r.input = t.input), r; }
function Ut(t) { return typeof t.constructor != "function" || qt(t) ? {} : Ke(me(t)); }
function Bt(t, n, r) {
var e = t.constructor;
switch (n) {
case fr: return _t(t);
case Gn:
case Hn: return new e(+t);
case lr: return gt(t, r);
case sr:
case hr:
case pr:
case yr:
case vr:
case br:
case _r:
case gr:
case dr: return wt(t, r);
case Xn: return new e;
case Yn:
case or: return new e(t);
case er: return dt(t);
case ur: return new e;
case ir: return jt(t);
}
}
function Ct(t) { return uu(t) || eu(t) || !!(Se && t && t[Se]); }
function Rt(t, n) { var r = typeof t; return n = null == n ? Nn : n, !!n && ("number" == r || "symbol" != r && Sr.test(t)) && t > -1 && t % 1 == 0 && t < n; }
function Dt(t, n, r) { if (!hn(r))
return false; var e = typeof n; return !!("number" == e ? an(r) && Rt(n, r.length) : "string" == e && n in r) && cn(r[n], t); }
function Nt(t, n) {
if (uu(t))
return false;
var r = typeof t;
return !("number" != r && "symbol" != r && "boolean" != r && null != t && !bn(t)) || (wr.test(t) || !jr.test(t) || null != n && t in Object(n));
}
function Vt(t) { var n = typeof t; return "string" == n || "number" == n || "symbol" == n || "boolean" == n ? "__proto__" !== t : null === t; }
function Wt(t) { return !!ve && ve in t; }
function qt(t) { var n = t && t.constructor; return t === (typeof n == "function" && n.prototype || se); }
function Gt(t) { var n = en(t, function (t) { return r.size === Mn && r.clear(), t; }), r = n.cache; return n; }
function Ht(t) {
var n = [];
if (null != t)
for (var r in Object(t))
n.push(r);
return n;
}
function Jt(t) { return be.call(t); }
function Kt(n, r, e) { return r = Fe(r === In ? n.length - 1 : r, 0), function () { for (var u = arguments, o = -1, i = Fe(u.length - r, 0), c = Array(i); ++o < i;)
c[o] = u[r + o]; o = -1; for (var a = Array(r + 1); ++o < r;)
a[o] = u[o]; return a[r] = e(c), t(n, this, a); }; }
function Qt(t, n) { return n.length < 2 ? t : J(t, ht(n, 0, -1)); }
function Xt(t) { var n = 0, r = 0; return function () { var e = Le(), u = Rn - (e - r); if (r = e, u > 0) {
if (++n >= Cn)
return arguments[0];
}
else
n = 0; return t.apply(In, arguments); }; }
function Yt(t) {
if (typeof t == "string" || bn(t))
return t;
var n = t + "";
return "0" == n && 1 / t == -Dn ? "-0" : n;
}
function Zt(t) { if (null != t) {
try {
return pe.call(t);
}
catch (t) { }
try {
return t + "";
}
catch (t) { }
} return ""; }
function tn(t) { return (null == t ? 0 : t.length) ? H(t, 1) : []; }
function nn(t) { var n = null == t ? 0 : t.length; return n ? t[n - 1] : In; }
function rn(t) { if (null == t)
return 0; if (an(t))
return vn(t) ? h(t) : t.length; var n = tu(t); return n == Xn || n == ur ? t.size : ut(t).length; }
function en(t, n) {
if (typeof t != "function" || null != n && typeof n != "function")
throw new TypeError(Fn);
var r = function () {
var e = arguments, u = n ? n.apply(this, e) : e[0], o = r.cache;
if (o.has(u))
return o.get(u);
var i = t.apply(this, e);
return r.cache = o.set(u, i) || o, i;
};
return r.cache = new (en.Cache || S), r;
}
function un(t) { return G(t, Bn); }
function on(t) { return G(t, Tn | Bn); }
function cn(t, n) { return t === n || t !== t && n !== n; }
function an(t) { return null != t && sn(t.length) && !ln(t); }
function fn(t) { return pn(t) && an(t); }
function ln(t) { if (!hn(t))
return false; var n = Q(t); return n == Kn || n == Qn || n == qn || n == rr; }
function sn(t) { return typeof t == "number" && t > -1 && t % 1 == 0 && t <= Nn; }
function hn(t) {
var n = typeof t;
return null != t && ("object" == n || "function" == n);
}
function pn(t) { return null != t && typeof t == "object"; }
function yn(t) { if (!pn(t) || Q(t) != tr)
return false; var n = me(t); if (null === n)
return true; var r = ye.call(n, "constructor") && n.constructor; return typeof r == "function" && r instanceof r && pe.call(r) == _e; }
function vn(t) { return typeof t == "string" || !uu(t) && pn(t) && Q(t) == or; }
function bn(t) { return typeof t == "symbol" || pn(t) && Q(t) == ir; }
function _n(t) { return mt(t, mn(t)); }
function gn(t) { return null == t ? "" : pt(t); }
function dn(t, n, r) { var e = null == t ? In : J(t, n); return e === In ? r : e; }
function jn(t, n) {
return null != t && Mt(t, n, X);
}
function wn(t, n) { return null != t && Mt(t, n, Y); }
function On(t) { return an(t) ? C(t) : ut(t); }
function mn(t) { return an(t) ? C(t, true) : ot(t); }
function An(t, n, r) { return null == t ? t : st(t, n, r); }
function zn(t, n) { return null == t || yt(t, n); }
function xn(t) { return function () { return t; }; }
function Sn(t) { return t; }
function kn() { return []; }
function En() { return false; }
var In, Pn = "4.17.5", $n = 200, Fn = "Expected a function", Ln = "__lodash_hash_undefined__", Mn = 500, Tn = 1, Un = 2, Bn = 4, Cn = 800, Rn = 16, Dn = 1 / 0, Nn = 9007199254740991, Vn = "[object Arguments]", Wn = "[object Array]", qn = "[object AsyncFunction]", Gn = "[object Boolean]", Hn = "[object Date]", Jn = "[object Error]", Kn = "[object Function]", Qn = "[object GeneratorFunction]", Xn = "[object Map]", Yn = "[object Number]", Zn = "[object Null]", tr = "[object Object]", nr = "[object Promise]", rr = "[object Proxy]", er = "[object RegExp]", ur = "[object Set]", or = "[object String]", ir = "[object Symbol]", cr = "[object Undefined]", ar = "[object WeakMap]", fr = "[object ArrayBuffer]", lr = "[object DataView]", sr = "[object Float32Array]", hr = "[object Float64Array]", pr = "[object Int8Array]", yr = "[object Int16Array]", vr = "[object Int32Array]", br = "[object Uint8Array]", _r = "[object Uint8ClampedArray]", gr = "[object Uint16Array]", dr = "[object Uint32Array]", jr = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, wr = /^\w*$/, Or = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, mr = /[\\^$.*+?()[\]{}|]/g, Ar = /\\(\\)?/g, zr = /\w*$/, xr = /^\[object .+?Constructor\]$/, Sr = /^(?:0|[1-9]\d*)$/, kr = "\\ud800-\\udfff", Er = "\\u0300-\\u036f", Ir = "\\ufe20-\\ufe2f", Pr = "\\u20d0-\\u20ff", $r = Er + Ir + Pr, Fr = "\\ufe0e\\ufe0f", Lr = "[" + kr + "]", Mr = "[" + $r + "]", Tr = "\\ud83c[\\udffb-\\udfff]", Ur = "(?:" + Mr + "|" + Tr + ")", Br = "[^" + kr + "]", Cr = "(?:\\ud83c[\\udde6-\\uddff]){2}", Rr = "[\\ud800-\\udbff][\\udc00-\\udfff]", Dr = "\\u200d", Nr = Ur + "?", Vr = "[" + Fr + "]?", Wr = "(?:" + Dr + "(?:" + [Br, Cr, Rr].join("|") + ")" + Vr + Nr + ")*", qr = Vr + Nr + Wr, Gr = "(?:" + [Br + Mr + "?", Mr, Cr, Rr, Lr].join("|") + ")", Hr = RegExp(Tr + "(?=" + Tr + ")|" + Gr + qr, "g"), Jr = RegExp("[" + Dr + kr + $r + Fr + "]"), Kr = {};
Kr[sr] = Kr[hr] = Kr[pr] = Kr[yr] = Kr[vr] = Kr[br] = Kr[_r] = Kr[gr] = Kr[dr] = true, Kr[Vn] = Kr[Wn] = Kr[fr] = Kr[Gn] = Kr[lr] = Kr[Hn] = Kr[Jn] = Kr[Kn] = Kr[Xn] = Kr[Yn] = Kr[tr] = Kr[er] = Kr[ur] = Kr[or] = Kr[ar] = false;
var Qr = {};
Qr[Vn] = Qr[Wn] = Qr[fr] = Qr[lr] = Qr[Gn] = Qr[Hn] = Qr[sr] = Qr[hr] = Qr[pr] = Qr[yr] = Qr[vr] = Qr[Xn] = Qr[Yn] = Qr[tr] = Qr[er] = Qr[ur] = Qr[or] = Qr[ir] = Qr[br] = Qr[_r] = Qr[gr] = Qr[dr] = true, Qr[Jn] = Qr[Kn] = Qr[ar] = false;
var Xr = typeof global == "object" && global && global.Object === Object && global, Yr = typeof self == "object" && self && self.Object === Object && self, Zr = Xr || Yr || Function("return this")(), te = typeof exports == "object" && exports && !exports.nodeType && exports, ne = te && typeof module == "object" && module && !module.nodeType && module, re = ne && ne.exports === te, ee = re && Xr.process, ue = function () {
try {
return ee && ee.binding && ee.binding("util");
}
catch (t) { }
}(), oe = ue && ue.isMap, ie = ue && ue.isSet, ce = ue && ue.isTypedArray, ae = o("length"), fe = Array.prototype, le = Function.prototype, se = Object.prototype, he = Zr["__core-js_shared__"], pe = le.toString, ye = se.hasOwnProperty, ve = function () { var t = /[^.]+$/.exec(he && he.keys && he.keys.IE_PROTO || ""); return t ? "Symbol(src)_1." + t : ""; }(), be = se.toString, _e = pe.call(Object), ge = RegExp("^" + pe.call(ye).replace(mr, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"), de = re ? Zr.Buffer : In, je = Zr.Symbol, we = Zr.Uint8Array, Oe = de ? de.allocUnsafe : In, me = l(Object.getPrototypeOf, Object), Ae = Object.create, ze = se.propertyIsEnumerable, xe = fe.splice, Se = je ? je.isConcatSpreadable : In, ke = je ? je.toStringTag : In, Ee = function () {
try {
var t = Ft(Object, "defineProperty");
return t({}, "", {}), t;
}
catch (t) { }
}(), Ie = Object.getOwnPropertySymbols, Pe = de ? de.isBuffer : In, $e = l(Object.keys, Object), Fe = Math.max, Le = Date.now, Me = Ft(Zr, "DataView"), Te = Ft(Zr, "Map"), Ue = Ft(Zr, "Promise"), Be = Ft(Zr, "Set"), Ce = Ft(Zr, "WeakMap"), Re = Ft(Object, "create"), De = Zt(Me), Ne = Zt(Te), Ve = Zt(Ue), We = Zt(Be), qe = Zt(Ce), Ge = je ? je.prototype : In, He = Ge ? Ge.valueOf : In, Je = Ge ? Ge.toString : In, Ke = function () {
function t() { }
return function (n) {
if (!hn(n))
return {};
if (Ae)
return Ae(n);
t.prototype = n;
var r = new t;
return t.prototype = In, r;
};
}();
v.prototype.clear = b, v.prototype.delete = _, v.prototype.get = g, v.prototype.has = d, v.prototype.set = j, w.prototype.clear = O, w.prototype.delete = m, w.prototype.get = A, w.prototype.has = z, w.prototype.set = x, S.prototype.clear = k, S.prototype.delete = E, S.prototype.get = I, S.prototype.has = P, S.prototype.set = $, F.prototype.clear = L, F.prototype.delete = M, F.prototype.get = T, F.prototype.has = U, F.prototype.set = B;
var Qe = St(), Xe = Ee ? function (t, n) {
return Ee(t, "toString", { configurable: true, enumerable: false,
value: xn(n), writable: true });
} : Sn, Ye = Ie ? function (t) { return null == t ? [] : (t = Object(t), r(Ie(t), function (n) { return ze.call(t, n); })); } : kn, Ze = Ie ? function (t) { for (var n = []; t;)
u(n, Ye(t)), t = me(t); return n; } : kn, tu = Q;
(Me && tu(new Me(new ArrayBuffer(1))) != lr || Te && tu(new Te) != Xn || Ue && tu(Ue.resolve()) != nr || Be && tu(new Be) != ur || Ce && tu(new Ce) != ar) && (tu = function (t) {
var n = Q(t), r = n == tr ? t.constructor : In, e = r ? Zt(r) : "";
if (e)
switch (e) {
case De: return lr;
case Ne: return Xn;
case Ve: return nr;
case We: return ur;
case qe: return ar;
}
return n;
});
var nu = Xt(Xe), ru = Gt(function (t) { var n = []; return 46 === t.charCodeAt(0) && n.push(""), t.replace(Or, function (t, r, e, u) { n.push(e ? u.replace(Ar, "$1") : r || t); }), n; });
en.Cache = S;
var eu = Z(function () { return arguments; }()) ? Z : function (t) { return pn(t) && ye.call(t, "callee") && !ze.call(t, "callee"); }, uu = Array.isArray, ou = Pe || En, iu = oe ? c(oe) : tt, cu = ie ? c(ie) : rt, au = ce ? c(ce) : et, fu = xt(function (t, n, r) { it(t, n, r); }), lu = xt(function (t, n, r, e) { it(t, n, r, e); }), su = Et(function (t, n) {
var r = {};
if (null == t)
return r;
var u = false;
n = e(n, function (n) {
return n = vt(n, t),
u || (u = n.length > 1), n;
}), mt(t, Pt(t), r), u && (r = G(r, Tn | Un | Bn, kt));
for (var o = n.length; o--;)
yt(r, n[o]);
return r;
}), hu = Et(function (t, n) { return null == t ? {} : at(t, n); });
y.constant = xn, y.flatten = tn, y.keys = On, y.keysIn = mn, y.memoize = en, y.merge = fu, y.mergeWith = lu, y.omit = su, y.pick = hu, y.set = An, y.toPlainObject = _n, y.unset = zn, y.clone = un, y.cloneDeep = on, y.eq = cn, y.get = dn, y.has = jn, y.hasIn = wn, y.identity = Sn, y.isArguments = eu, y.isArray = uu, y.isArrayLike = an, y.isArrayLikeObject = fn, y.isBuffer = ou, y.isFunction = ln, y.isLength = sn, y.isMap = iu,
y.isObject = hn, y.isObjectLike = pn, y.isPlainObject = yn, y.isSet = cu, y.isString = vn, y.isSymbol = bn, y.isTypedArray = au, y.last = nn, y.stubArray = kn, y.stubFalse = En, y.size = rn, y.toString = gn, y.VERSION = Pn, ne && ((ne.exports = y)._ = y, te._ = y);
}).call(this);
/**
* Copied directly from https://github.com/nuxt-contrib/destr/blob/master/src/index.ts but
* instead raises the malformed JSON exceptions over swallowing them
* instead raises the malformed JSON exceptions vs swallowing them
*/
export declare function safeParse(val: string, reviver?: (this: any, key: string, value: any) => any): any;
export declare function safeParse(val: string, reviver?: (this: any, jsonKey: string, jsonValue: any) => any): any;

@@ -25,3 +25,3 @@ "use strict";

* Copied directly from https://github.com/nuxt-contrib/destr/blob/master/src/index.ts but
* instead raises the malformed JSON exceptions over swallowing them
* instead raises the malformed JSON exceptions vs swallowing them
*/

@@ -28,0 +28,0 @@ function safeParse(val, reviver) {

{
"name": "@poppinss/utils",
"version": "2.5.10",
"version": "3.0.0",
"description": "Handy utilities for repetitive work",

@@ -9,3 +9,5 @@ "main": "build/index.js",

"build/index.d.ts",
"build/index.js"
"build/index.js",
"build/helpers.d.ts",
"build/helpers.js"
],

@@ -17,5 +19,5 @@ "scripts": {

"clean": "del build",
"compile": "npm run lint && npm run clean && tsc",
"build:lodash": "lodash exports=node include=pick,omit,get,set,unset,mergeWith,merge,snakeCase,camelCase,startCase -o build/src/lodash/index.js --production",
"build": "npm run compile && npm run build:lodash",
"compile": "npm run lint && npm run clean && npm run build:lodash && tsc",
"build:lodash": "lodash exports=node include=pick,omit,get,set,unset,mergeWith,merge,has,size,clone,cloneDeep -o src/lodash/index.js --production",
"build": "npm run compile",
"commit": "git-cz",

@@ -35,7 +37,10 @@ "release": "np",

"devDependencies": {
"@adonisjs/mrm-preset": "^2.4.0",
"@adonisjs/require-ts": "^1.1.1",
"@poppinss/dev-utils": "^1.0.11",
"@adonisjs/mrm-preset": "^3.0.0",
"@adonisjs/require-ts": "^2.0.0",
"@poppinss/dev-utils": "^1.1.0",
"@types/fs-readdir-recursive": "^1.0.0",
"@types/ms": "^0.7.31",
"@types/node": "^14.14.22",
"@types/node": "^14.14.25",
"@types/pluralize": "0.0.29",
"@types/require-all": "^3.0.1",
"commitizen": "^4.2.3",

@@ -45,5 +50,5 @@ "cz-conventional-changelog": "^3.3.0",

"doctoc": "^2.0.0",
"eslint": "^7.18.0",
"eslint": "^7.19.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-adonis": "^1.0.15",
"eslint-plugin-adonis": "^1.2.0",
"eslint-plugin-prettier": "^3.3.1",

@@ -54,5 +59,4 @@ "github-label-sync": "^2.0.0",

"lodash-cli": "^4.17.5",
"mrm": "^2.5.13",
"mrm": "^2.5.15",
"np": "^7.2.0",
"npm-audit-html": "^1.5.0",
"prettier": "^2.2.1",

@@ -71,3 +75,3 @@ "typescript": "^4.1.3"

"hooks": {
"pre-commit": "doctoc README.md --title='## Table of contents' && git add README.md && npm audit --production --json | ./node_modules/.bin/npm-audit-html && git add npm-audit.html",
"pre-commit": "doctoc README.md --title='## Table of contents' && git add README.md",
"commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js"

@@ -86,9 +90,18 @@ }

"dependencies": {
"@types/bytes": "^3.1.0",
"@types/he": "^1.1.1",
"buffer-alloc": "^1.2.0",
"bytes": "^3.1.0",
"change-case": "^4.1.2",
"cuid": "^2.1.8",
"fast-safe-stringify": "^2.0.7",
"fs-readdir-recursive": "^1.1.0",
"klona": "^2.0.4",
"he": "^1.2.0",
"kind-of": "^6.0.3",
"ms": "^2.1.3",
"pluralize": "^8.0.0",
"require-all": "^3.0.0",
"resolve-from": "^5.0.0"
"resolve-from": "^5.0.0",
"slugify": "^1.4.6",
"truncatise": "0.0.8"
},

@@ -95,0 +108,0 @@ "directories": {

@@ -7,6 +7,98 @@ <div align="center"><img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1557762307/poppinss_iftxlt.jpg" width="600px"></div>

[![circleci-image]][circleci-url] [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url] [![audit-report-image]][audit-report-url]
[![circleci-image]][circleci-url] [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url] [![synk-image]][synk-url]
This module exports a collection of re-usable utilties to avoid re-writing the same code in every other package. We also include a handful of Lodash utilities, which are used across the AdonisJS packages eco-system.
<details>
<summary>
<strong>Version 3.0 breaking changes</strong>
</summary>
The version 3.0 re-format the exports to expose an "helpers" subpath to be used within the AdonisJS apps as well.
The idea is to separate helpers that we need to share with AdonisJS core inside its own module, accessible as `‌@poppinss/utils/build/helpers`.
### Inside helpers subpath
Following modules are now moved to a subpath.
- `MessageBuilder`
- `base64`
- `compose`
- `fsReadAll`
- `interpolate`
- `requireAll`
- `resolveDir`
- `resolveFrom`
```ts
// Earlier
import {
MessageBuilder,
base64,
compose,
fsReadAll,
interpolate,
requireAll,
resolveDir,
resolveFrom,
safeEqual
} from '@poppinss/utils'
// After version 3.0
import {
MessageBuilder,
base64,
compose,
fsReadAll,
interpolate,
requireAll,
resolveDir,
resolveFrom,
safeEqual
} from '@poppinss/utils/build/helpers'
````
### randomString
The `randomString` is now part of the `string` helpers.
```ts
// Earlier
import { randomString } from '@poppinss/utils'
randomString(32)
// After version 3.0
import { string } from '@poppinss/utils/build/helpers'
string.generateRandom(32)
````
### lodash
The following lodash functions have been removed with new alternatives.
- `snakeCase`
- `camelCase`
- `startCase`
```ts
// Earlier
import { lodash } from '@poppinss/utils'
lodash.snakeCase()
lodash.camelCase()
lodash.startCase()
// After version 3.0
import { string } from '@poppinss/utils/build/helpers'
string.snakeCase()
string.camelCase()
string.titleCase()
```
</details>
<!-- START doctoc generated TOC please keep comment here to allow auto update -->

@@ -18,12 +110,16 @@ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Exception](#exception)
- [fsReadAll](#fsreadall)
- [requireAll](#requireall)
- [esmRequire](#esmrequire)
- [esmResolver](#esmresolver)
- [resolveFrom](#resolvefrom)
- [resolveDir](#resolvedir)
- [interpolate](#interpolate)
- [Lodash utilities](#lodash-utilities)
- [Exported methods](#exported-methods)
- [Base 64 Encode/Decode](#base-64-encodedecode)
- [Safe stringify](#safe-stringify)
- [Safe parse](#safe-parse)
- [defineStaticProperty](#definestaticproperty)
- [Helpers](#helpers)
- [fsReadAll](#fsreadall)
- [requireAll](#requireall)
- [resolveFrom](#resolvefrom)
- [resolveDir](#resolvedir)
- [interpolate](#interpolate)
- [Base 64 Encode/Decode](#base-64-encodedecode)
- [encode](#encode)

@@ -33,10 +129,49 @@ - [decode](#decode)

- [urlDecode](#urldecode)
- [Random String](#random-string)
- [Safe equal](#safe-equal)
- [Safe stringify](#safe-stringify)
- [Safe parse](#safe-parse)
- [Message Builder](#message-builder)
- [defineStaticProperty](#definestaticproperty)
- [compose](#compose)
- [Mixins gotchas](#mixins-gotchas)
- [Safe equal](#safe-equal)
- [Message Builder](#message-builder)
- [compose](#compose)
- [Mixins gotchas](#mixins-gotchas)
- [string](#string)
- [camelCase](#camelcase)
- [snakeCase](#snakecase)
- [dashCase](#dashcase)
- [pascalCase](#pascalcase)
- [capitalCase](#capitalcase)
- [sentenceCase](#sentencecase)
- [dotCase](#dotcase)
- [noCase](#nocase)
- [titleCase](#titlecase)
- [pluralize](#pluralize)
- [truncate](#truncate)
- [excerpt](#excerpt)
- [condenseWhitespace](#condensewhitespace)
- [escapeHTML](#escapehtml)
- [encodeSymbols](#encodesymbols)
- [toSentence](#tosentence)
- [prettyBytes](#prettybytes)
- [toBytes](#tobytes)
- [prettyMs](#prettyms)
- [toMs](#toms)
- [ordinalize](#ordinalize)
- [generateRandom](#generaterandom)
- [isEmpty](#isempty)
- [Types](#types)
- [lookup](#lookup)
- [isNull](#isnull)
- [isBoolean](#isboolean)
- [isBuffer](#isbuffer)
- [isNumber](#isnumber)
- [isString](#isstring)
- [isArguments](#isarguments)
- [isObject](#isobject)
- [isDate](#isdate)
- [isArray](#isarray)
- [isRegexp](#isregexp)
- [isError](#iserror)
- [isFunction](#isfunction)
- [isClass](#isclass)
- [isInteger](#isinteger)
- [isFloat](#isfloat)
- [isDecimal](#isdecimal)
- [ObjectBuilder](#objectbuilder)

@@ -74,35 +209,2 @@ <!-- END doctoc generated TOC please keep comment here to allow auto update -->

## fsReadAll
A utility to recursively read all script files for a given directory. This method is equivalent to
`readdir + recursive + filter (.js, .json, .ts)`.
```ts
import { fsReadAll } from '@poppinss/utils'
const files = fsReadAll(__dirname) // array of strings
```
You can also define your custom filter function. The filter function must return `true` for files to be included.
```ts
const files = fsReadAll(__dirname, (file) => {
return file.endsWith('.foo.js')
})
```
## requireAll
Same as `fsReadAll`, but instead require the files. Helpful when you want to load all the config files inside a directory on app boot.
```ts
import { requireAll } from '@poppinss/utils'
const config = requireAll(join(__dirname, 'config'))
{
file1: {}, // exported object
file2: {} // exported object
}
```
## esmRequire

@@ -168,65 +270,13 @@

## resolveFrom
Works similar to `require.resolve`, however it handles the absolute paths properly.
```ts
import { resolveFrom } from '@poppinss/utils'
resolveFrom(__dirname, 'npm-package') // returns path to package "main" file
resolveFrom(__dirname, './foo.js') // returns path to `foo.js` (if exists)
resolveFrom(__dirname, join(__dirname, './foo.js')) // returns path to `foo.js` (if exists)
```
## resolveDir
The `require.resolve` or `resolveFrom` method can only resolve paths to a given file and not the directory. For example: If you pass path to a directory, then it will search for `index.js` inside it and in case of a package, it will be search for `main` entry point.
On the other hand, the `resolveDir` method can also resolve path to directories using following resolution.
- Absolute paths are returned as it is.
- Relative paths starting with `./` or `.\` are resolved using `path.join`.
- Path to packages inside `node_modules` are resolved as follows: - Uses `require.resolve` to resolve the `package.json` file. - Then replace the `package-name` with the absolute resolved package path.
```ts
import { resolveDir } from '@poppinss/utils'
resolveDir(__dirname, './database/migrations')
// __dirname + /database/migrations
resolveDir(__dirname, 'some-package/database/migrations')
// {path-to-package}/database/migrations
resolveDir(__dirname, '@some/package/database/migrations')
// {path-to-package}/database/migrations
```
## interpolate
A small utility function to interpolate values inside a string.
```
import { interpolate } from '@poppinss/utils'
interpolate('hello {{ username }}', { username: 'virk' })
interpolate('hello {{ users.0.username }}', { users: [{ username: 'virk' }] })
```
If value is missing, it will be replaced with an `undefined` string.
## Lodash utilities
Lodash itself is a bulky library and most of the times, we don't need all the functions from it. For this purpose, the lodash team decided to publish individual methods to npm as packages. However, most of those individual packages are outdated.
Lodash itself is a bulky library and most of the times, we don't need all the functions from it.
At this point, whether we should use the complete lodash build or use outdated individual packages. Both are not acceptable.
Also, all of the lodash functions are published as individual modules on npm. However, most of those individual packages are outdated and using them is not an option.
Instead, we make use of `lodash-cli` to create a custom build of all the utilities we ever need inside the AdonisJS eco-system and export it as part of this package. Why part of this package?
Instead, we decided to use the `lodash-cli` to create a custom build for all the utilities we need inside AdonisJS ecosystem and export it as part of this package.
Well, creating custom builds in multiple packages will cause friction, so it's better to keep it at a single place.
> **Do note: There are no Typescript types for the lodash methods, since their CLI doesn't generate one and the one published on `@types/lodash` package are again maintained by community and not the lodash core team, so at times, they can also be outdated.**
```ts
import { lodash } from '@poppinss/utils'
lodash.snakeCase('HelloWorld') // hello_world
lodash.get({ name: 'virk' }, 'name') // virk
```

@@ -241,2 +291,4 @@

- [get](https://lodash.com/docs/latest#get)
- [has](https://lodash.com/docs/latest#has)
- [size](https://lodash.com/docs/latest#size)
- [set](https://lodash.com/docs/latest#set)

@@ -246,54 +298,5 @@ - [unset](https://lodash.com/docs/latest#unset)

- [merge](https://lodash.com/docs/latest#merge)
- [snakeCase](https://lodash.com/docs/latest#snakeCase)
- [camelCase](https://lodash.com/docs/latest#camelCase)
- [startCase](https://lodash.com/docs/latest#startCase)
- [clone](https://lodash.com/docs/latest#clone)
- [cloneDeep](https://lodash.com/docs/latest#cloneDeep)
## Base 64 Encode/Decode
Following helpers for base64 encoding/decoding also exists.
#### encode
```ts
import { base64 } from '@poppinss/utils'
base64.encode('hello world')
base64.encode(Buffer.from('hello world', 'binary'))
```
#### decode
```ts
import { base64 } from '@poppinss/utils'
base64.decode(base64.encode('hello world'))
base64.decode(base64.encode(Buffer.from('hello world', 'binary')), 'binary')
```
#### urlEncode
Same as `encode`, but safe for URLS and Filenames
#### urlDecode
Same as `decode`, but decodes the `urlEncode` output values
## Random String
A helper to generate random strings of a given length. Uses `crypto` under the hood.
```ts
import { randomString } from '@poppinss/utils'
randomString(32)
randomString(128)
```
## Safe equal
Compares two values by avoid [timing attack](https://en.wikipedia.org/wiki/Timing_attack). Accepts any input that can be passed to `Buffer.from`
```ts
import { safeValue } from '@poppinss/utils'
if (safeValue('foo', 'foo')) {
}
```
## Safe stringify

@@ -332,25 +335,2 @@

## Message Builder
Message builder provides a sane API for stringifying objects similar to `JSON.stringify` but has a few advantages.
- It is safe from JSON poisoning vulnerability.
- You can define expiry and purpose for the encoding. The `verify` method will respect these values.
The message builder alone may seem useless, since anyone can decode the object and change its expiry or purpose. However, you can generate an hash of the stringified object and verify for tampering by validating the hash. This is what AdonisJS does for cookies.
```ts
import { MessageBuilder } from '@poppinss/utils'
const builder = new MessageBuilder()
const encoded = builder.build({ username: 'virk' }, '1 hour', 'login')
```
Now verify it
```ts
builder.verify(encoded) // returns null, no purpose defined
builder.verify(encoded, 'register') // returns null, purpose mismatch.
builder.verify(encoded, 'login') // return { username: 'virk' }
```
## defineStaticProperty

@@ -410,4 +390,179 @@

## compose
## Helpers
The helpers module is also available in AdonisJS applications as follows:
```ts
import { fsReadAll, string, types } from '@ioc:Adonis/Core/Helpers'
```
The `@poppinss/utils` exposes this module as follows
```ts
import { fsReadAll, string, types } from '@poppinss/utils/build/helpers'
```
### fsReadAll
A utility to recursively read all script files for a given directory. This method is equivalent to
`readdir + recursive + filter (.js, .json, .ts)`.
```ts
import { fsReadAll } from '@poppinss/utils/build/helpers'
const files = fsReadAll(__dirname) // array of strings
```
You can also define your custom filter function. The filter function must return `true` for files to be included.
```ts
const files = fsReadAll(__dirname, (file) => {
return file.endsWith('.foo.js')
})
```
### requireAll
Same as `fsReadAll`, but instead require the files. Helpful when you want to load all the config files inside a directory on app boot.
```ts
import { requireAll } from '@poppinss/utils/build/helpers'
const config = requireAll(join(__dirname, 'config'))
{
file1: {}, // exported object
file2: {} // exported object
}
```
### resolveFrom
Works similar to `require.resolve`, however it handles the absolute paths properly.
```ts
import { resolveFrom } from '@poppinss/utils/build/helpers'
resolveFrom(__dirname, 'npm-package') // returns path to package "main" file
resolveFrom(__dirname, './foo.js') // returns path to `foo.js` (if exists)
resolveFrom(__dirname, join(__dirname, './foo.js')) // returns path to `foo.js` (if exists)
```
### resolveDir
The `require.resolve` or `resolveFrom` method can only resolve paths to a given file and not the directory. For example: If you pass path to a directory, then it will search for `index.js` inside it and in case of a package, it will be search for `main` entry point.
On the other hand, the `resolveDir` method can also resolve path to directories using following resolution.
- Absolute paths are returned as it is.
- Relative paths starting with `./` or `.\` are resolved using `path.join`.
- Path to packages inside `node_modules` are resolved as follows: - Uses `require.resolve` to resolve the `package.json` file. - Then replace the `package-name` with the absolute resolved package path.
```ts
import { resolveDir } from '@poppinss/utils/build/helpers'
resolveDir(__dirname, './database/migrations')
// __dirname + /database/migrations
resolveDir(__dirname, 'some-package/database/migrations')
// {path-to-package}/database/migrations
resolveDir(__dirname, '@some/package/database/migrations')
// {path-to-package}/database/migrations
```
### interpolate
A small utility function to interpolate values inside a string.
```ts
import { interpolate } from '@poppinss/utils/build/helpers'
interpolate('hello {{ username }}', {
username: 'virk'
})
interpolate('hello {{ users.0.username }}', {
users: [{ username: 'virk' }]
})
```
If value is missing, it will be replaced with an `'undefined'` string.
Use the `\` to escape a mustache block from getting evaluated.
```ts
import { interpolate } from '@poppinss/utils/build/helpers'
interpolate('\\{{ username }} expression evaluates to {{ username }}', {
username: 'virk'
})
// Output: {{ username }} expression evaluates to virk
```
### Base 64 Encode/Decode
Following helpers for base64 encoding/decoding also exists.
#### encode
```ts
import { base64 } from '@poppinss/utils/build/helpers'
base64.encode('hello world')
base64.encode(Buffer.from('hello world', 'binary'))
```
#### decode
```ts
import { base64 } from '@poppinss/utils/build/helpers'
base64.decode(base64.encode('hello world'))
base64.decode(base64.encode(Buffer.from('hello world', 'binary')), 'binary')
```
#### urlEncode
Same as `encode`, but safe for URLS and Filenames
#### urlDecode
Same as `decode`, but decodes the `urlEncode` output values
### Safe equal
Compares two values by avoid [timing attack](https://en.wikipedia.org/wiki/Timing_attack). Accepts any input that can be passed to `Buffer.from`
```ts
import { safeValue } from '@poppinss/utils/build/helpers'
if (safeValue('foo', 'foo')) {
}
```
### Message Builder
Message builder provides a sane API for stringifying objects similar to `JSON.stringify` but has a few advantages.
- It is safe from JSON poisoning vulnerability.
- You can define expiry and purpose for the encoding. The `verify` method will respect these values.
The message builder alone may seem useless, since anyone can decode the object and change its expiry or purpose. However, you can generate an hash of the stringified object and verify the tampering by validating the hash. This is what AdonisJS does for cookies.
```ts
import { MessageBuilder } from '@poppinss/utils/build/helpers'
const builder = new MessageBuilder()
const encoded = builder.build({ username: 'virk' }, '1 hour', 'login')
```
Now verify it
```ts
builder.verify(encoded) // returns null, no purpose defined
builder.verify(encoded, 'register') // returns null, purpose mismatch.
builder.verify(encoded, 'login') // return { username: 'virk' }
```
### compose
Javascript doesn't have a concept of inherting multiple classes together and neither does Typescript. However, the [official documentation](https://www.typescriptlang.org/docs/handbook/mixins.html) of Typescript does talks about the concept of mixins.

@@ -436,5 +591,5 @@

Mixins are close to perfect way of inherting multiple classes. I recommend reading [this article](https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/) for same.
Mixins are close to a perfect way of inherting multiple classes. I recommend reading [this article](https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/) for same.
However, the syntax of applying multiple mixins is kind of ugly, as you have apply mixins over mixins creating a nested hierarchy as shown below.
However, the syntax of applying multiple mixins is kind of ugly, as you have to apply **mixins over mixins**, creating a nested hierarchy as shown below.

@@ -448,3 +603,3 @@ ```ts

```ts
import { compose } from '@poppinss/utils'
import { compose } from '@poppinss/utils/build/helpers'

@@ -460,3 +615,3 @@ class User extends compose(

### Mixins gotchas
#### Mixins gotchas

@@ -485,3 +640,3 @@ Typescript has an [open issue](https://github.com/microsoft/TypeScript/issues/37142) related to the constructor arguments of the mixin class or the base class.

```ts
import { NormalizeConstructor, compose } from '@poppinss/utils'
import { NormalizeConstructor, compose } from '@poppinss/utils/build/helpers'

@@ -495,2 +650,561 @@ const UserWithEmail = <T extends NormalizeConstructor<typeof BaseModel>>(superclass: T) => {

### string
The `string` module includes a bunch of helper methods to work with strings.
#### camelCase
Convert a string to its `camelCase` version.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.camelCase('hello-world') // helloWorld
```
#### snakeCase
Convert a string to its `snake_case` version.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.snakeCase('helloWorld') // hello_world
```
#### dashCase
Convert a string to its `dash-case` version. Optionally, you can also capitalize the first letter of each segment.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.dashCase('helloWorld') // hello-world
string.dashCase('helloWorld', { capitalize: true }) // Hello-World
```
#### pascalCase
Convert a string to its `PascalCase` version.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.pascalCase('helloWorld') // HelloWorld
```
#### capitalCase
Capitalize a string
```ts
import { string } from '@poppinss/utils/build/helpers'
string.capitalCase('helloWorld') // Hello World
```
#### sentenceCase
Convert string to a sentence
```ts
import { string } from '@poppinss/utils/build/helpers'
string.sentenceCase('hello-world') // Hello world
```
#### dotCase
Convert string to its `dot.case` version.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.dotCase('hello-world') // hello.world
```
#### noCase
Remove all sorts of casing
```ts
import { string } from '@poppinss/utils/build/helpers'
string.noCase('hello-world') // hello world
string.noCase('hello_world') // hello world
string.noCase('helloWorld') // hello world
```
#### titleCase
Convert a sentence to title case
```ts
import { string } from '@poppinss/utils/build/helpers'
string.titleCase('Here is a fox') // Here Is a fox
```
#### pluralize
Pluralize a word.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.pluralize('box') // boxes
string.pluralize('i') // we
```
You can also define your own irregular rules using the `string.defineIrregularRule` method.
- The first argument is the singular variation
- The second argument is the plural variation
```ts
import { string } from '@poppinss/utils/build/helpers'
string.defineIrregularRule('auth', 'auth')
string.plural('auth') // auth
```
You can also define your own uncountable rules using the `string.defineUncountableRule` method.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.defineUncountableRule('login')
string.plural('login') // home
```
#### truncate
Truncate a string after a given number of characters
```ts
import { string } from '@poppinss/utils/build/helpers'
string.truncate(
'This is a very long, maybe not that long title',
12
) // This is a ve...
```
By default, the string is truncated exactly after the given characters. However, you can instruct the method to wait for the words to complete.
```ts
string.truncate(
'This is a very long, maybe not that long title',
12,
{
completeWords: true
}
) // This is a very...
```
Also, it is possible to customize the suffix.
```ts
string.truncate(
'This is a very long, maybe not that long title',
12,
{
completeWords: true,
suffix: ' <a href="/1"> Read more </a>',
}
) // This is a very <a href="/1"> Read more </a>
```
#### excerpt
The `excerpt` method is same as the `truncate` method. However, it strips the HTML from the string.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.excerpt(
'<p>This is a <strong>very long</strong>, maybe not that long title</p>',
12
) // This is a very...
```
#### condenseWhitespace
Condense whitespaces from a given string. The method removes the whitespace from the `left`, `right` and multiple whitespace in between the words.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.condenseWhitespace(' hello world ')
// hello world
```
#### escapeHTML
Escape HTML from the string
```ts
import { string } from '@poppinss/utils/build/helpers'
string.escapeHTML('<p> foo © bar </p>')
// &lt;p&gt; foo © bar &lt;/p&gt;
```
Additonally, you can also encode non-ascii symbols
```ts
import { string } from '@poppinss/utils/build/helpers'
string.escapeHTML(
'<p> foo © bar </p>',
{
encodeSymbols: true
}
)
// &lt;p&gt; foo &#xA9; bar &lt;/p&gt;
```
#### encodeSymbols
Encode symbols. Checkout [he](https://npm.im/he) for available options
```ts
import { string } from '@poppinss/utils/build/helpers'
string.encodeSymbols('foo © bar')
// foo &#xA9; bar
```
#### toSentence
Join an array of words with a separator.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.toSentence([
'route',
'middleware',
'controller'
]) // route, middleware, and controller
string.toSentence([
'route',
'middleware'
]) // route and middleware
```
You can also customize
- `separator`: The value between two words except the last one
- `pairSeparator`: The value between the first and the last word. Used, only when there are two words
- `lastSeparator`: The value between the second last and the last word. Used, only when there are more than two words
```ts
string.toSentence([
'route',
'middleware',
'controller'
], {
separator: '/ ',
lastSeparator: '/or '
}) // route/ middleware/or controller
```
#### prettyBytes
Convert bytes value to a human readable string. For options, recommend the [bytes](https://www.npmjs.com/package/bytes) package.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.prettyBytes(1024) // 1KB
string.prettyBytes(1024, { unitSeparator: ' ' }) // 1 KB
```
#### toBytes
Convert human readable string to bytes. This method is the opposite of the `prettyBytes` method.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.toBytes('1KB') // 1024
```
#### prettyMs
Convert time in milliseconds to a human readable string
```ts
import { string } from '@poppinss/utils/build/helpers'
string.prettyMs(60000) // 1min
string.prettyMs(60000, { long: true }) // 1 minute
```
#### toMs
Convert human readable string to milliseconds. This method is the opposite of the `prettyMs` method.
```ts
import { string } from '@poppinss/utils/build/helpers'
string.toMs('1min') // 60000
```
#### ordinalize
Ordinalize a string or a number value
```ts
import { string } from '@poppinss/utils/build/helpers'
string.ordinalize(1) // 1st
string.ordinalize(99) // 99th
```
#### generateRandom
Generate a cryptographically strong random string
```ts
import { string } from '@poppinss/utils/build/helpers'
string.generateRandom(32)
```
#### isEmpty
Find if a value is empty. Also checks for empty strings with all whitespace
```ts
import { string } from '@poppinss/utils/build/helpers'
string.isEmpty('') // true
string.isEmpty(' ') // true
```
### Types
The types module allows distinguishing between different Javascript datatypes. The `typeof` returns the same type for many different values. For example:
```ts
typeof ({}) // object
typeof ([]) // object
typeof (null) // object
```
WHAT??? Yes, coz everything is an object in Javascript. To have better control, you can make use of the `types.lookup` method.
#### lookup
Returns a more accurate type for a given value.
```ts
import { types } from '@poppinss/utils/build/helpers'
types.lookup({}) // object
types.lookup([]) // array
types.lookup(Object.create(null)) // object
types.lookup(null) // null
types.lookup(function () {}) // function
types.lookup(class Foo {}) // class
types.lookup(new Map()) // map
```
#### isNull
Find if the given value is null
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isNull(null)) // true
```
#### isBoolean
Find if the given value is a boolean
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isBoolean(true)) // true
```
#### isBuffer
Find if the given value is a buffer
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isBuffer(new Buffer())) // true
```
#### isNumber
Find if the given value is a number
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isNumber(100)) // true
```
#### isString
Find if the given value is a string
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isString('hello')) // true
```
#### isArguments
Find if the given value is an arguments object
```ts
import { types } from '@poppinss/utils/build/helpers'
function foo() {
types.isArguments(arguments)) // true
}
```
#### isObject
Find if the given value is a plain object
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isObject({})) // true
```
#### isDate
Find if the given value is a date object
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isDate(new Date())) // true
```
#### isArray
Find if the given value is an array
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isArray([1, 2, 3])) // true
```
#### isRegexp
Find if the given value is an regular expression
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isRegexp(/[a-z]+/)) // true
```
#### isError
Find if the given value is an instance of the error object
```ts
import { types } from '@poppinss/utils/build/helpers'
import { Exception } from '@poppinss/utils'
types.isError(new Error('foo'))) // true
types.isError(new Exception('foo'))) // true
```
#### isFunction
Find if the given value is a function
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isFunction(function foo() {})) // true
```
#### isClass
Find if the given value is a class constructor. Uses regex to distinguish between a function and a class.
```ts
import { types } from '@poppinss/utils/build/helpers'
class User {}
types.isClass(User) // true
types.isFunction(User) // true
```
#### isInteger
Find if the given value is an integer.
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isInteger(22.00) // true
types.isInteger(22) // true
types.isInteger(-1) // true
types.isInteger(-1.00) // true
types.isInteger(22.10) // false
types.isInteger(.3) // false
types.isInteger(-.3) // false
```
#### isFloat
Find if the given value is an float number.
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isFloat(22.10) // true
types.isFloat(-22.10) // true
types.isFloat(.3) // true
types.isFloat(-.3) // true
types.isFloat(22.00) // false
types.isFloat(-22.00) // false
types.isFloat(-22) // false
```
#### isDecimal
Find if the given value has a decimal. The value can be a string or a number. The number values are casted to a string by calling the `toString()` method on the value itself.
The string conversion is peformed to test the value against a regex. Since, there is no way to natively find a decimal value in Javascript.
```ts
import { types } from '@poppinss/utils/build/helpers'
types.isDecimal('22.10') // true
types.isDecimal(22.1) // true
types.isDecimal('-22.10') // true
types.isDecimal(-22.1) // true
types.isDecimal('.3') // true
types.isDecimal(0.3) // true
types.isDecimal('-.3') // true
types.isDecimal(-0.3) // true
types.isDecimal('22.00') // true
types.isDecimal(22.0) // false (gets converted to 22)
types.isDecimal('-22.00') // true
types.isDecimal(-22.0) // false (gets converted to -22)
types.isDecimal('22') // false
types.isDecimal(22) // false
types.isDecimal('0.0000000000001') // true
types.isDecimal(0.0000000000001) // false (gets converted to 1e-13)
```
### ObjectBuilder
A very simple class to conditionally builder an object. Quite often, I create a new object from an existing one and wants to avoid writing undefined values to it. For example
```ts
const obj = {
...(user.username ? { username: user.username } : {}),
...(user.id ? { id: user.id } : {}),
...(user.createdAt ? { createdAt: user.createdAt.toString() } : {}),
}
```
Not only the above code is harder to write. It is performance issues as well, since we are destructuring too many objects.
To address this use case, you can make use of the `ObjectBuilder` class as follows
```ts
import { ObjectBuilder } from '@poppinss/utils/build/helpers'
const obj = new ObjectBuilder()
.add('username', user.username)
.add('id', user.id)
.add('createdAt', user.createdAt && user.createdAt.toString())
.value // returns the underlying object
```
The `add` method ignores the value if its `undefined`. So it never gets added to the object at all. You can also ignore `null` properties by passing a boolean flag to the constructor.
```ts
new ObjectBuilder(true) // ignore null as well
```
[circleci-image]: https://img.shields.io/circleci/project/github/poppinss/utils/master.svg?style=for-the-badge&logo=circleci

@@ -504,3 +1218,3 @@ [circleci-url]: https://circleci.com/gh/poppinss/utils 'circleci'

[license-url]: LICENSE.md 'license'
[audit-report-image]: https://img.shields.io/badge/-Audit%20Report-blueviolet?style=for-the-badge
[audit-report-url]: https://htmlpreview.github.io/?https://github.com/poppinss/utils/blob/develop/npm-audit.html 'audit-report'
[synk-image]: https://img.shields.io/snyk/vulnerabilities/github/poppinss/utils?label=Synk%20Vulnerabilities&style=for-the-badge
[synk-url]: https://snyk.io/test/github/poppinss/utils?targetFile=package.json 'synk'
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc