@livechat/data-utils
Advanced tools
Comparing version 0.2.15 to 0.2.16
@@ -185,2 +185,21 @@ function add(first, second) { | ||
function mapKeys(mapper, obj) { | ||
return Object.keys(obj).reduce(function (acc, key) { | ||
if (obj[key] && typeof obj[key] === 'object') { | ||
if (Array.isArray(obj[key])) { | ||
acc[mapper(key)] = obj[key].map(function (el) { | ||
return mapKeys(mapper, el); | ||
}); | ||
return acc; | ||
} | ||
acc[mapper(key)] = mapKeys(mapper, obj[key]); | ||
return acc; | ||
} | ||
acc[mapper(key)] = obj[key]; | ||
return acc; | ||
}, {}); | ||
} | ||
function deepMerge(target) { | ||
@@ -411,3 +430,3 @@ for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
function mapKeys(mapper, obj) { | ||
function mapKeys$1(mapper, obj) { | ||
return Object.keys(obj).reduce(function (acc, key) { | ||
@@ -1039,2 +1058,2 @@ acc[mapper(key)] = obj[key]; | ||
export { add, assign, camelCase, capitalizeFirstLetter, chain, chunk, cloneDeep, compact, compose, debounce, deepMerge, defaultTo, drop, dropRight, ensureArray, entries, filledArray, find, findIndex, findKey, findLast, findLastIndex, findLastIndexFrom, flatMap, flatten, forOwn, fromPairs, generateRandomId, generateUniqueId, get, getOr, groupBy, groupKeys, hasOwn, identity, includes, isArray, isEmpty, isFalsy, isNil, isObject, isPromise, isTruthy, keyBy, keys, last, leadingThrottle, mapKeys, mapValues, mapValuesIndexed, memoize, memoizeOne, memoizeWith, merge, mergeAll, noop, numericSortBy, omit, omitBy, omitByIndexed, once, over, overArgs, pair, partitionObject, pick, pickBy, pickByIndexed, pickOwn, randomInt, range, reject, removeAt, repeat, set, shallowEqual, shortenLongText, shuffle, sign, sliceDiff, snakeCase, someAreTruthy, splitAt, splitRightWhenAccum, spread, stringCompare, sum, take, takeLast, takeRightWhile, takeRightWhileFrom, throttle, toArray, toFixedNumber, toPairs, trailingThrottle, trimEnd, trimStart, uniq, uniqBy, update, values, without, zip, zipWith }; | ||
export { add, assign, camelCase, capitalizeFirstLetter, chain, chunk, cloneDeep, compact, compose, debounce, mapKeys as deepMapKeys, deepMerge, defaultTo, drop, dropRight, ensureArray, entries, filledArray, find, findIndex, findKey, findLast, findLastIndex, findLastIndexFrom, flatMap, flatten, forOwn, fromPairs, generateRandomId, generateUniqueId, get, getOr, groupBy, groupKeys, hasOwn, identity, includes, isArray, isEmpty, isFalsy, isNil, isObject, isPromise, isTruthy, keyBy, keys, last, leadingThrottle, mapKeys$1 as mapKeys, mapValues, mapValuesIndexed, memoize, memoizeOne, memoizeWith, merge, mergeAll, noop, numericSortBy, omit, omitBy, omitByIndexed, once, over, overArgs, pair, partitionObject, pick, pickBy, pickByIndexed, pickOwn, randomInt, range, reject, removeAt, repeat, set, shallowEqual, shortenLongText, shuffle, sign, sliceDiff, snakeCase, someAreTruthy, splitAt, splitRightWhenAccum, spread, stringCompare, sum, take, takeLast, takeRightWhile, takeRightWhileFrom, throttle, toArray, toFixedNumber, toPairs, trailingThrottle, trimEnd, trimStart, uniq, uniqBy, update, values, without, zip, zipWith }; |
@@ -189,2 +189,21 @@ 'use strict'; | ||
function mapKeys(mapper, obj) { | ||
return Object.keys(obj).reduce(function (acc, key) { | ||
if (obj[key] && typeof obj[key] === 'object') { | ||
if (Array.isArray(obj[key])) { | ||
acc[mapper(key)] = obj[key].map(function (el) { | ||
return mapKeys(mapper, el); | ||
}); | ||
return acc; | ||
} | ||
acc[mapper(key)] = mapKeys(mapper, obj[key]); | ||
return acc; | ||
} | ||
acc[mapper(key)] = obj[key]; | ||
return acc; | ||
}, {}); | ||
} | ||
function deepMerge(target) { | ||
@@ -415,3 +434,3 @@ for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
function mapKeys(mapper, obj) { | ||
function mapKeys$1(mapper, obj) { | ||
return Object.keys(obj).reduce(function (acc, key) { | ||
@@ -1053,2 +1072,3 @@ acc[mapper(key)] = obj[key]; | ||
exports.debounce = debounce; | ||
exports.deepMapKeys = mapKeys; | ||
exports.deepMerge = deepMerge; | ||
@@ -1091,3 +1111,3 @@ exports.defaultTo = defaultTo; | ||
exports.leadingThrottle = leadingThrottle; | ||
exports.mapKeys = mapKeys; | ||
exports.mapKeys = mapKeys$1; | ||
exports.mapValues = mapValues; | ||
@@ -1094,0 +1114,0 @@ exports.mapValuesIndexed = mapValuesIndexed; |
@@ -191,2 +191,21 @@ (function (global, factory) { | ||
function mapKeys(mapper, obj) { | ||
return Object.keys(obj).reduce(function (acc, key) { | ||
if (obj[key] && typeof obj[key] === 'object') { | ||
if (Array.isArray(obj[key])) { | ||
acc[mapper(key)] = obj[key].map(function (el) { | ||
return mapKeys(mapper, el); | ||
}); | ||
return acc; | ||
} | ||
acc[mapper(key)] = mapKeys(mapper, obj[key]); | ||
return acc; | ||
} | ||
acc[mapper(key)] = obj[key]; | ||
return acc; | ||
}, {}); | ||
} | ||
function deepMerge(target) { | ||
@@ -417,3 +436,3 @@ for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
function mapKeys(mapper, obj) { | ||
function mapKeys$1(mapper, obj) { | ||
return Object.keys(obj).reduce(function (acc, key) { | ||
@@ -1055,2 +1074,3 @@ acc[mapper(key)] = obj[key]; | ||
exports.debounce = debounce; | ||
exports.deepMapKeys = mapKeys; | ||
exports.deepMerge = deepMerge; | ||
@@ -1093,3 +1113,3 @@ exports.defaultTo = defaultTo; | ||
exports.leadingThrottle = leadingThrottle; | ||
exports.mapKeys = mapKeys; | ||
exports.mapKeys = mapKeys$1; | ||
exports.mapValues = mapValues; | ||
@@ -1096,0 +1116,0 @@ exports.mapValuesIndexed = mapValuesIndexed; |
@@ -1,1 +0,1 @@ | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((n="undefined"!=typeof globalThis?globalThis:n||self).DataUtils={})}(this,(function(n){"use strict";function r(n,r){return n+r}var t={}.hasOwnProperty;function e(n,r){return t.call(r,n)}function u(){return(u=Object.assign||function(n){for(var r=arguments.length,t=Array(r>1?r-1:0),u=1;r>u;u++)t[u-1]=arguments[u];return t.forEach((function(r){for(var t in r)e(t,r)&&(n[t]=r[t])})),n}).apply(void 0,arguments)}function o(n,r){var t;return(t=[]).concat.apply(t,r.map(n))}var i=Array.isArray;function c(n){return"object"==typeof n&&null!==n&&!i(n)}function f(n,r){return Object.keys(r).reduce((function(t,e){return t[e]=n(r[e]),t}),{})}function a(n){return null==n}function l(n,r){for(var t=0;r.length>t;t++){var e=r[t];if(n(e))return e}}function s(n,r,t){for(var e=r;e>=0;e--)if(n(t[e]))return e;return-1}function p(n){return n}function y(n,r){return Object.keys(r).forEach((function(t){n(r[t],t)}))}function v(){return Math.random().toString(36).substring(2)}function d(n,r){for(var t="string"==typeof n?n.split("."):n,e=0,u=r;u&&t.length>e;)u=u[t[e++]];return u}function h(n){return 0===(i(n)?n:Object.keys(n)).length}function g(n,r){if(h(r))return n;var t={};return y((function(u,o){if(e(o,r))if(c(n[o])&&c(r[o]))t[o]=g(n[o],r[o]);else if(i(n[o])&&i(r[o])){var f=Math.max(n[o].length,r[o].length);t[o]=Array(f);for(var a=0;f>a;a++)a in r[o]?t[o][a]=r[o][a]:a in n[o]&&(t[o][a]=n[o][a])}else t[o]=r[o];else t[o]=n[o]}),n),y((function(n,u){e(u,t)||(t[u]=r[u])}),r),t}function m(n,r){var t={};return function(){var u=n.apply(void 0,arguments);if(e(u,t))return t[u];var o=r.apply(void 0,arguments);return t[u]=o,o}}function b(n){return Object.keys(n).map((function(r){return n[r]}))}function O(n,r){return Object.keys(r).reduce((function(t,e){return n(r[e],e)||(t[e]=r[e]),t}),{})}function j(n,r){return r.slice(-n)}function A(n,r){return[n,r]}function k(n,r){return Object.keys(r).reduce((function(t,e){return n(r[e],e)&&(t[e]=r[e]),t}),{})}function w(n,r){return n+Math.floor(Math.random()*(r-n+1))}function x(){return(x=Object.assign||function(n){for(var r=1;arguments.length>r;r++){var t=arguments[r];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])}return n}).apply(this,arguments)}function C(n,r){(null==r||r>n.length)&&(r=n.length);for(var t=0,e=Array(r);r>t;t++)e[t]=n[t];return e}function T(n,r){var t;if("undefined"==typeof Symbol||null==n[Symbol.iterator]){if(Array.isArray(n)||(t=function(n,r){if(n){if("string"==typeof n)return C(n,r);var t=Object.prototype.toString.call(n).slice(8,-1);return"Object"===t&&n.constructor&&(t=n.constructor.name),"Map"===t||"Set"===t?Array.from(n):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?C(n,r):void 0}}(n))||r&&n&&"number"==typeof n.length){t&&(n=t);var e=0;return function(){return n.length>e?{done:!1,value:n[e++]}:{done:!0}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=n[Symbol.iterator]()).next.bind(t)}function D(n,r){return n===r?0!==n||0!==r||1/n==1/r:n!=n&&r!=r}function I(n,r){return[r.slice(0,n),r.slice(n,r.length)]}function L(n,r,t){var e=s((function(r){return!n(r)}),r,t);return e===r?[]:t.slice(e+1,r+1)}var z=/^\s+/;var S=/\s+$/;function B(n,r){var t=[];return r.filter((function(r){var e=n(r);return-1===t.indexOf(e)&&(t.push(e),!0)}))}function M(n,r,t){return r.map((function(r,e){return n(r,t[e])}))}n.add=r,n.assign=u,n.camelCase=function(n){var r=n.trim();return 0===r.length?"":1===r.length?r.toLowerCase():/^[a-z\d]+$/.test(r)?r:(r!==r.toLowerCase()&&(r=function(n){for(var r=n,t=!1,e=!1,u=!1,o=0;r.length>o;o++){var i=r[o];t&&/[a-zA-Z]/.test(i)&&i.toUpperCase()===i?(r=r.slice(0,o)+"-"+r.slice(o),t=!1,u=e,e=!0,o++):e&&u&&/[a-zA-Z]/.test(i)&&i.toLowerCase()===i?(r=r.slice(0,o-1)+"-"+r.slice(o-1),u=e,e=!1,t=!0):(t=i.toLowerCase()===i,u=e,e=i.toUpperCase()===i)}return r}(r)),r=r.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(function(n,r){return r.toUpperCase()})))},n.capitalizeFirstLetter=function(n){return n.charAt(0).toUpperCase()+n.slice(1)},n.chain=function(n,r){return"function"==typeof r?function(t){return n(r(t))(t)}:o(n,r)},n.chunk=function(n,r){for(var t=[],e=0;n.length>e;e+=r)t.push(n.slice(e,e+r));return t},n.cloneDeep=function n(r){return i(r)?r.map(n):c(r)?f(n,r):r},n.compact=function(n){return i(n)?n.filter((function(n){return null!=n})):Object.keys(n).reduce((function(r,t){var e=n[t];return null!=e&&(r[t]=e),r}),{})},n.compose=function(){for(var n=arguments.length,r=Array(n),t=0;n>t;t++)r[t]=arguments[t];return r.reduce((function(n,r){return function(){return n(r.apply(void 0,arguments))}}))},n.debounce=function(n,r){var t;return function(){clearTimeout(t);for(var e=arguments.length,u=Array(e),o=0;e>o;o++)u[o]=arguments[o];t=setTimeout.apply(void 0,[r,n].concat(u))}},n.deepMerge=function n(r){for(var t=arguments.length,e=Array(t>1?t-1:0),u=1;t>u;u++)e[u-1]=arguments[u];if(!e.length)return r;var o=e.shift();if(c(r)&&c(o))for(var i in o){var f,a;if(c(o[i]))r[i]||Object.assign(r,((f={})[i]={},f)),n(r[i],o[i]);else Object.assign(r,((a={})[i]=o[i],a))}return n.apply(void 0,[r].concat(e))},n.defaultTo=function(n){return function(r){return a(r)?n:r}},n.drop=function(n,r){return r.slice(n)},n.dropRight=function(n,r){return r.slice(0,-n)},n.ensureArray=function(n){return i(n)?n:[n]},n.entries=function(n){return Object.keys(n).map((function(r){return[r,n[r]]}))},n.filledArray=function(n,r){for(var t=[];n--;)t.push(r);return t},n.find=l,n.findIndex=function(n,r){for(var t=0;r.length>t;t++)if(n(r[t]))return t;return-1},n.findKey=function(n,r){return l((function(t){return n(r[t])}),Object.keys(r))},n.findLast=function(n,r){for(var t=r.length-1;t>=0;t--)if(n(r[t]))return r[t]},n.findLastIndex=function(n,r){return s(n,r.length-1,r)},n.findLastIndexFrom=s,n.flatMap=o,n.flatten=function(n){return o(p,n)},n.forOwn=y,n.fromPairs=function(n){return n.reduce((function(n,r){return n[r[0]]=r[1],n}),{})},n.generateRandomId=v,n.generateUniqueId=function n(r){var t=v();return e(t,r)?n(r):t},n.get=d,n.getOr=function(n,r,t){var e=d(r,t);return null!=e?e:n},n.groupBy=function(n,r){return Object.keys(r).reduce((function(t,e){var u=r[e],o=n(u);return t[o]=t[o]||[],t[o].push(u),t}),{})},n.groupKeys=function(n,r){return Object.keys(r).reduce((function(t,e){var u=n(e);return t[u]=t[u]||{},t[u][e]=r[e],t}),{})},n.hasOwn=e,n.identity=p,n.includes=function(n,r){return-1!==r.indexOf(n)},n.isArray=i,n.isEmpty=h,n.isFalsy=function(n){return!n},n.isNil=a,n.isObject=c,n.isPromise=function(n){return!!n&&"function"==typeof n.then},n.isTruthy=function(n){return!!n},n.keyBy=function(n,r){return r.reduce((function(r,t){return r[t[n]]=t,r}),{})},n.keys=function(n){var r=[];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&r.push(t);return r},n.last=function(n){return n.length>0?n[n.length-1]:null},n.leadingThrottle=function(n,r){var t=0;return function(){var e=Date.now();n>e-t||(t=Date.now(),r.apply(void 0,arguments))}},n.mapKeys=function(n,r){return Object.keys(r).reduce((function(t,e){return t[n(e)]=r[e],t}),{})},n.mapValues=f,n.mapValuesIndexed=function(n,r){return Object.keys(r).reduce((function(t,e){return t[e]=n(r[e],e),t}),{})},n.memoize=function(n){return m(p,n)},n.memoizeOne=function(n){var r,t,e=!1;return function(){return e&&(arguments.length>0?arguments[0]:void 0)===t?r:(e=!0,t=arguments.length>0?arguments[0]:void 0,r=n.apply(void 0,arguments))}},n.memoizeWith=m,n.merge=g,n.mergeAll=function(n){if(0===n.length)return{};var r=n[0];return n.slice(1).reduce((function(n,r){return g(n,r)}),r)},n.noop=function(){},n.numericSortBy=function(n,r){var t="function"==typeof n?n:function(r){return d(n,r)};return(i(r)?[].concat(r):b(r)).sort((function(n,r){return t(n)-t(r)}))},n.omit=function(n,r){return O((function(r,t){return-1!==n.indexOf(t)}),r)},n.omitBy=function(n,r){return Object.keys(r).reduce((function(t,e){return n(r[e])||(t[e]=r[e]),t}),{})},n.omitByIndexed=O,n.once=function(n){var r,t=!1;return function(){return t?r:(t=!0,r=n.apply(void 0,arguments))}},n.over=function(n){return function(){for(var r=arguments.length,t=Array(r),e=0;r>e;e++)t[e]=arguments[e];return n.map((function(n){return n.apply(void 0,t)}))}},n.overArgs=function(n,r){return function(){for(var t=arguments.length,e=Array(t),u=0;t>u;u++)e[u]=arguments[u];var o=r.map((function(n,r){return n(e[r])}));return n.apply(void 0,e.length>o.length?o.concat(j(e.length-o.length,e)):o)}},n.pair=A,n.partitionObject=function(n,r){return Object.keys(r).reduce((function(t,e){return t[n(r[e])?0:1][e]=r[e],t}),[{},{}])},n.pick=function(n,r){return n.reduce((function(n,t){return n[t]=r[t],n}),{})},n.pickBy=function(n,r){return Object.keys(r).reduce((function(t,e){return n(r[e])&&(t[e]=r[e]),t}),{})},n.pickByIndexed=k,n.pickOwn=function(n,r){return n.reduce((function(n,t){return e(t,r)&&(n[t]=r[t]),n}),{})},n.randomInt=w,n.range=function(n){for(var r=[],t=0;n>=t;)r.push(t++);return r},n.reject=function(n,r){return r.filter((function(r){return!n(r)}))},n.removeAt=function(n,r){var t=[].concat(r);return t.splice(n,1),t},n.repeat=function(n,r){return Array(n+1).join(r)},n.set=function n(r,t,u){var o,i=r.split?r.split("."):r,c=i[0],f=t;if(i.length>1){var a=null!=u&&e(c,u)?u[c]:{};f=n(i.slice(1),t,a)}return x({},u,((o={})[c]=f,o))},n.shallowEqual=function(n,r){if(D(n,r))return!0;if("object"!=typeof n||null===n||"object"!=typeof r||null===r)return!1;var t=Object.keys(n);if(t.length!==Object.keys(r).length)return!1;for(var u=0;t.length>u;u++)if(!e(t[u],r)||!D(n[t[u]],r[t[u]]))return!1;return!0},n.shortenLongText=function(n,r){if(n>=r.length)return r;for(var t,e=[],u=0,o=T(r.split(" "));!(t=o()).done;){var i=t.value;if(u+i.length>n)break;u+=i.length+1,e.push(i)}return e.join(" ")+"..."},n.shuffle=function(n){for(var r=n.slice(),t=n.length-1,e=0;n.length>e;e++){var u=w(e,t),o=r[u];r[u]=r[e],r[e]=o}return r},n.sign=function(n){return"number"!=typeof n||isNaN(n)?NaN:0===n?0:-0===n?-0:n>0?1:-1},n.sliceDiff=function(n,r){var t=k((function(n,t){return n!==r[t]}),n);return h(t)?null:t},n.snakeCase=function(n){var r=n.replace(/[A-Z]|([-_ ]+)/g,(function(n){var r=n.charCodeAt(0);return r>64&&91>r?"_"+n.toLowerCase():"_"}));return"_"===r[0]?r.substr(1):r},n.someAreTruthy=function(n){return n.some(p)},n.splitAt=I,n.splitRightWhenAccum=function(n,r,t){for(var e=t.length;e>0;e--){var u=n(t[e-1],r);if(r=u[1],u[0])return I(e-1,t)}return[[],t]},n.spread=function(n){return function(r){return n.apply(void 0,r)}},n.stringCompare=function(n,r){return n===r?0:r>n?-1:1},n.sum=function(n){return n.reduce(r,0)},n.take=function(n,r){return r.slice(0,n)},n.takeLast=j,n.takeRightWhile=function(n,r){return L(n,r.length-1,r)},n.takeRightWhileFrom=L,n.throttle=function(n,r){var t,e=Date.now()-2*n,u=function(){e=Date.now(),r.apply(void 0,arguments)};return function(){for(var r=Date.now(),o=arguments.length,i=Array(o),c=0;o>c;c++)i[c]=arguments[c];n>r-e?(clearTimeout(t),t=setTimeout.apply(void 0,[u,e-r+n].concat(i))):u.apply(void 0,i)}},n.toArray=function(n){return Array.prototype.slice.call(n)},n.toFixedNumber=function(n,r){return Number(n.toFixed(r))},n.toPairs=function(n){return Object.keys(n).map((function(r){return[r,n[r]]}))},n.trailingThrottle=function(n,r){var t,e=Date.now()-2*n,u=function(){return e=Date.now(),r.apply(void 0,arguments)};return function(){var r=Date.now();n>r-e||(e=Date.now()),clearTimeout(t);for(var o=arguments.length,i=Array(o),c=0;o>c;c++)i[c]=arguments[c];t=setTimeout.apply(void 0,[u,e-r+n].concat(i))}},n.trimEnd=function(n){return n.replace(S,"")},n.trimStart=function(n){return n.replace(z,"")},n.uniq=function(n){return B(p,n)},n.uniqBy=B,n.update=function(n,r,t){return[].concat(t.slice(0,n),[r],t.slice(n+1,t.length))},n.values=b,n.without=function(n,r){return r.filter((function(r){return-1===n.indexOf(r)}))},n.zip=function(n,r){return M(A,n,r)},n.zipWith=M,Object.defineProperty(n,"__esModule",{value:!0})})); | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((n="undefined"!=typeof globalThis?globalThis:n||self).DataUtils={})}(this,(function(n){"use strict";function r(n,r){return n+r}var t={}.hasOwnProperty;function e(n,r){return t.call(r,n)}function u(){return(u=Object.assign||function(n){for(var r=arguments.length,t=Array(r>1?r-1:0),u=1;r>u;u++)t[u-1]=arguments[u];return t.forEach((function(r){for(var t in r)e(t,r)&&(n[t]=r[t])})),n}).apply(void 0,arguments)}function o(n,r){var t;return(t=[]).concat.apply(t,r.map(n))}var i=Array.isArray;function c(n){return"object"==typeof n&&null!==n&&!i(n)}function f(n,r){return Object.keys(r).reduce((function(t,e){return t[e]=n(r[e]),t}),{})}function a(n){return null==n}function l(n,r){for(var t=0;r.length>t;t++){var e=r[t];if(n(e))return e}}function s(n,r,t){for(var e=r;e>=0;e--)if(n(t[e]))return e;return-1}function p(n){return n}function y(n,r){return Object.keys(r).forEach((function(t){n(r[t],t)}))}function v(){return Math.random().toString(36).substring(2)}function d(n,r){for(var t="string"==typeof n?n.split("."):n,e=0,u=r;u&&t.length>e;)u=u[t[e++]];return u}function h(n){return 0===(i(n)?n:Object.keys(n)).length}function g(n,r){if(h(r))return n;var t={};return y((function(u,o){if(e(o,r))if(c(n[o])&&c(r[o]))t[o]=g(n[o],r[o]);else if(i(n[o])&&i(r[o])){var f=Math.max(n[o].length,r[o].length);t[o]=Array(f);for(var a=0;f>a;a++)a in r[o]?t[o][a]=r[o][a]:a in n[o]&&(t[o][a]=n[o][a])}else t[o]=r[o];else t[o]=n[o]}),n),y((function(n,u){e(u,t)||(t[u]=r[u])}),r),t}function m(n,r){var t={};return function(){var u=n.apply(void 0,arguments);if(e(u,t))return t[u];var o=r.apply(void 0,arguments);return t[u]=o,o}}function b(n){return Object.keys(n).map((function(r){return n[r]}))}function O(n,r){return Object.keys(r).reduce((function(t,e){return n(r[e],e)||(t[e]=r[e]),t}),{})}function j(n,r){return r.slice(-n)}function A(n,r){return[n,r]}function k(n,r){return Object.keys(r).reduce((function(t,e){return n(r[e],e)&&(t[e]=r[e]),t}),{})}function w(n,r){return n+Math.floor(Math.random()*(r-n+1))}function x(){return(x=Object.assign||function(n){for(var r=1;arguments.length>r;r++){var t=arguments[r];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])}return n}).apply(this,arguments)}function C(n,r){(null==r||r>n.length)&&(r=n.length);for(var t=0,e=Array(r);r>t;t++)e[t]=n[t];return e}function T(n,r){var t;if("undefined"==typeof Symbol||null==n[Symbol.iterator]){if(Array.isArray(n)||(t=function(n,r){if(n){if("string"==typeof n)return C(n,r);var t=Object.prototype.toString.call(n).slice(8,-1);return"Object"===t&&n.constructor&&(t=n.constructor.name),"Map"===t||"Set"===t?Array.from(n):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?C(n,r):void 0}}(n))||r&&n&&"number"==typeof n.length){t&&(n=t);var e=0;return function(){return n.length>e?{done:!1,value:n[e++]}:{done:!0}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=n[Symbol.iterator]()).next.bind(t)}function D(n,r){return n===r?0!==n||0!==r||1/n==1/r:n!=n&&r!=r}function I(n,r){return[r.slice(0,n),r.slice(n,r.length)]}function L(n,r,t){var e=s((function(r){return!n(r)}),r,t);return e===r?[]:t.slice(e+1,r+1)}var z=/^\s+/;var M=/\s+$/;function S(n,r){var t=[];return r.filter((function(r){var e=n(r);return-1===t.indexOf(e)&&(t.push(e),!0)}))}function B(n,r,t){return r.map((function(r,e){return n(r,t[e])}))}n.add=r,n.assign=u,n.camelCase=function(n){var r=n.trim();return 0===r.length?"":1===r.length?r.toLowerCase():/^[a-z\d]+$/.test(r)?r:(r!==r.toLowerCase()&&(r=function(n){for(var r=n,t=!1,e=!1,u=!1,o=0;r.length>o;o++){var i=r[o];t&&/[a-zA-Z]/.test(i)&&i.toUpperCase()===i?(r=r.slice(0,o)+"-"+r.slice(o),t=!1,u=e,e=!0,o++):e&&u&&/[a-zA-Z]/.test(i)&&i.toLowerCase()===i?(r=r.slice(0,o-1)+"-"+r.slice(o-1),u=e,e=!1,t=!0):(t=i.toLowerCase()===i,u=e,e=i.toUpperCase()===i)}return r}(r)),r=r.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(function(n,r){return r.toUpperCase()})))},n.capitalizeFirstLetter=function(n){return n.charAt(0).toUpperCase()+n.slice(1)},n.chain=function(n,r){return"function"==typeof r?function(t){return n(r(t))(t)}:o(n,r)},n.chunk=function(n,r){for(var t=[],e=0;n.length>e;e+=r)t.push(n.slice(e,e+r));return t},n.cloneDeep=function n(r){return i(r)?r.map(n):c(r)?f(n,r):r},n.compact=function(n){return i(n)?n.filter((function(n){return null!=n})):Object.keys(n).reduce((function(r,t){var e=n[t];return null!=e&&(r[t]=e),r}),{})},n.compose=function(){for(var n=arguments.length,r=Array(n),t=0;n>t;t++)r[t]=arguments[t];return r.reduce((function(n,r){return function(){return n(r.apply(void 0,arguments))}}))},n.debounce=function(n,r){var t;return function(){clearTimeout(t);for(var e=arguments.length,u=Array(e),o=0;e>o;o++)u[o]=arguments[o];t=setTimeout.apply(void 0,[r,n].concat(u))}},n.deepMapKeys=function n(r,t){return Object.keys(t).reduce((function(e,u){return t[u]&&"object"==typeof t[u]?Array.isArray(t[u])?(e[r(u)]=t[u].map((function(t){return n(r,t)})),e):(e[r(u)]=n(r,t[u]),e):(e[r(u)]=t[u],e)}),{})},n.deepMerge=function n(r){for(var t=arguments.length,e=Array(t>1?t-1:0),u=1;t>u;u++)e[u-1]=arguments[u];if(!e.length)return r;var o=e.shift();if(c(r)&&c(o))for(var i in o){var f,a;if(c(o[i]))r[i]||Object.assign(r,((f={})[i]={},f)),n(r[i],o[i]);else Object.assign(r,((a={})[i]=o[i],a))}return n.apply(void 0,[r].concat(e))},n.defaultTo=function(n){return function(r){return a(r)?n:r}},n.drop=function(n,r){return r.slice(n)},n.dropRight=function(n,r){return r.slice(0,-n)},n.ensureArray=function(n){return i(n)?n:[n]},n.entries=function(n){return Object.keys(n).map((function(r){return[r,n[r]]}))},n.filledArray=function(n,r){for(var t=[];n--;)t.push(r);return t},n.find=l,n.findIndex=function(n,r){for(var t=0;r.length>t;t++)if(n(r[t]))return t;return-1},n.findKey=function(n,r){return l((function(t){return n(r[t])}),Object.keys(r))},n.findLast=function(n,r){for(var t=r.length-1;t>=0;t--)if(n(r[t]))return r[t]},n.findLastIndex=function(n,r){return s(n,r.length-1,r)},n.findLastIndexFrom=s,n.flatMap=o,n.flatten=function(n){return o(p,n)},n.forOwn=y,n.fromPairs=function(n){return n.reduce((function(n,r){return n[r[0]]=r[1],n}),{})},n.generateRandomId=v,n.generateUniqueId=function n(r){var t=v();return e(t,r)?n(r):t},n.get=d,n.getOr=function(n,r,t){var e=d(r,t);return null!=e?e:n},n.groupBy=function(n,r){return Object.keys(r).reduce((function(t,e){var u=r[e],o=n(u);return t[o]=t[o]||[],t[o].push(u),t}),{})},n.groupKeys=function(n,r){return Object.keys(r).reduce((function(t,e){var u=n(e);return t[u]=t[u]||{},t[u][e]=r[e],t}),{})},n.hasOwn=e,n.identity=p,n.includes=function(n,r){return-1!==r.indexOf(n)},n.isArray=i,n.isEmpty=h,n.isFalsy=function(n){return!n},n.isNil=a,n.isObject=c,n.isPromise=function(n){return!!n&&"function"==typeof n.then},n.isTruthy=function(n){return!!n},n.keyBy=function(n,r){return r.reduce((function(r,t){return r[t[n]]=t,r}),{})},n.keys=function(n){var r=[];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&r.push(t);return r},n.last=function(n){return n.length>0?n[n.length-1]:null},n.leadingThrottle=function(n,r){var t=0;return function(){var e=Date.now();n>e-t||(t=Date.now(),r.apply(void 0,arguments))}},n.mapKeys=function(n,r){return Object.keys(r).reduce((function(t,e){return t[n(e)]=r[e],t}),{})},n.mapValues=f,n.mapValuesIndexed=function(n,r){return Object.keys(r).reduce((function(t,e){return t[e]=n(r[e],e),t}),{})},n.memoize=function(n){return m(p,n)},n.memoizeOne=function(n){var r,t,e=!1;return function(){return e&&(arguments.length>0?arguments[0]:void 0)===t?r:(e=!0,t=arguments.length>0?arguments[0]:void 0,r=n.apply(void 0,arguments))}},n.memoizeWith=m,n.merge=g,n.mergeAll=function(n){if(0===n.length)return{};var r=n[0];return n.slice(1).reduce((function(n,r){return g(n,r)}),r)},n.noop=function(){},n.numericSortBy=function(n,r){var t="function"==typeof n?n:function(r){return d(n,r)};return(i(r)?[].concat(r):b(r)).sort((function(n,r){return t(n)-t(r)}))},n.omit=function(n,r){return O((function(r,t){return-1!==n.indexOf(t)}),r)},n.omitBy=function(n,r){return Object.keys(r).reduce((function(t,e){return n(r[e])||(t[e]=r[e]),t}),{})},n.omitByIndexed=O,n.once=function(n){var r,t=!1;return function(){return t?r:(t=!0,r=n.apply(void 0,arguments))}},n.over=function(n){return function(){for(var r=arguments.length,t=Array(r),e=0;r>e;e++)t[e]=arguments[e];return n.map((function(n){return n.apply(void 0,t)}))}},n.overArgs=function(n,r){return function(){for(var t=arguments.length,e=Array(t),u=0;t>u;u++)e[u]=arguments[u];var o=r.map((function(n,r){return n(e[r])}));return n.apply(void 0,e.length>o.length?o.concat(j(e.length-o.length,e)):o)}},n.pair=A,n.partitionObject=function(n,r){return Object.keys(r).reduce((function(t,e){return t[n(r[e])?0:1][e]=r[e],t}),[{},{}])},n.pick=function(n,r){return n.reduce((function(n,t){return n[t]=r[t],n}),{})},n.pickBy=function(n,r){return Object.keys(r).reduce((function(t,e){return n(r[e])&&(t[e]=r[e]),t}),{})},n.pickByIndexed=k,n.pickOwn=function(n,r){return n.reduce((function(n,t){return e(t,r)&&(n[t]=r[t]),n}),{})},n.randomInt=w,n.range=function(n){for(var r=[],t=0;n>=t;)r.push(t++);return r},n.reject=function(n,r){return r.filter((function(r){return!n(r)}))},n.removeAt=function(n,r){var t=[].concat(r);return t.splice(n,1),t},n.repeat=function(n,r){return Array(n+1).join(r)},n.set=function n(r,t,u){var o,i=r.split?r.split("."):r,c=i[0],f=t;if(i.length>1){var a=null!=u&&e(c,u)?u[c]:{};f=n(i.slice(1),t,a)}return x({},u,((o={})[c]=f,o))},n.shallowEqual=function(n,r){if(D(n,r))return!0;if("object"!=typeof n||null===n||"object"!=typeof r||null===r)return!1;var t=Object.keys(n);if(t.length!==Object.keys(r).length)return!1;for(var u=0;t.length>u;u++)if(!e(t[u],r)||!D(n[t[u]],r[t[u]]))return!1;return!0},n.shortenLongText=function(n,r){if(n>=r.length)return r;for(var t,e=[],u=0,o=T(r.split(" "));!(t=o()).done;){var i=t.value;if(u+i.length>n)break;u+=i.length+1,e.push(i)}return e.join(" ")+"..."},n.shuffle=function(n){for(var r=n.slice(),t=n.length-1,e=0;n.length>e;e++){var u=w(e,t),o=r[u];r[u]=r[e],r[e]=o}return r},n.sign=function(n){return"number"!=typeof n||isNaN(n)?NaN:0===n?0:-0===n?-0:n>0?1:-1},n.sliceDiff=function(n,r){var t=k((function(n,t){return n!==r[t]}),n);return h(t)?null:t},n.snakeCase=function(n){var r=n.replace(/[A-Z]|([-_ ]+)/g,(function(n){var r=n.charCodeAt(0);return r>64&&91>r?"_"+n.toLowerCase():"_"}));return"_"===r[0]?r.substr(1):r},n.someAreTruthy=function(n){return n.some(p)},n.splitAt=I,n.splitRightWhenAccum=function(n,r,t){for(var e=t.length;e>0;e--){var u=n(t[e-1],r);if(r=u[1],u[0])return I(e-1,t)}return[[],t]},n.spread=function(n){return function(r){return n.apply(void 0,r)}},n.stringCompare=function(n,r){return n===r?0:r>n?-1:1},n.sum=function(n){return n.reduce(r,0)},n.take=function(n,r){return r.slice(0,n)},n.takeLast=j,n.takeRightWhile=function(n,r){return L(n,r.length-1,r)},n.takeRightWhileFrom=L,n.throttle=function(n,r){var t,e=Date.now()-2*n,u=function(){e=Date.now(),r.apply(void 0,arguments)};return function(){for(var r=Date.now(),o=arguments.length,i=Array(o),c=0;o>c;c++)i[c]=arguments[c];n>r-e?(clearTimeout(t),t=setTimeout.apply(void 0,[u,e-r+n].concat(i))):u.apply(void 0,i)}},n.toArray=function(n){return Array.prototype.slice.call(n)},n.toFixedNumber=function(n,r){return Number(n.toFixed(r))},n.toPairs=function(n){return Object.keys(n).map((function(r){return[r,n[r]]}))},n.trailingThrottle=function(n,r){var t,e=Date.now()-2*n,u=function(){return e=Date.now(),r.apply(void 0,arguments)};return function(){var r=Date.now();n>r-e||(e=Date.now()),clearTimeout(t);for(var o=arguments.length,i=Array(o),c=0;o>c;c++)i[c]=arguments[c];t=setTimeout.apply(void 0,[u,e-r+n].concat(i))}},n.trimEnd=function(n){return n.replace(M,"")},n.trimStart=function(n){return n.replace(z,"")},n.uniq=function(n){return S(p,n)},n.uniqBy=S,n.update=function(n,r,t){return[].concat(t.slice(0,n),[r],t.slice(n+1,t.length))},n.values=b,n.without=function(n,r){return r.filter((function(r){return-1===n.indexOf(r)}))},n.zip=function(n,r){return B(A,n,r)},n.zipWith=B,Object.defineProperty(n,"__esModule",{value:!0})})); |
{ | ||
"name": "@livechat/data-utils", | ||
"version": "0.2.15", | ||
"version": "0.2.16", | ||
"description": "Collections utility functions", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -11,2 +11,3 @@ export { default as add } from './add'; | ||
export { default as debounce } from './debounce'; | ||
export { default as deepMapKeys } from './deepMapKeys'; | ||
export { default as deepMerge } from './deepMerge'; | ||
@@ -13,0 +14,0 @@ export { default as defaultTo } from './defaultTo'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
109913
73
3004