Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vest-utils

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vest-utils - npm Package Compare versions

Comparing version 0.0.3-rc to 0.0.4-dev-ae93bf

src/__tests__/greaterThan.test.ts

88

dist/cjs/vest-utils.development.js

@@ -5,2 +5,12 @@ 'use strict';

function bindNot(fn) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return !fn.apply(void 0, args);
};
}
function isNumeric(value) {

@@ -12,2 +22,3 @@ var str = String(value);

}
var isNotNumeric = bindNot(isNumeric);

@@ -17,2 +28,3 @@ function numberEquals(value, eq) {

}
var numberNotEquals = bindNot(numberEquals);

@@ -22,2 +34,3 @@ function lengthEquals(value, arg1) {

}
var lengthNotEquals = bindNot(lengthEquals);

@@ -77,2 +90,3 @@ function greaterThan(value, gt) {

}
var isNotUndefined = bindNot(isUndefined);

@@ -84,15 +98,2 @@ function isNullish(value) {

var isNullish$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
isNullish: isNullish,
isNotNullish: isNotNullish
});
// The module is named "isArrayValue" since it
// is conflicting with a nested npm dependency.
// We may need to revisit this in the future.
function isArray(value) {
return Boolean(Array.isArray(value));
}
function asArray(possibleArg) {

@@ -119,2 +120,10 @@ return [].concat(possibleArg);

// The module is named "isArrayValue" since it
// is conflicting with a nested npm dependency.
// We may need to revisit this in the future.
function isArray(value) {
return Boolean(Array.isArray(value));
}
var isNotArray = bindNot(isArray);
function last(values) {

@@ -209,2 +218,6 @@ var valuesArray = asArray(values);

}
// eslint-disable-next-line @typescript-eslint/ban-types
function StringObject(value) {
return new String(optionalFunctionValue(value));
}

@@ -222,12 +235,2 @@ function isStringValue(v) {

function bindNot(fn) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return !fn.apply(void 0, args);
};
}
function either(a, b) {

@@ -298,2 +301,21 @@ return !!a !== !!b;

function isEmpty(value) {
if (!value) {
return true;
}
else if (hasOwnProperty(value, 'length')) {
return lengthEquals(value, 0);
}
else if (typeof value === 'object') {
return lengthEquals(Object.keys(value), 0);
}
return false;
}
var isNotEmpty = bindNot(isEmpty);
function isPositive(value) {
return greaterThan(value, 0);
}
exports.StringObject = StringObject;
exports.asArray = asArray;

@@ -309,13 +331,31 @@ exports.assign = assign;

exports.genId = genId;
exports.greaterThan = greaterThan;
exports.hasOwnProperty = hasOwnProperty;
exports.invariant = invariant;
exports.isArray = isArray;
exports.isBoolean = isBoolean;
exports.isEmpty = isEmpty;
exports.isFunction = isFunction;
exports.isNullish = isNullish$1;
exports.isNotArray = isNotArray;
exports.isNotEmpty = isNotEmpty;
exports.isNotNull = isNotNull;
exports.isNotNullish = isNotNullish;
exports.isNotNumeric = isNotNumeric;
exports.isNotUndefined = isNotUndefined;
exports.isNull = isNull;
exports.isNullish = isNullish;
exports.isNumeric = isNumeric;
exports.isPositive = isPositive;
exports.isPromise = isPromise;
exports.isStringValue = isStringValue;
exports.isUndefined = isUndefined;
exports.last = last;
exports.lengthEquals = lengthEquals;
exports.lengthNotEquals = lengthNotEquals;
exports.longerThan = longerThan;
exports.mapFirst = mapFirst;
exports.nestedArray = nestedArray;
exports.numberEquals = numberEquals;
exports.numberNotEquals = numberNotEquals;
exports.optionalFunctionValue = optionalFunctionValue;
exports.partition = partition;

@@ -1,1 +0,1 @@

"use strict";function n(n){var t=Number(n);return!(isNaN(parseFloat(String(n)))||isNaN(Number(n))||!isFinite(t))}function t(t,r){return function(t,r){return n(t)&&n(r)&&Number(t)===Number(r)}(t.length,r)}function r(t,r){return function(t,r){return n(t)&&n(r)&&Number(t)>Number(r)}(t.length,r)}function e(n){return null===n}Object.defineProperty(exports,"__esModule",{value:!0});var u=d(e);function o(n){return e(n)||function(n){return void 0===n}(n)}var i=d(o),c=Object.freeze({__proto__:null,isNullish:o,isNotNullish:i});function f(n){return!!Array.isArray(n)}function a(n){return[].concat(n)}function s(n){return"function"==typeof n}function l(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return s(n)?n.apply(void 0,t):n}function p(n,t){var r;return null!==(r=l(n))&&void 0!==r?r:l(t)}function h(n){return(n=a(n))[n.length-1]}function v(n,t){var r=0;for(t=t.slice(0,-1);r<t.length;r++){var e=t[r];n[e]=p(n[e],[]),n=n[e]}return n}var x=Object.freeze({__proto__:null,transform:function n(t,r){for(var e=[],o=0;o<t.length;o++){var i=t[o];f(i)?e.push(n(i,r)):(i=r(i),u(i)&&e.push(i))}return e},valueAtPath:function(n,t){return v(n,t)[h(t)]},setValueAtPath:function(n,t,r){return v(n,t)[h(t)]=r,n},flatten:function n(t){return a(t).reduce((function(t,r){return f(r)?t.concat(n(r)):a(t).concat(r)}),[])},getCurrent:v});var g=Object.assign;function d(n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return!n.apply(void 0,t)}}var N,b=Object.freeze({__proto__:null,createBus:function(){var n={};return{emit:function(t,r){(n[t]||[]).forEach((function(n){n(r)}))},on:function(t,r){return n[t]=(n[t]||[]).concat(r),{off:function(){n[t]=(n[t]||[]).filter((function(n){return n!==r}))}}}}}}),_=(N=0,function(){return"".concat(N++)});exports.asArray=a,exports.assign=g,exports.bindNot=d,exports.bus=b,exports.cache=function(n){function e(n){return u.findIndex((function(r){var e=r[0];return t(n,e.length)&&n.every((function(n,t){return n===e[t]}))}))}void 0===n&&(n=1);var u=[],o=function(t,e){var i=o.get(t);return i?i[1]:(e=e(),u.unshift([t.concat(),e]),r(u,n)&&(u.length=n),e)};return o.invalidate=function(n){-1<(n=e(n))&&u.splice(n,1)},o.get=function(n){return u[e(n)]||null},o},exports.callEach=function(n){return n.forEach((function(n){return n()}))},exports.defaultTo=p,exports.deferThrow=function(n){setTimeout((function(){throw Error(n)}),0)},exports.either=function(n,t){return!!n!=!!t},exports.genId=_,exports.hasOwnProperty=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},exports.invariant=function(n,t){if(!n)throw t instanceof String?t.valueOf():Error(t?l(t):t)},exports.isBoolean=function(n){return!!n===n},exports.isFunction=s,exports.isNullish=c,exports.isPromise=function(n){return n&&s(n.then)},exports.isStringValue=function(n){return String(n)===n},exports.last=h,exports.mapFirst=function(n,t){function r(n,t){n&&(e=!0,u=t)}for(var e=!1,u=null,o=0;o<n.length;o++)if(t(n[o],r,o),e)return u},exports.nestedArray=x,exports.optionalFunctionValue=l,exports.partition=function(n,t){return n.reduce((function(r,e,u){return r[t(e,u,n)?0:1].push(e),r}),[[],[]])};
"use strict";function t(t){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return!t.apply(void 0,r)}}function r(t){var r=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(r))}Object.defineProperty(exports,"__esModule",{value:!0});var n=t(r);function e(t,n){return r(t)&&r(n)&&Number(t)===Number(n)}var o=t(e);function u(t,r){return e(t.length,r)}var i=t(u);function s(t,n){return r(t)&&r(n)&&Number(t)>Number(n)}function c(t,r){return s(t.length,r)}function a(t){return null===t}var f=t(a);function p(t){return void 0===t}var l=t(p);function x(t){return a(t)||p(t)}var v=t(x);function h(t){return[].concat(t)}function g(t){return"function"==typeof t}function N(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return g(t)?t.apply(void 0,r):t}function d(t,r){var n;return null!==(n=N(t))&&void 0!==n?n:N(r)}function b(t){return!!Array.isArray(t)}var y=t(b);function m(t){return(t=h(t))[t.length-1]}function E(t,r){var n=0;for(r=r.slice(0,-1);n<r.length;n++){var e=r[n];t[e]=d(t[e],[]),t=t[e]}return t}var O=Object.freeze({__proto__:null,transform:function t(r,n){for(var e=[],o=0;o<r.length;o++){var u=r[o];b(u)?e.push(t(u,n)):(u=n(u),f(u)&&e.push(u))}return e},valueAtPath:function(t,r){return E(t,r)[m(r)]},setValueAtPath:function(t,r,n){return E(t,r)[m(r)]=n,t},flatten:function t(r){return h(r).reduce((function(r,n){return b(n)?r.concat(t(n)):h(r).concat(n)}),[])},getCurrent:E});function _(t,r){return Object.prototype.hasOwnProperty.call(t,r)}var j=Object.assign;var A,P=Object.freeze({__proto__:null,createBus:function(){var t={};return{emit:function(r,n){(t[r]||[]).forEach((function(t){t(n)}))},on:function(r,n){return t[r]=(t[r]||[]).concat(n),{off:function(){t[r]=(t[r]||[]).filter((function(t){return t!==n}))}}}}}}),w=(A=0,function(){return"".concat(A++)});function S(t){return!t||(_(t,"length")?u(t,0):"object"==typeof t&&u(Object.keys(t),0))}var F=t(S);exports.StringObject=function(t){return new String(N(t))},exports.asArray=h,exports.assign=j,exports.bindNot=t,exports.bus=P,exports.cache=function(t){function r(t){return n.findIndex((function(r){var n=r[0];return u(t,n.length)&&t.every((function(t,r){return t===n[r]}))}))}void 0===t&&(t=1);var n=[],e=function(r,o){var u=e.get(r);return u?u[1]:(o=o(),n.unshift([r.concat(),o]),c(n,t)&&(n.length=t),o)};return e.invalidate=function(t){-1<(t=r(t))&&n.splice(t,1)},e.get=function(t){return n[r(t)]||null},e},exports.callEach=function(t){return t.forEach((function(t){return t()}))},exports.defaultTo=d,exports.deferThrow=function(t){setTimeout((function(){throw Error(t)}),0)},exports.either=function(t,r){return!!t!=!!r},exports.genId=w,exports.greaterThan=s,exports.hasOwnProperty=_,exports.invariant=function(t,r){if(!t)throw r instanceof String?r.valueOf():Error(r?N(r):r)},exports.isArray=b,exports.isBoolean=function(t){return!!t===t},exports.isEmpty=S,exports.isFunction=g,exports.isNotArray=y,exports.isNotEmpty=F,exports.isNotNull=f,exports.isNotNullish=v,exports.isNotNumeric=n,exports.isNotUndefined=l,exports.isNull=a,exports.isNullish=x,exports.isNumeric=r,exports.isPositive=function(t){return s(t,0)},exports.isPromise=function(t){return t&&g(t.then)},exports.isStringValue=function(t){return String(t)===t},exports.isUndefined=p,exports.last=m,exports.lengthEquals=u,exports.lengthNotEquals=i,exports.longerThan=c,exports.mapFirst=function(t,r){function n(t,r){t&&(e=!0,o=r)}for(var e=!1,o=null,u=0;u<t.length;u++)if(r(t[u],n,u),e)return o},exports.nestedArray=O,exports.numberEquals=e,exports.numberNotEquals=o,exports.optionalFunctionValue=N,exports.partition=function(t,r){return t.reduce((function(n,e,o){return n[r(e,o,t)?0:1].push(e),n}),[[],[]])};

