vest-utils
Advanced tools
Comparing version 0.0.3-rc to 0.0.3
@@ -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)); | ||
} | ||
@@ -215,19 +228,2 @@ function isStringValue(v) { | ||
function partition(array, predicate) { | ||
return array.reduce(function (partitions, value, number) { | ||
partitions[predicate(value, number, array) ? 0 : 1].push(value); | ||
return partitions; | ||
}, [[], []]); | ||
} | ||
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) { | ||
@@ -277,3 +273,3 @@ return !!a !== !!b; | ||
*/ | ||
var genId = (function (n) { return function () { | ||
var seq = (function (n) { return function () { | ||
return "".concat(n++); | ||
@@ -299,2 +295,21 @@ }; })(0); | ||
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,14 +324,31 @@ exports.assign = assign; | ||
exports.either = either; | ||
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; | ||
exports.seq = seq; |
@@ -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 r(r){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return!r.apply(void 0,t)}}function t(r){var t=String(r),n=Number(r),e=!isNaN(parseFloat(t))&&!isNaN(Number(r))&&isFinite(n);return Boolean(e)}Object.defineProperty(exports,"__esModule",{value:!0});var n=r(t);function e(r,n){return t(r)&&t(n)&&Number(r)===Number(n)}var o=r(e);function u(r,t){return e(r.length,t)}var i=r(u);function s(r,n){return t(r)&&t(n)&&Number(r)>Number(n)}function c(r,t){return s(r.length,t)}function a(r){return null===r}var f=r(a);function l(r){return void 0===r}var p=r(l);function x(r){return a(r)||l(r)}var v=r(x);function h(r){return[].concat(r)}function g(r){return"function"==typeof r}function N(r){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return g(r)?r.apply(void 0,t):r}function d(r,t){var n;return null!==(n=N(r))&&void 0!==n?n:N(t)}function b(r){return Boolean(Array.isArray(r))}var y=r(b);function m(r){var t=h(r);return t[t.length-1]}function E(r,t){for(var n=r,e=0,o=t.slice(0,-1);e<o.length;e++){var u=o[e];n[u]=d(n[u],[]),n=n[u]}return n}var O=Object.freeze({__proto__:null,transform:function r(t,n){for(var e=[],o=0,u=t;o<u.length;o++){var i=u[o];if(b(i))e.push(r(i,n));else{var s=n(i);f(s)&&e.push(s)}}return e},valueAtPath:function(r,t){return E(r,t)[m(t)]},setValueAtPath:function(r,t,n){return E(r,t)[m(t)]=n,r},flatten:function r(t){return h(t).reduce((function(t,n){return b(n)?t.concat(r(n)):h(t).concat(n)}),[])},getCurrent:E});function _(r,t){return Object.prototype.hasOwnProperty.call(r,t)}var j=Object.assign;var w,A=Object.freeze({__proto__:null,createBus:function(){var r={};return{emit:function(r,n){t(r).forEach((function(r){r(n)}))},on:function(n,e){return r[n]=t(n).concat(e),{off:function(){r[n]=t(n).filter((function(r){return r!==e}))}}}};function t(t){return r[t]||[]}}}),P=(w=0,function(){return"".concat(w++)});function S(r){return!r||(_(r,"length")?u(r,0):"object"==typeof r&&u(Object.keys(r),0))}var q=r(S);exports.StringObject=function(r){return new String(N(r))},exports.asArray=h,exports.assign=j,exports.bindNot=r,exports.bus=A,exports.cache=function(r){void 0===r&&(r=1);var t=[],n=function(e,o){var u=n.get(e);if(u)return u[1];var i=o();return t.unshift([e.concat(),i]),c(t,r)&&(t.length=r),i};return n.invalidate=function(r){var n=e(r);n>-1&&t.splice(n,1)},n.get=function(r){return t[e(r)]||null},n;function e(r){return t.findIndex((function(t){var n=t[0];return u(r,n.length)&&r.every((function(r,t){return r===n[t]}))}))}},exports.callEach=function(r){return r.forEach((function(r){return r()}))},exports.defaultTo=d,exports.deferThrow=function(r){setTimeout((function(){throw new Error(r)}),0)},exports.either=function(r,t){return!!r!=!!t},exports.greaterThan=s,exports.hasOwnProperty=_,exports.invariant=function(r,t){if(!r)throw t instanceof String?t.valueOf():new Error(t?N(t):t)},exports.isArray=b,exports.isBoolean=function(r){return!!r===r},exports.isEmpty=S,exports.isFunction=g,exports.isNotArray=y,exports.isNotEmpty=q,exports.isNotNull=f,exports.isNotNullish=v,exports.isNotNumeric=n,exports.isNotUndefined=p,exports.isNull=a,exports.isNullish=x,exports.isNumeric=t,exports.isPositive=function(r){return s(r,0)},exports.isPromise=function(r){return r&&g(r.then)},exports.isStringValue=function(r){return String(r)===r},exports.isUndefined=l,exports.last=m,exports.lengthEquals=u,exports.lengthNotEquals=i,exports.longerThan=c,exports.mapFirst=function(r,t){for(var n=!1,e=null,o=0;o<r.length;o++)if(t(r[o],u,o),n)return e;function u(r,t){r&&(n=!0,e=t)}},exports.nestedArray=O,exports.numberEquals=e,exports.numberNotEquals=o,exports.optionalFunctionValue=N,exports.seq=P; |
@@ -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)); | ||
} | ||
@@ -210,19 +223,2 @@ function isStringValue(v) { | ||
function partition(array, predicate) { | ||
return array.reduce(function (partitions, value, number) { | ||
partitions[predicate(value, number, array) ? 0 : 1].push(value); | ||
return partitions; | ||
}, [[], []]); | ||
} | ||
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) { | ||
@@ -272,3 +268,3 @@ return !!a !== !!b; | ||
*/ | ||
var genId = (function (n) { return function () { | ||
var seq = (function (n) { return function () { | ||
return "".concat(n++); | ||
@@ -294,2 +290,20 @@ }; })(0); | ||
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, 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, seq }; |
@@ -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 r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return!n.apply(void 0,r)}}function r(n){var r=String(n),t=Number(n),u=!isNaN(parseFloat(r))&&!isNaN(Number(n))&&isFinite(t);return Boolean(u)}var t=n(r);function u(n,t){return r(n)&&r(t)&&Number(n)===Number(t)}var e=n(u);function o(n,r){return u(n.length,r)}var i=n(o);function c(n,t){return r(n)&&r(t)&&Number(n)>Number(t)}function f(n,r){return c(n.length,r)}function a(n){void 0===n&&(n=1);var r=[],t=function(u,e){var o=t.get(u);if(o)return o[1];var i=e();return r.unshift([u.concat(),i]),f(r,n)&&(r.length=n),i};return t.invalidate=function(n){var t=u(n);t>-1&&r.splice(t,1)},t.get=function(n){return r[u(n)]||null},t;function u(n){return r.findIndex((function(r){var t=r[0];return o(n,t.length)&&n.every((function(n,r){return n===t[r]}))}))}}function l(n){return null===n}var v=n(l);function h(n){return void 0===n}var s=n(h);function g(n){return l(n)||h(n)}var p=n(g);function b(n){return[].concat(n)}function y(n){return"function"==typeof n}function N(n){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];return y(n)?n.apply(void 0,r):n}function d(n,r){var t;return null!==(t=N(n))&&void 0!==t?t:N(r)}function m(n){return Boolean(Array.isArray(n))}var _=n(m);function O(n){var r=b(n);return r[r.length-1]}function j(n,r){for(var t=n,u=0,e=r.slice(0,-1);u<e.length;u++){var o=e[u];t[o]=d(t[o],[]),t=t[o]}return t}var w=Object.freeze({__proto__:null,transform:function n(r,t){for(var u=[],e=0,o=r;e<o.length;e++){var i=o[e];if(m(i))u.push(n(i,t));else{var c=t(i);v(c)&&u.push(c)}}return u},valueAtPath:function(n,r){return j(n,r)[O(r)]},setValueAtPath:function(n,r,t){return j(n,r)[O(r)]=t,n},flatten:function n(r){return b(r).reduce((function(r,t){return m(t)?r.concat(n(t)):b(r).concat(t)}),[])},getCurrent:j});function A(n){return n.forEach((function(n){return n()}))}function E(n,r){return Object.prototype.hasOwnProperty.call(n,r)}function S(n){return n&&y(n.then)}var B=Object.assign;function P(n,r){if(!n)throw r instanceof String?r.valueOf():new Error(r?N(r):r)}function x(n){return new String(N(n))}function z(n){return String(n)===n}function F(n,r){return!!n!=!!r}function k(n){return!!n===n}function C(n){setTimeout((function(){throw new Error(n)}),0)}var I,T=Object.freeze({__proto__:null,createBus:function(){var n={};return{emit:function(n,t){r(n).forEach((function(n){n(t)}))},on:function(t,u){return n[t]=r(t).concat(u),{off:function(){n[t]=r(t).filter((function(n){return n!==u}))}}}};function r(r){return n[r]||[]}}}),V=(I=0,function(){return"".concat(I++)});function q(n,r){for(var t=!1,u=null,e=0;e<n.length;e++)if(r(n[e],o,e),t)return u;function o(n,r){n&&(t=!0,u=r)}}function D(n){return!n||(E(n,"length")?o(n,0):"object"==typeof n&&o(Object.keys(n),0))}var G=n(D);function H(n){return c(n,0)}export{x as StringObject,b as asArray,B as assign,n as bindNot,T as bus,a as cache,A as callEach,d as defaultTo,C as deferThrow,F as either,c as greaterThan,E as hasOwnProperty,P as invariant,m as isArray,k as isBoolean,D as isEmpty,y as isFunction,_ as isNotArray,G as isNotEmpty,v as isNotNull,p as isNotNullish,t as isNotNumeric,s as isNotUndefined,l as isNull,g as isNullish,r as isNumeric,H as isPositive,S as isPromise,z as isStringValue,h as isUndefined,O as last,o as lengthEquals,i as lengthNotEquals,f as longerThan,q as mapFirst,w as nestedArray,u as numberEquals,e as numberNotEquals,N as optionalFunctionValue,V as seq}; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['vest-utils'] = {})); | ||
}(this, (function (exports) { 'use strict'; | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["vest-utils"] = {})); | ||
})(this, (function (exports) { '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) { | ||
@@ -13,2 +23,3 @@ var str = String(value); | ||
} | ||
var isNotNumeric = bindNot(isNumeric); | ||
@@ -18,2 +29,3 @@ function numberEquals(value, eq) { | ||
} | ||
var numberNotEquals = bindNot(numberEquals); | ||
@@ -23,2 +35,3 @@ function lengthEquals(value, arg1) { | ||
} | ||
var lengthNotEquals = bindNot(lengthEquals); | ||
@@ -78,2 +91,3 @@ function greaterThan(value, gt) { | ||
} | ||
var isNotUndefined = bindNot(isUndefined); | ||
@@ -85,15 +99,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) { | ||
@@ -120,2 +121,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) { | ||
@@ -210,2 +219,6 @@ var valuesArray = asArray(values); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
function StringObject(value) { | ||
return new String(optionalFunctionValue(value)); | ||
} | ||
@@ -216,19 +229,2 @@ function isStringValue(v) { | ||
function partition(array, predicate) { | ||
return array.reduce(function (partitions, value, number) { | ||
partitions[predicate(value, number, array) ? 0 : 1].push(value); | ||
return partitions; | ||
}, [[], []]); | ||
} | ||
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) { | ||
@@ -278,3 +274,3 @@ return !!a !== !!b; | ||
*/ | ||
var genId = (function (n) { return function () { | ||
var seq = (function (n) { return function () { | ||
return "".concat(n++); | ||
@@ -300,2 +296,21 @@ }; })(0); | ||
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; | ||
@@ -310,18 +325,35 @@ exports.assign = assign; | ||
exports.either = either; | ||
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; | ||
exports.seq = seq; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
})); |
@@ -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})})); | ||
!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){"use strict";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=String(n),r=Number(n),e=!isNaN(parseFloat(t))&&!isNaN(Number(n))&&isFinite(r);return Boolean(e)}var e=t(r);function u(n,t){return r(n)&&r(t)&&Number(n)===Number(t)}var i=t(u);function o(n,t){return u(n.length,t)}var f=t(o);function c(n,t){return r(n)&&r(t)&&Number(n)>Number(t)}function a(n,t){return c(n.length,t)}function l(n){return null===n}var s=t(l);function v(n){return void 0===n}var h=t(v);function d(n){return l(n)||v(n)}var g=t(d);function p(n){return[].concat(n)}function N(n){return"function"==typeof n}function y(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return N(n)?n.apply(void 0,t):n}function b(n,t){var r;return null!==(r=y(n))&&void 0!==r?r:y(t)}function m(n){return Boolean(Array.isArray(n))}var E=t(m);function O(n){var t=p(n);return t[t.length-1]}function _(n,t){for(var r=n,e=0,u=t.slice(0,-1);e<u.length;e++){var i=u[e];r[i]=b(r[i],[]),r=r[i]}return r}var j=Object.freeze({__proto__:null,transform:function n(t,r){for(var e=[],u=0,i=t;u<i.length;u++){var o=i[u];if(m(o))e.push(n(o,r));else{var f=r(o);s(f)&&e.push(f)}}return e},valueAtPath:function(n,t){return _(n,t)[O(t)]},setValueAtPath:function(n,t,r){return _(n,t)[O(t)]=r,n},flatten:function n(t){return p(t).reduce((function(t,r){return m(r)?t.concat(n(r)):p(t).concat(r)}),[])},getCurrent:_});function w(n,t){return Object.prototype.hasOwnProperty.call(n,t)}var A=Object.assign;var P,T=Object.freeze({__proto__:null,createBus:function(){var n={};return{emit:function(n,r){t(n).forEach((function(n){n(r)}))},on:function(r,e){return n[r]=t(r).concat(e),{off:function(){n[r]=t(r).filter((function(n){return n!==e}))}}}};function t(t){return n[t]||[]}}}),S=(P=0,function(){return"".concat(P++)});function q(n){return!n||(w(n,"length")?o(n,0):"object"==typeof n&&o(Object.keys(n),0))}var F=t(q);n.StringObject=function(n){return new String(y(n))},n.asArray=p,n.assign=A,n.bindNot=t,n.bus=T,n.cache=function(n){void 0===n&&(n=1);var t=[],r=function(e,u){var i=r.get(e);if(i)return i[1];var o=u();return t.unshift([e.concat(),o]),a(t,n)&&(t.length=n),o};return r.invalidate=function(n){var r=e(n);r>-1&&t.splice(r,1)},r.get=function(n){return t[e(n)]||null},r;function e(n){return t.findIndex((function(t){var r=t[0];return o(n,r.length)&&n.every((function(n,t){return n===r[t]}))}))}},n.callEach=function(n){return n.forEach((function(n){return n()}))},n.defaultTo=b,n.deferThrow=function(n){setTimeout((function(){throw new Error(n)}),0)},n.either=function(n,t){return!!n!=!!t},n.greaterThan=c,n.hasOwnProperty=w,n.invariant=function(n,t){if(!n)throw t instanceof String?t.valueOf():new Error(t?y(t):t)},n.isArray=m,n.isBoolean=function(n){return!!n===n},n.isEmpty=q,n.isFunction=N,n.isNotArray=E,n.isNotEmpty=F,n.isNotNull=s,n.isNotNullish=g,n.isNotNumeric=e,n.isNotUndefined=h,n.isNull=l,n.isNullish=d,n.isNumeric=r,n.isPositive=function(n){return c(n,0)},n.isPromise=function(n){return n&&N(n.then)},n.isStringValue=function(n){return String(n)===n},n.isUndefined=v,n.last=O,n.lengthEquals=o,n.lengthNotEquals=f,n.longerThan=a,n.mapFirst=function(n,t){for(var r=!1,e=null,u=0;u<n.length;u++)if(t(n[u],i,u),r)return e;function i(n,t){n&&(r=!0,e=t)}},n.nestedArray=j,n.numberEquals=u,n.numberNotEquals=i,n.optionalFunctionValue=y,n.seq=S,Object.defineProperty(n,"__esModule",{value:!0})})); |
{ | ||
"version": "0.0.3-rc", | ||
"version": "0.0.3", | ||
"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(); |
@@ -1,2 +0,2 @@ | ||
import { CB } from 'utilityTypes'; | ||
import type { CB } from 'utilityTypes'; | ||
@@ -3,0 +3,0 @@ export function createBus(): { |
@@ -1,3 +0,5 @@ | ||
export default function callEach(arr: ((...args: any[]) => any)[]): void { | ||
import type { CB } from 'utilityTypes'; | ||
export default function callEach(arr: CB[]): void { | ||
return arr.forEach(fn => fn()); | ||
} |
@@ -1,3 +0,3 @@ | ||
declare let __DEV__: boolean; | ||
declare let __LIB_VERSION__: string; | ||
declare let LIBRARY_NAME: string; | ||
declare const __DEV__: boolean; | ||
declare const __LIB_VERSION__: string; | ||
declare const LIBRARY_NAME: string; |
import optionalFunctionValue from 'optionalFunctionValue'; | ||
import { Stringable } from 'utilityTypes'; | ||
import type { Stringable } from 'utilityTypes'; | ||
@@ -4,0 +4,0 @@ export default function invariant( |
@@ -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 @@ |
@@ -7,4 +7,4 @@ export type DropFirst<T extends unknown[]> = T extends [unknown, ...infer U] | ||
export type CB = (...args: any[]) => void; | ||
export type CB = (...args: any[]) => any; | ||
export type ValueOf<T> = T[keyof T]; |
export { default as cache } from 'cache'; | ||
export * as isNullish from 'isNullish'; | ||
export { isNullish, isNotNullish } from 'isNullish'; | ||
export * as nestedArray from 'nestedArray'; | ||
@@ -11,5 +11,4 @@ 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'; | ||
export { default as partition } from 'partition'; | ||
export { default as bindNot } from 'bindNot'; | ||
@@ -21,4 +20,19 @@ export { default as either } from 'either'; | ||
export * as bus from 'bus'; | ||
export { default as genId } from 'genId'; | ||
export { default as seq } from 'seq'; | ||
export { default as isFunction } from 'isFunction'; | ||
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'; | ||
export type { DropFirst } from 'utilityTypes'; | ||
export type { Stringable } from 'utilityTypes'; | ||
export type { CB } from 'utilityTypes'; | ||
export type { ValueOf } from 'utilityTypes'; |
{ | ||
"extends": "../../tsconfig.json", | ||
"rootDir": ".", | ||
"compilerOptions": { | ||
"noEmit": true | ||
"baseUrl": ".", | ||
"declarationMap": true, | ||
"declarationDir": "./types", | ||
"outDir": "./dist", | ||
"paths": { | ||
"asArray": ["src/asArray.ts"], | ||
"assign": ["src/assign.ts"], | ||
"bindNot": ["src/bindNot.ts"], | ||
"bus": ["src/bus.ts"], | ||
"cache": ["src/cache.ts"], | ||
"callEach": ["src/callEach.ts"], | ||
"defaultTo": ["src/defaultTo.ts"], | ||
"deferThrow": ["src/deferThrow.ts"], | ||
"either": ["src/either.ts"], | ||
"globals.d": ["src/globals.d.ts"], | ||
"greaterThan": ["src/greaterThan.ts"], | ||
"hasOwnProperty": ["src/hasOwnProperty.ts"], | ||
"invariant": ["src/invariant.ts"], | ||
"isArrayValue": ["src/isArrayValue.ts"], | ||
"isBooleanValue": ["src/isBooleanValue.ts"], | ||
"isEmpty": ["src/isEmpty.ts"], | ||
"isFunction": ["src/isFunction.ts"], | ||
"isNull": ["src/isNull.ts"], | ||
"isNullish": ["src/isNullish.ts"], | ||
"isNumeric": ["src/isNumeric.ts"], | ||
"isPositive": ["src/isPositive.ts"], | ||
"isPromise": ["src/isPromise.ts"], | ||
"isStringValue": ["src/isStringValue.ts"], | ||
"isUndefined": ["src/isUndefined.ts"], | ||
"last": ["src/last.ts"], | ||
"lengthEquals": ["src/lengthEquals.ts"], | ||
"longerThan": ["src/longerThan.ts"], | ||
"mapFirst": ["src/mapFirst.ts"], | ||
"nestedArray": ["src/nestedArray.ts"], | ||
"numberEquals": ["src/numberEquals.ts"], | ||
"optionalFunctionValue": ["src/optionalFunctionValue.ts"], | ||
"seq": ["src/seq.ts"], | ||
"utilityTypes": ["src/utilityTypes.ts"], | ||
"vest-utils": ["src/vest-utils.ts"] | ||
} | ||
} | ||
} |
@@ -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 { | ||
@@ -26,3 +24,10 @@ type NestedArray<T> = Array<NestedArray<T> | T>; | ||
declare function asArray<T>(possibleArg: T | T[]): T[]; | ||
declare function callEach(arr: ((...args: any[]) => any)[]): void; | ||
type DropFirst<T extends unknown[]> = T extends [ | ||
unknown, | ||
...infer U | ||
] ? U : never; | ||
type Stringable = string | ((...args: any[]) => string); | ||
type CB = (...args: any[]) => any; | ||
type ValueOf<T> = T[keyof T]; | ||
declare function callEach(arr: CB[]): void; | ||
/** | ||
@@ -35,18 +40,14 @@ * A safe hasOwnProperty access | ||
declare const _default: { | ||
<T, U>(target: T, source: U): T & U; | ||
<T_1, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V; | ||
<T_2, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W; | ||
<T extends {}, U>(target: T, source: U): T & U; | ||
<T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V; | ||
<T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W; | ||
(target: object, ...sources: any[]): any; | ||
}; | ||
declare function defaultTo<T>(value: T | ((...args: any[]) => T), defaultValue: T | (() => T)): T; | ||
type Stringable = string | ((...args: any[]) => string); | ||
type CB = (...args: any[]) => void; | ||
declare function invariant(condition: any, | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
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; | ||
declare function partition<T>(array: T[], predicate: (value: T, index: number, array: T[]) => boolean): [ | ||
T[], | ||
T[] | ||
]; | ||
declare function bindNot<T extends (...args: any[]) => unknown>(fn: T): (...args: Parameters<T>) => boolean; | ||
@@ -63,3 +64,3 @@ declare function either(a: unknown, b: unknown): boolean; | ||
type Stringable = string | ((...args: any[]) => string); | ||
type CB = (...args: any[]) => void; | ||
type CB = (...args: any[]) => any; | ||
type ValueOf<T> = T[keyof T]; | ||
@@ -77,5 +78,27 @@ function createBus(): { | ||
*/ | ||
declare const genId: () => string; | ||
declare const seq: () => string; | ||
declare function isFunction(value: unknown): value is (...args: unknown[]) => unknown; | ||
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, bindNot, either, isBoolean, last, deferThrow, bus, seq, isFunction, mapFirst, greaterThan, longerThan, isNumeric, isNotNumeric, lengthEquals, lengthNotEquals, numberEquals, numberNotEquals, isNull, isNotNull, isUndefined, isNotUndefined, isArray, isNotArray, isEmpty, isNotEmpty, isPositive }; | ||
export type { DropFirst, Stringable, CB, ValueOf }; | ||
//# sourceMappingURL=vest-utils.d.ts.map |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
82139
66
2080
0
0
6
0