@@ -0,1 +1,11 @@

function bindNot(fn) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return !fn.apply(void 0, args);
};
}
function isNumeric(value) {

@@ -7,2 +17,3 @@ var str = String(value);

}
var isNotNumeric = bindNot(isNumeric);

@@ -12,2 +23,3 @@ function numberEquals(value, eq) {

}
var numberNotEquals = bindNot(numberEquals);

@@ -17,2 +29,3 @@ function lengthEquals(value, arg1) {

}
var lengthNotEquals = bindNot(lengthEquals);

@@ -72,2 +85,3 @@ function greaterThan(value, gt) {

}
var isNotUndefined = bindNot(isUndefined);

@@ -79,15 +93,2 @@ function isNullish(value) {

var isNullish$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
isNullish: isNullish,
isNotNullish: isNotNullish
});
// The module is named "isArrayValue" since it
// is conflicting with a nested npm dependency.
// We may need to revisit this in the future.
function isArray(value) {
return Boolean(Array.isArray(value));
}
function asArray(possibleArg) {

@@ -114,2 +115,10 @@ return [].concat(possibleArg);

// The module is named "isArrayValue" since it
// is conflicting with a nested npm dependency.
// We may need to revisit this in the future.
function isArray(value) {
return Boolean(Array.isArray(value));
}
var isNotArray = bindNot(isArray);
function last(values) {

@@ -204,2 +213,6 @@ var valuesArray = asArray(values);

}
// eslint-disable-next-line @typescript-eslint/ban-types
function StringObject(value) {
return new String(optionalFunctionValue(value));
}

@@ -217,12 +230,2 @@ function isStringValue(v) {

function bindNot(fn) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return !fn.apply(void 0, args);
};
}
function either(a, b) {

@@ -293,2 +296,20 @@ return !!a !== !!b;

export { asArray, assign, bindNot, bus, createCache as cache, callEach, defaultTo, deferThrow, either, genId, hasOwnProperty, invariant, isBoolean, isFunction, isNullish$1 as isNullish, isPromise, isStringValue, last, mapFirst, nestedArray, optionalFunctionValue, partition };
function isEmpty(value) {
if (!value) {
return true;
}
else if (hasOwnProperty(value, 'length')) {
return lengthEquals(value, 0);
}
else if (typeof value === 'object') {
return lengthEquals(Object.keys(value), 0);
}
return false;
}
var isNotEmpty = bindNot(isEmpty);
function isPositive(value) {
return greaterThan(value, 0);
}
export { StringObject, asArray, assign, bindNot, bus, createCache as cache, callEach, defaultTo, deferThrow, either, genId, greaterThan, hasOwnProperty, invariant, isArray, isBoolean, isEmpty, isFunction, isNotArray, isNotEmpty, isNotNull, isNotNullish, isNotNumeric, isNotUndefined, isNull, isNullish, isNumeric, isPositive, isPromise, isStringValue, isUndefined, last, lengthEquals, lengthNotEquals, longerThan, mapFirst, nestedArray, numberEquals, numberNotEquals, optionalFunctionValue, partition };

@@ -1,1 +0,1 @@

function n(n){var r=Number(n);return!(isNaN(parseFloat(String(n)))||isNaN(Number(n))||!isFinite(r))}var r=g((function(n){return null===n}));function t(n){return null==n}var u=g(t),e=Object.freeze({__proto__:null,isNullish:t,isNotNullish:u});function o(n){return[].concat(n)}function i(n){return"function"==typeof n}function c(n){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];return i(n)?n.apply(void 0,r):n}function a(n,r){var t;return null!==(t=c(n))&&void 0!==t?t:c(r)}function f(n){return(n=o(n))[n.length-1]}function l(n,r){var t=0;for(r=r.slice(0,-1);t<r.length;t++){var u=r[t];n[u]=a(n[u],[]),n=n[u]}return n}var s=Object.freeze({__proto__:null,transform:function n(t,u){for(var e=[],o=0;o<t.length;o++){var i=t[o];Array.isArray(i)?e.push(n(i,u)):(i=u(i),r(i)&&e.push(i))}return e},valueAtPath:function(n,r){return l(n,r)[f(r)]},setValueAtPath:function(n,r,t){return l(n,r)[f(r)]=t,n},flatten:function n(r){return o(r).reduce((function(r,t){return Array.isArray(t)?r.concat(n(t)):o(r).concat(t)}),[])},getCurrent:l});function h(n,r){return Object.prototype.hasOwnProperty.call(n,r)}var v=Object.assign;function g(n){return function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return!n.apply(void 0,r)}}var p,N=Object.freeze({__proto__:null,createBus:function(){var n={};return{emit:function(r,t){(n[r]||[]).forEach((function(n){n(t)}))},on:function(r,t){return n[r]=(n[r]||[]).concat(t),{off:function(){n[r]=(n[r]||[]).filter((function(n){return n!==t}))}}}}}}),b=(p=0,function(){return"".concat(p++)});function d(r){function t(u,o){var i=t.get(u);return i?i[1]:(o=o(),e.unshift([u.concat(),o]),u=e.length,i=r,n(u)&&n(i)&&Number(u)>Number(i)&&(e.length=r),o)}function u(r){return e.findIndex((function(t){var u=t[0];return function(r,t){return n(r)&&n(t)&&Number(r)===Number(t)}(r.length,u.length)&&r.every((function(n,r){return n===u[r]}))}))}void 0===r&&(r=1);var e=[];return t.invalidate=function(n){-1<(n=u(n))&&e.splice(n,1)},t.get=function(n){return e[u(n)]||null},t}function y(n){return n.forEach((function(n){return n()}))}function _(n){setTimeout((function(){throw Error(n)}),0)}function m(n,r){return!!n!=!!r}function A(n,r){if(!n)throw r instanceof String?r.valueOf():Error(r?c(r):r)}function O(n){return!!n===n}function j(n){return n&&i(n.then)}function E(n){return String(n)===n}function F(n,r){function t(n,r){n&&(u=!0,e=r)}for(var u=!1,e=null,o=0;o<n.length;o++)if(r(n[o],t,o),u)return e}function w(n,r){return n.reduce((function(t,u,e){return t[r(u,e,n)?0:1].push(u),t}),[[],[]])}export{o as asArray,v as assign,g as bindNot,N as bus,d as cache,y as callEach,a as defaultTo,_ as deferThrow,m as either,b as genId,h as hasOwnProperty,A as invariant,O as isBoolean,i as isFunction,e as isNullish,j as isPromise,E as isStringValue,f as last,F as mapFirst,s as nestedArray,c as optionalFunctionValue,w as partition};
function n(n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return!n.apply(void 0,t)}}function t(n){var t=Number(n);return!(isNaN(parseFloat(String(n)))||isNaN(Number(n))||!isFinite(t))}var r=n(t);function u(n,r){return t(n)&&t(r)&&Number(n)===Number(r)}var e=n(u);function o(n,t){return u(n.length,t)}var i=n(o);function a(n,r){return t(n)&&t(r)&&Number(n)>Number(r)}function c(n,t){return a(n.length,t)}function f(n){return null===n}var s=n(f);function l(n){return void 0===n}var v=n(l);function h(n){return null===n||l(n)}var g=n(h);function N(n){return[].concat(n)}function p(n){return"function"==typeof n}function d(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return p(n)?n.apply(void 0,t):n}function b(n,t){var r;return null!==(r=d(n))&&void 0!==r?r:d(t)}function y(n){return!!Array.isArray(n)}var m=n(y);function E(n){return(n=N(n))[n.length-1]}function A(n,t){var r=0;for(t=t.slice(0,-1);r<t.length;r++){var u=t[r];n[u]=b(n[u],[]),n=n[u]}return n}var _=Object.freeze({__proto__:null,transform:function n(t,r){for(var u=[],e=0;e<t.length;e++){var o=t[e];y(o)?u.push(n(o,r)):(o=r(o),s(o)&&u.push(o))}return u},valueAtPath:function(n,t){return A(n,t)[E(t)]},setValueAtPath:function(n,t,r){return A(n,t)[E(t)]=r,n},flatten:function n(t){return N(t).reduce((function(t,r){return y(r)?t.concat(n(r)):N(t).concat(r)}),[])},getCurrent:A});function O(n,t){return Object.prototype.hasOwnProperty.call(n,t)}var j,q=Object.assign,w=Object.freeze({__proto__:null,createBus:function(){var n={};return{emit:function(t,r){(n[t]||[]).forEach((function(n){n(r)}))},on:function(t,r){return n[t]=(n[t]||[]).concat(r),{off:function(){n[t]=(n[t]||[]).filter((function(n){return n!==r}))}}}}}}),F=(j=0,function(){return"".concat(j++)});function S(n){return!n||(O(n,"length")?o(n,0):"object"==typeof n&&o(Object.keys(n),0))}var T=n(S);function P(n){return new String(d(n))}function x(n){function t(r,e){var o=t.get(r);return o?o[1]:(e=e(),u.unshift([r.concat(),e]),c(u,n)&&(u.length=n),e)}function r(n){return u.findIndex((function(t){var r=t[0];return o(n,r.length)&&n.every((function(n,t){return n===r[t]}))}))}void 0===n&&(n=1);var u=[];return t.invalidate=function(n){-1<(n=r(n))&&u.splice(n,1)},t.get=function(n){return u[r(n)]||null},t}function z(n){return n.forEach((function(n){return n()}))}function I(n){setTimeout((function(){throw Error(n)}),0)}function U(n,t){return!!n!=!!t}function V(n,t){if(!n)throw t instanceof String?t.valueOf():Error(t?d(t):t)}function k(n){return!!n===n}function B(n){return a(n,0)}function C(n){return n&&p(n.then)}function D(n){return String(n)===n}function G(n,t){function r(n,t){n&&(u=!0,e=t)}for(var u=!1,e=null,o=0;o<n.length;o++)if(t(n[o],r,o),u)return e}function H(n,t){return n.reduce((function(r,u,e){return r[t(u,e,n)?0:1].push(u),r}),[[],[]])}export{P as StringObject,N as asArray,q as assign,n as bindNot,w as bus,x as cache,z as callEach,b as defaultTo,I as deferThrow,U as either,F as genId,a as greaterThan,O as hasOwnProperty,V as invariant,y as isArray,k as isBoolean,S as isEmpty,p as isFunction,m as isNotArray,T as isNotEmpty,s as isNotNull,g as isNotNullish,r as isNotNumeric,v as isNotUndefined,f as isNull,h as isNullish,t as isNumeric,B as isPositive,C as isPromise,D as isStringValue,l as isUndefined,E as last,o as lengthEquals,i as lengthNotEquals,c as longerThan,G as mapFirst,_ as nestedArray,u as numberEquals,e as numberNotEquals,d as optionalFunctionValue,H as partition};

@@ -7,2 +7,12 @@ (function (global, factory) {

function bindNot(fn) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return !fn.apply(void 0, args);
};
}
function isNumeric(value) {

@@ -14,2 +24,3 @@ var str = String(value);

}
var isNotNumeric = bindNot(isNumeric);

@@ -19,2 +30,3 @@ function numberEquals(value, eq) {

}
var numberNotEquals = bindNot(numberEquals);

@@ -24,2 +36,3 @@ function lengthEquals(value, arg1) {

}
var lengthNotEquals = bindNot(lengthEquals);

@@ -79,2 +92,3 @@ function greaterThan(value, gt) {

}
var isNotUndefined = bindNot(isUndefined);

@@ -86,15 +100,2 @@ function isNullish(value) {

var isNullish$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
isNullish: isNullish,
isNotNullish: isNotNullish
});
// The module is named "isArrayValue" since it
// is conflicting with a nested npm dependency.
// We may need to revisit this in the future.
function isArray(value) {
return Boolean(Array.isArray(value));
}
function asArray(possibleArg) {

@@ -121,2 +122,10 @@ return [].concat(possibleArg);

// The module is named "isArrayValue" since it
// is conflicting with a nested npm dependency.
// We may need to revisit this in the future.
function isArray(value) {
return Boolean(Array.isArray(value));
}
var isNotArray = bindNot(isArray);
function last(values) {

@@ -211,2 +220,6 @@ var valuesArray = asArray(values);

}
// eslint-disable-next-line @typescript-eslint/ban-types
function StringObject(value) {
return new String(optionalFunctionValue(value));
}

@@ -224,12 +237,2 @@ function isStringValue(v) {

function bindNot(fn) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return !fn.apply(void 0, args);
};
}
function either(a, b) {

@@ -300,2 +303,21 @@ return !!a !== !!b;

function isEmpty(value) {
if (!value) {
return true;
}
else if (hasOwnProperty(value, 'length')) {
return lengthEquals(value, 0);
}
else if (typeof value === 'object') {
return lengthEquals(Object.keys(value), 0);
}
return false;
}
var isNotEmpty = bindNot(isEmpty);
function isPositive(value) {
return greaterThan(value, 0);
}
exports.StringObject = StringObject;
exports.asArray = asArray;

@@ -311,12 +333,30 @@ exports.assign = assign;

exports.genId = genId;
exports.greaterThan = greaterThan;
exports.hasOwnProperty = hasOwnProperty;
exports.invariant = invariant;
exports.isArray = isArray;
exports.isBoolean = isBoolean;
exports.isEmpty = isEmpty;
exports.isFunction = isFunction;
exports.isNullish = isNullish$1;
exports.isNotArray = isNotArray;
exports.isNotEmpty = isNotEmpty;
exports.isNotNull = isNotNull;
exports.isNotNullish = isNotNullish;
exports.isNotNumeric = isNotNumeric;
exports.isNotUndefined = isNotUndefined;
exports.isNull = isNull;
exports.isNullish = isNullish;
exports.isNumeric = isNumeric;
exports.isPositive = isPositive;
exports.isPromise = isPromise;
exports.isStringValue = isStringValue;
exports.isUndefined = isUndefined;
exports.last = last;
exports.lengthEquals = lengthEquals;
exports.lengthNotEquals = lengthNotEquals;
exports.longerThan = longerThan;
exports.mapFirst = mapFirst;
exports.nestedArray = nestedArray;
exports.numberEquals = numberEquals;
exports.numberNotEquals = numberNotEquals;
exports.optionalFunctionValue = optionalFunctionValue;

@@ -323,0 +363,0 @@ exports.partition = partition;

@@ -1,1 +0,1 @@

"use strict";!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self)["vest-utils"]={})}(this,(function(n){function t(n){var t=Number(n);return!(isNaN(parseFloat(String(n)))||isNaN(Number(n))||!isFinite(t))}function r(n){return null==n}function e(n){return[].concat(n)}function u(n){return"function"==typeof n}function o(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return u(n)?n.apply(void 0,t):n}function i(n,t){var r;return null!==(r=o(n))&&void 0!==r?r:o(t)}function c(n){return(n=e(n))[n.length-1]}function f(n,t){var r=0;for(t=t.slice(0,-1);r<t.length;r++){var e=t[r];n[e]=i(n[e],[]),n=n[e]}return n}function a(n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return!n.apply(void 0,t)}}var l=a((function(n){return null===n})),s=a(r);s=Object.freeze({__proto__:null,isNullish:r,isNotNullish:s});var h,p=Object.freeze({__proto__:null,transform:function n(t,r){for(var e=[],u=0;u<t.length;u++){var o=t[u];Array.isArray(o)?e.push(n(o,r)):(o=r(o),l(o)&&e.push(o))}return e},valueAtPath:function(n,t){return f(n,t)[c(t)]},setValueAtPath:function(n,t,r){return f(n,t)[c(t)]=r,n},flatten:function n(t){return e(t).reduce((function(t,r){return Array.isArray(r)?t.concat(n(r)):e(t).concat(r)}),[])},getCurrent:f}),v=Object.assign,d=Object.freeze({__proto__:null,createBus:function(){var n={};return{emit:function(t,r){(n[t]||[]).forEach((function(n){n(r)}))},on:function(t,r){return n[t]=(n[t]||[]).concat(r),{off:function(){n[t]=(n[t]||[]).filter((function(n){return n!==r}))}}}}}}),g=(h=0,function(){return"".concat(h++)});n.asArray=e,n.assign=v,n.bindNot=a,n.bus=d,n.cache=function(n){function r(n){return e.findIndex((function(r){var e=r[0];return function(n,r){return t(n)&&t(r)&&Number(n)===Number(r)}(n.length,e.length)&&n.every((function(n,t){return n===e[t]}))}))}void 0===n&&(n=1);var e=[],u=function(r,o){var i=u.get(r);return i?i[1]:(o=o(),e.unshift([r.concat(),o]),r=e.length,i=n,t(r)&&t(i)&&Number(r)>Number(i)&&(e.length=n),o)};return u.invalidate=function(n){-1<(n=r(n))&&e.splice(n,1)},u.get=function(n){return e[r(n)]||null},u},n.callEach=function(n){return n.forEach((function(n){return n()}))},n.defaultTo=i,n.deferThrow=function(n){setTimeout((function(){throw Error(n)}),0)},n.either=function(n,t){return!!n!=!!t},n.genId=g,n.hasOwnProperty=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},n.invariant=function(n,t){if(!n)throw t instanceof String?t.valueOf():Error(t?o(t):t)},n.isBoolean=function(n){return!!n===n},n.isFunction=u,n.isNullish=s,n.isPromise=function(n){return n&&u(n.then)},n.isStringValue=function(n){return String(n)===n},n.last=c,n.mapFirst=function(n,t){function r(n,t){n&&(e=!0,u=t)}for(var e=!1,u=null,o=0;o<n.length;o++)if(t(n[o],r,o),e)return u},n.nestedArray=p,n.optionalFunctionValue=o,n.partition=function(n,t){return n.reduce((function(r,e,u){return r[t(e,u,n)?0:1].push(e),r}),[[],[]])},Object.defineProperty(n,"__esModule",{value:!0})}));
"use strict";!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self)["vest-utils"]={})}(this,(function(n){function t(n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return!n.apply(void 0,t)}}function r(n){var t=Number(n);return!(isNaN(parseFloat(String(n)))||isNaN(Number(n))||!isFinite(t))}function e(n,t){return r(n)&&r(t)&&Number(n)===Number(t)}function u(n,t){return e(n.length,t)}function i(n,t){return r(n)&&r(t)&&Number(n)>Number(t)}function o(n,t){return i(n.length,t)}function c(n){return null===n}function f(n){return void 0===n}function a(n){return null===n||f(n)}function l(n){return[].concat(n)}function s(n){return"function"==typeof n}function h(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return s(n)?n.apply(void 0,t):n}function d(n,t){var r;return null!==(r=h(n))&&void 0!==r?r:h(t)}function p(n){return!!Array.isArray(n)}function g(n){return(n=l(n))[n.length-1]}function v(n,t){var r=0;for(t=t.slice(0,-1);r<t.length;r++){var e=t[r];n[e]=d(n[e],[]),n=n[e]}return n}function N(n,t){return Object.prototype.hasOwnProperty.call(n,t)}function y(n){return!n||(N(n,"length")?u(n,0):"object"==typeof n&&u(Object.keys(n),0))}var b,m=t(r),E=t(e),O=t(u),_=t(c),j=t(f),A=t(a),P=t(p),T=Object.freeze({__proto__:null,transform:function n(t,r){for(var e=[],u=0;u<t.length;u++){var i=t[u];p(i)?e.push(n(i,r)):(i=r(i),_(i)&&e.push(i))}return e},valueAtPath:function(n,t){return v(n,t)[g(t)]},setValueAtPath:function(n,t,r){return v(n,t)[g(t)]=r,n},flatten:function n(t){return l(t).reduce((function(t,r){return p(r)?t.concat(n(r)):l(t).concat(r)}),[])},getCurrent:v}),w=Object.assign,S=Object.freeze({__proto__:null,createBus:function(){var n={};return{emit:function(t,r){(n[t]||[]).forEach((function(n){n(r)}))},on:function(t,r){return n[t]=(n[t]||[]).concat(r),{off:function(){n[t]=(n[t]||[]).filter((function(n){return n!==r}))}}}}}}),F=(b=0,function(){return"".concat(b++)}),q=t(y);n.StringObject=function(n){return new String(h(n))},n.asArray=l,n.assign=w,n.bindNot=t,n.bus=S,n.cache=function(n){function t(n){return r.findIndex((function(t){var r=t[0];return u(n,r.length)&&n.every((function(n,t){return n===r[t]}))}))}void 0===n&&(n=1);var r=[],e=function(t,u){var i=e.get(t);return i?i[1]:(u=u(),r.unshift([t.concat(),u]),o(r,n)&&(r.length=n),u)};return e.invalidate=function(n){-1<(n=t(n))&&r.splice(n,1)},e.get=function(n){return r[t(n)]||null},e},n.callEach=function(n){return n.forEach((function(n){return n()}))},n.defaultTo=d,n.deferThrow=function(n){setTimeout((function(){throw Error(n)}),0)},n.either=function(n,t){return!!n!=!!t},n.genId=F,n.greaterThan=i,n.hasOwnProperty=N,n.invariant=function(n,t){if(!n)throw t instanceof String?t.valueOf():Error(t?h(t):t)},n.isArray=p,n.isBoolean=function(n){return!!n===n},n.isEmpty=y,n.isFunction=s,n.isNotArray=P,n.isNotEmpty=q,n.isNotNull=_,n.isNotNullish=A,n.isNotNumeric=m,n.isNotUndefined=j,n.isNull=c,n.isNullish=a,n.isNumeric=r,n.isPositive=function(n){return i(n,0)},n.isPromise=function(n){return n&&s(n.then)},n.isStringValue=function(n){return String(n)===n},n.isUndefined=f,n.last=g,n.lengthEquals=u,n.lengthNotEquals=O,n.longerThan=o,n.mapFirst=function(n,t){function r(n,t){n&&(e=!0,u=t)}for(var e=!1,u=null,i=0;i<n.length;i++)if(t(n[i],r,i),e)return u},n.nestedArray=T,n.numberEquals=e,n.numberNotEquals=E,n.optionalFunctionValue=h,n.partition=function(n,t){return n.reduce((function(r,e,u){return r[t(e,u,n)?0:1].push(e),r}),[[],[]])},Object.defineProperty(n,"__esModule",{value:!0})}));
{
"version": "0.0.3-rc",
"version": "0.0.4-dev-ae93bf",
"name": "vest-utils",

@@ -4,0 +4,0 @@ "author": "ealush",

@@ -1,10 +0,10 @@

import { bus } from 'vest-utils';
import { createBus } from 'bus';
describe('bus', () => {
it('should be a function', () => {
expect(bus.createBus).toBeInstanceOf(Function);
expect(createBus).toBeInstanceOf(Function);
});
it('should return a bus', () => {
const bus = bus.createBus();
const bus = createBus();
expect(bus).toBeInstanceOf(Object);

@@ -16,3 +16,3 @@ expect(bus.emit).toBeInstanceOf(Function);

it('should emit events', () => {
const bus = bus.createBus();
const bus = createBus();
const spy = jest.fn();

@@ -25,3 +25,3 @@ bus.on('test', spy);

it('should emit events with data', () => {
const bus = bus.createBus();
const bus = createBus();
const spy = jest.fn();

@@ -34,3 +34,3 @@ bus.on('test', spy);

it('should emit events with multiple listeners', () => {
const bus = bus.createBus();
const bus = createBus();
const spy1 = jest.fn();

@@ -46,3 +46,3 @@ const spy2 = jest.fn();

it('should emit events with multiple listeners and data', () => {
const bus = bus.createBus();
const bus = createBus();
const spy1 = jest.fn();

@@ -58,3 +58,3 @@ const spy2 = jest.fn();

test('on returns an object with an `off` function', () => {
const bus = bus.createBus();
const bus = createBus();
const spy = jest.fn();

@@ -67,3 +67,3 @@ const off = bus.on('test', spy);

test('off should remove a listener', () => {
const bus = bus.createBus();
const bus = createBus();
const spy = jest.fn();

@@ -77,3 +77,3 @@ const off = bus.on('test', spy);

test('off should only remove specific handler', () => {
const bus = bus.createBus();
const bus = createBus();
const spy1 = jest.fn();

@@ -80,0 +80,0 @@ const spy2 = jest.fn();

@@ -0,6 +1,5 @@

import bindNot from 'bindNot';
import { isNull } from 'isNull';
import { isUndefined } from 'isUndefined';
import { bindNot } from 'vest-utils';
export function isNullish(value: any): value is null | undefined {

@@ -7,0 +6,0 @@ return isNull(value) || isUndefined(value);

@@ -0,6 +1,5 @@

import asArray from 'asArray';
import defaultTo from 'defaultTo';
import { isArray } from 'isArrayValue';
import { isNotNull } from 'isNull';
import asArray from 'asArray';
import defaultTo from 'defaultTo';
import last from 'last';

@@ -7,0 +6,0 @@

export { default as cache } from 'cache';
export * as isNullish from 'isNullish';
export { isNullish, isNotNullish } from 'isNullish';
export * as nestedArray from 'nestedArray';

@@ -11,3 +11,3 @@ export { default as asArray } from 'asArray';

export { default as defaultTo } from 'defaultTo';
export { default as invariant } from 'invariant';
export { default as invariant, StringObject } from 'invariant';
export { default as isStringValue } from 'isStringValue';

@@ -24,1 +24,11 @@ export { default as partition } from 'partition';

export { default as mapFirst } from 'mapFirst';
export { greaterThan } from 'greaterThan';
export { longerThan } from 'longerThan';
export { isNumeric, isNotNumeric } from 'isNumeric';
export { lengthEquals, lengthNotEquals } from 'lengthEquals';
export { numberEquals, numberNotEquals } from 'numberEquals';
export { isNull, isNotNull } from 'isNull';
export { isUndefined, isNotUndefined } from 'isUndefined';
export { isArray, isNotArray } from 'isArrayValue';
export { isEmpty, isNotEmpty } from 'isEmpty';
export { isPositive } from 'isPositive';

@@ -9,6 +9,4 @@ /**

};
declare namespace isNullish {
function isNullish(value: any): value is null | undefined;
const isNotNullish: (value: any) => boolean;
}
declare function isNullish(value: any): value is null | undefined;
declare const isNotNullish: (value: any) => boolean;
declare namespace nestedArray {

@@ -45,2 +43,4 @@ type NestedArray<T> = Array<NestedArray<T> | T>;

message?: String | Stringable): asserts condition;
// eslint-disable-next-line @typescript-eslint/ban-types
declare function StringObject(value?: Stringable): String;
declare function isStringValue(v: unknown): v is string;

@@ -78,2 +78,22 @@ declare function partition<T>(array: T[], predicate: (value: T, index: number, array: T[]) => boolean): [

declare function mapFirst<T>(array: T[], callback: (item: T, breakout: (conditional: boolean, value: unknown) => void, index: number) => unknown): any;
export { createCache as cache, isNullish, nestedArray, asArray, callEach, hasOwnProperty, isPromise, optionalFunctionValue, _default as assign, defaultTo, invariant, isStringValue, partition, bindNot, either, isBoolean, last, deferThrow, bus, genId, isFunction, mapFirst };
declare function greaterThan(value: number | string, gt: number | string): boolean;
declare function longerThan(value: string | unknown[], arg1: string | number): boolean;
declare function isNumeric(value: string | number): boolean;
declare const isNotNumeric: (value: string | number) => boolean;
declare function lengthEquals(value: string | unknown[], arg1: string | number): boolean;
declare const lengthNotEquals: (value: string | unknown[], arg1: string | number) => boolean;
declare function numberEquals(value: string | number, eq: string | number): boolean;
declare const numberNotEquals: (value: string | number, eq: string | number) => boolean;
declare function isNull(value: unknown): value is null;
declare const isNotNull: (value: unknown) => boolean;
declare function isUndefined(value?: unknown): value is undefined;
declare const isNotUndefined: (value?: unknown) => boolean;
// The module is named "isArrayValue" since it
// is conflicting with a nested npm dependency.
// We may need to revisit this in the future.
declare function isArray(value: unknown): value is Array<unknown>;
declare const isNotArray: (value: unknown) => boolean;
declare function isEmpty(value: unknown): boolean;
declare const isNotEmpty: (value: unknown) => boolean;
declare function isPositive(value: number | string): boolean;
export { createCache as cache, isNullish, isNotNullish, nestedArray, asArray, callEach, hasOwnProperty, isPromise, optionalFunctionValue, _default as assign, defaultTo, invariant, StringObject, isStringValue, partition, bindNot, either, isBoolean, last, deferThrow, bus, genId, isFunction, mapFirst, greaterThan, longerThan, isNumeric, isNotNumeric, lengthEquals, lengthNotEquals, numberEquals, numberNotEquals, isNull, isNotNull, isUndefined, isNotUndefined, isArray, isNotArray, isEmpty, isNotEmpty, isPositive };
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