@livechat/data-utils
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -58,2 +58,8 @@ var _ref = {}, | ||
function camelCase(text) { | ||
return text.replace(/^[_.\- ]+/, '').toLowerCase().replace(/[_.\- ]+(\w|$)/g, function (__, p1) { | ||
return p1.toUpperCase(); | ||
}); | ||
} | ||
function compact(collection) { | ||
@@ -68,2 +74,14 @@ return isArray(collection) ? collection.filter(Boolean) : Object.keys(collection).reduce(function (result, key) { | ||
function compose() { | ||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { | ||
funcs[_key] = arguments[_key]; | ||
} | ||
return funcs.reduce(function (composed, next) { | ||
return function () { | ||
return composed(next.apply(undefined, arguments)); | ||
}; | ||
}); | ||
} | ||
function dropRight(count, arr) { | ||
@@ -102,4 +120,4 @@ return arr.slice(0, -count); | ||
function findLastIndex(predicate, arr) { | ||
for (var index = arr.length - 1; index >= 0; index--) { | ||
function findLastIndexFrom(predicate, startIndex, arr) { | ||
for (var index = startIndex; index >= 0; index--) { | ||
if (predicate(arr[index])) { | ||
@@ -113,2 +131,6 @@ return index; | ||
function findLastIndex(predicate, arr) { | ||
return findLastIndexFrom(predicate, arr.length - 1, arr); | ||
} | ||
function flatMap(iteratee, arr) { | ||
@@ -381,2 +403,8 @@ var _ref; | ||
function reject(predicate, arr) { | ||
return arr.filter(function (element) { | ||
return !predicate(element); | ||
}); | ||
} | ||
function removeAt(index, arr) { | ||
@@ -388,2 +416,33 @@ var copy = [].concat(arr); | ||
// https://github.com/reactjs/react-redux/blob/5d792a283554cff3d2f54fad1be1f79cbcab33fe/src/utils/shallowEqual.js | ||
function is(first, second) { | ||
if (first === second) { | ||
return first !== 0 || second !== 0 || 1 / first === 1 / second; | ||
} | ||
// eslint-disable-next-line no-self-compare | ||
return first !== first && second !== second; | ||
} | ||
function shallowEqual(objA, objB) { | ||
if (is(objA, objB)) return true; | ||
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) { | ||
return false; | ||
} | ||
var keysA = Object.keys(objA); | ||
var keysB = Object.keys(objB); | ||
if (keysA.length !== keysB.length) return false; | ||
for (var index = 0; index < keysA.length; index++) { | ||
if (!hasOwn(keysA[index], objB) || !is(objA[keysA[index]], objB[keysA[index]])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function splitAt(splitPoint, arr) { | ||
@@ -414,2 +473,9 @@ // TODO first item from the tuple could be replaced by dropRight | ||
function takeRightWhileFrom(predicate, startIndex, arr) { | ||
var endIndex = findLastIndexFrom(function (element) { | ||
return !predicate(element); | ||
}, startIndex, arr); | ||
return endIndex === startIndex ? [] : arr.slice(endIndex + 1, startIndex + 1); | ||
} | ||
function throttle(ms, fn) { | ||
@@ -479,2 +545,2 @@ var lastCall = Date.now() - 2 * ms; | ||
export { assign, cloneDeep, compact, dropRight, find, findIndex, findLast, findLastIndex, flatMap, flatten, forOwn, fromPairs, generateRandomId, generateUniqueId, get$1 as get, getOr, groupBy, groupKeys, hasOwn, identity, includes, isArray, isEmpty, isObject, keyBy, last, mapKeys, mapValues, mapValuesIndexed, merge, mergeAll, memoize, memoize$1 as memoizeOne, noop, numericSortBy, omit, omitBy, omitByIndexed, once, pick, pickBy, pickByIndexed, pickOwn, removeAt, splitAt, splitRightWhenAccum, throttle, toPairs, trimStart, trimEnd, uniq, values, without }; | ||
export { assign, cloneDeep, camelCase, compact, compose, dropRight, find, findIndex, findLast, findLastIndex, findLastIndexFrom, flatMap, flatten, forOwn, fromPairs, generateRandomId, generateUniqueId, get$1 as get, getOr, groupBy, groupKeys, hasOwn, identity, includes, isArray, isEmpty, isObject, keyBy, last, mapKeys, mapValues, mapValuesIndexed, merge, mergeAll, memoize, memoize$1 as memoizeOne, noop, numericSortBy, omit, omitBy, omitByIndexed, once, pick, pickBy, pickByIndexed, pickOwn, reject, removeAt, shallowEqual, splitAt, splitRightWhenAccum, takeRightWhileFrom, throttle, toPairs, trimStart, trimEnd, uniq, values, without }; |
@@ -62,2 +62,8 @@ 'use strict'; | ||
function camelCase(text) { | ||
return text.replace(/^[_.\- ]+/, '').toLowerCase().replace(/[_.\- ]+(\w|$)/g, function (__, p1) { | ||
return p1.toUpperCase(); | ||
}); | ||
} | ||
function compact(collection) { | ||
@@ -72,2 +78,14 @@ return isArray(collection) ? collection.filter(Boolean) : Object.keys(collection).reduce(function (result, key) { | ||
function compose() { | ||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { | ||
funcs[_key] = arguments[_key]; | ||
} | ||
return funcs.reduce(function (composed, next) { | ||
return function () { | ||
return composed(next.apply(undefined, arguments)); | ||
}; | ||
}); | ||
} | ||
function dropRight(count, arr) { | ||
@@ -106,4 +124,4 @@ return arr.slice(0, -count); | ||
function findLastIndex(predicate, arr) { | ||
for (var index = arr.length - 1; index >= 0; index--) { | ||
function findLastIndexFrom(predicate, startIndex, arr) { | ||
for (var index = startIndex; index >= 0; index--) { | ||
if (predicate(arr[index])) { | ||
@@ -117,2 +135,6 @@ return index; | ||
function findLastIndex(predicate, arr) { | ||
return findLastIndexFrom(predicate, arr.length - 1, arr); | ||
} | ||
function flatMap(iteratee, arr) { | ||
@@ -385,2 +407,8 @@ var _ref; | ||
function reject(predicate, arr) { | ||
return arr.filter(function (element) { | ||
return !predicate(element); | ||
}); | ||
} | ||
function removeAt(index, arr) { | ||
@@ -392,2 +420,33 @@ var copy = [].concat(arr); | ||
// https://github.com/reactjs/react-redux/blob/5d792a283554cff3d2f54fad1be1f79cbcab33fe/src/utils/shallowEqual.js | ||
function is(first, second) { | ||
if (first === second) { | ||
return first !== 0 || second !== 0 || 1 / first === 1 / second; | ||
} | ||
// eslint-disable-next-line no-self-compare | ||
return first !== first && second !== second; | ||
} | ||
function shallowEqual(objA, objB) { | ||
if (is(objA, objB)) return true; | ||
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) { | ||
return false; | ||
} | ||
var keysA = Object.keys(objA); | ||
var keysB = Object.keys(objB); | ||
if (keysA.length !== keysB.length) return false; | ||
for (var index = 0; index < keysA.length; index++) { | ||
if (!hasOwn(keysA[index], objB) || !is(objA[keysA[index]], objB[keysA[index]])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function splitAt(splitPoint, arr) { | ||
@@ -418,2 +477,9 @@ // TODO first item from the tuple could be replaced by dropRight | ||
function takeRightWhileFrom(predicate, startIndex, arr) { | ||
var endIndex = findLastIndexFrom(function (element) { | ||
return !predicate(element); | ||
}, startIndex, arr); | ||
return endIndex === startIndex ? [] : arr.slice(endIndex + 1, startIndex + 1); | ||
} | ||
function throttle(ms, fn) { | ||
@@ -485,3 +551,5 @@ var lastCall = Date.now() - 2 * ms; | ||
exports.cloneDeep = cloneDeep; | ||
exports.camelCase = camelCase; | ||
exports.compact = compact; | ||
exports.compose = compose; | ||
exports.dropRight = dropRight; | ||
@@ -492,2 +560,3 @@ exports.find = find; | ||
exports.findLastIndex = findLastIndex; | ||
exports.findLastIndexFrom = findLastIndexFrom; | ||
exports.flatMap = flatMap; | ||
@@ -528,5 +597,8 @@ exports.flatten = flatten; | ||
exports.pickOwn = pickOwn; | ||
exports.reject = reject; | ||
exports.removeAt = removeAt; | ||
exports.shallowEqual = shallowEqual; | ||
exports.splitAt = splitAt; | ||
exports.splitRightWhenAccum = splitRightWhenAccum; | ||
exports.takeRightWhileFrom = takeRightWhileFrom; | ||
exports.throttle = throttle; | ||
@@ -533,0 +605,0 @@ exports.toPairs = toPairs; |
@@ -64,2 +64,8 @@ (function (global, factory) { | ||
function camelCase(text) { | ||
return text.replace(/^[_.\- ]+/, '').toLowerCase().replace(/[_.\- ]+(\w|$)/g, function (__, p1) { | ||
return p1.toUpperCase(); | ||
}); | ||
} | ||
function compact(collection) { | ||
@@ -74,2 +80,14 @@ return isArray(collection) ? collection.filter(Boolean) : Object.keys(collection).reduce(function (result, key) { | ||
function compose() { | ||
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { | ||
funcs[_key] = arguments[_key]; | ||
} | ||
return funcs.reduce(function (composed, next) { | ||
return function () { | ||
return composed(next.apply(undefined, arguments)); | ||
}; | ||
}); | ||
} | ||
function dropRight(count, arr) { | ||
@@ -108,4 +126,4 @@ return arr.slice(0, -count); | ||
function findLastIndex(predicate, arr) { | ||
for (var index = arr.length - 1; index >= 0; index--) { | ||
function findLastIndexFrom(predicate, startIndex, arr) { | ||
for (var index = startIndex; index >= 0; index--) { | ||
if (predicate(arr[index])) { | ||
@@ -119,2 +137,6 @@ return index; | ||
function findLastIndex(predicate, arr) { | ||
return findLastIndexFrom(predicate, arr.length - 1, arr); | ||
} | ||
function flatMap(iteratee, arr) { | ||
@@ -387,2 +409,8 @@ var _ref; | ||
function reject(predicate, arr) { | ||
return arr.filter(function (element) { | ||
return !predicate(element); | ||
}); | ||
} | ||
function removeAt(index, arr) { | ||
@@ -394,2 +422,33 @@ var copy = [].concat(arr); | ||
// https://github.com/reactjs/react-redux/blob/5d792a283554cff3d2f54fad1be1f79cbcab33fe/src/utils/shallowEqual.js | ||
function is(first, second) { | ||
if (first === second) { | ||
return first !== 0 || second !== 0 || 1 / first === 1 / second; | ||
} | ||
// eslint-disable-next-line no-self-compare | ||
return first !== first && second !== second; | ||
} | ||
function shallowEqual(objA, objB) { | ||
if (is(objA, objB)) return true; | ||
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) { | ||
return false; | ||
} | ||
var keysA = Object.keys(objA); | ||
var keysB = Object.keys(objB); | ||
if (keysA.length !== keysB.length) return false; | ||
for (var index = 0; index < keysA.length; index++) { | ||
if (!hasOwn(keysA[index], objB) || !is(objA[keysA[index]], objB[keysA[index]])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function splitAt(splitPoint, arr) { | ||
@@ -420,2 +479,9 @@ // TODO first item from the tuple could be replaced by dropRight | ||
function takeRightWhileFrom(predicate, startIndex, arr) { | ||
var endIndex = findLastIndexFrom(function (element) { | ||
return !predicate(element); | ||
}, startIndex, arr); | ||
return endIndex === startIndex ? [] : arr.slice(endIndex + 1, startIndex + 1); | ||
} | ||
function throttle(ms, fn) { | ||
@@ -487,3 +553,5 @@ var lastCall = Date.now() - 2 * ms; | ||
exports.cloneDeep = cloneDeep; | ||
exports.camelCase = camelCase; | ||
exports.compact = compact; | ||
exports.compose = compose; | ||
exports.dropRight = dropRight; | ||
@@ -494,2 +562,3 @@ exports.find = find; | ||
exports.findLastIndex = findLastIndex; | ||
exports.findLastIndexFrom = findLastIndexFrom; | ||
exports.flatMap = flatMap; | ||
@@ -530,5 +599,8 @@ exports.flatten = flatten; | ||
exports.pickOwn = pickOwn; | ||
exports.reject = reject; | ||
exports.removeAt = removeAt; | ||
exports.shallowEqual = shallowEqual; | ||
exports.splitAt = splitAt; | ||
exports.splitRightWhenAccum = splitRightWhenAccum; | ||
exports.takeRightWhileFrom = takeRightWhileFrom; | ||
exports.throttle = throttle; | ||
@@ -535,0 +607,0 @@ exports.toPairs = toPairs; |
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.DataUtils={})}(this,function(n){"use strict";var r={}.hasOwnProperty;function o(n,t){return r.call(t,n)}function t(){return(t=Object.assign||function(r){for(var n=arguments.length,t=Array(1<n?n-1:0),e=1;e<n;e++)t[e-1]=arguments[e];return t.forEach(function(n){for(var t in n)o(t,n)&&(r[t]=n[t])}),r}).apply(void 0,arguments)}var e=Array.isArray,u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n};function i(n){return"object"===(void 0===n?"undefined":u(n))&&null!==n&&!e(n)}function c(r,e){return Object.keys(e).reduce(function(n,t){return n[t]=r(e[t]),n},{})}function f(n,t){var r;return(r=[]).concat.apply(r,t.map(n))}function a(n){return n}function l(t,r){return Object.keys(r).forEach(function(n){t(r[n],n)})}function d(){return Math.random().toString(36).substring(2)}function s(n,t){for(var r="string"==typeof n?n.split("."):n,e=0,u=t;u&&e<r.length;)u=u[r[e++]];return u}function p(n){return 0===(e(n)?n:Object.keys(n)).length}function y(r,e){if(p(e))return r;var u={};return l(function(n,t){u[t]=o(t,e)?i(r[t])&&i(e[t])?y(r[t],e[t]):e[t]:r[t]},r),l(function(n,t){o(t,u)||(u[t]=e[t])},e),u}function v(t){return Object.keys(t).map(function(n){return t[n]})}function m(r,e){return Object.keys(e).reduce(function(n,t){return r(e[t],t)||(n[t]=e[t]),n},{})}function g(n,t){return[t.slice(0,n),t.slice(n,t.length)]}var h=/^\s+/;var O=/\s+$/;n.assign=t,n.cloneDeep=function n(t){return e(t)?t.map(n):i(t)?c(n,t):t},n.compact=function(r){return e(r)?r.filter(Boolean):Object.keys(r).reduce(function(n,t){return r[t]&&(n[t]=r[t]),n},{})},n.dropRight=function(n,t){return t.slice(0,-n)},n.find=function(n,t){for(var r=0;r<t.length;r++){var e=t[r];if(n(e))return e}},n.findIndex=function(n,t){for(var r=0;r<t.length;r++)if(n(t[r]))return r;return-1},n.findLast=function(n,t){for(var r=t.length-1;0<=r;r--)if(n(t[r]))return t[r]},n.findLastIndex=function(n,t){for(var r=t.length-1;0<=r;r--)if(n(t[r]))return r;return-1},n.flatMap=f,n.flatten=function(n){return f(a,n)},n.forOwn=l,n.fromPairs=function(n){return n.reduce(function(n,t){return n[t[0]]=t[1],n},{})},n.generateRandomId=d,n.generateUniqueId=function n(t){var r=d();return o(r,t)?n(t):r},n.get=s,n.getOr=function(n,t,r){var e=s(t,r);return null!=e?e:n},n.groupBy=function(u,o){return Object.keys(o).reduce(function(n,t){var r=o[t],e=u(r);return n[e]=n[e]||[],n[e].push(r),n},{})},n.groupKeys=function(e,u){return Object.keys(u).reduce(function(n,t){var r=e(t);return n[r]=n[r]||{},n[r][t]=u[t],n},{})},n.hasOwn=o,n.identity=a,n.includes=function(n,t){return-1!==t.indexOf(n)},n.isArray=e,n.isEmpty=p,n.isObject=i,n.keyBy=function(r,n){return n.reduce(function(n,t){return n[t[r]]=t,n},{})},n.last=function(n){return 0<n.length?n[n.length-1]:null},n.mapKeys=function(r,e){return Object.keys(e).reduce(function(n,t){return n[r(t)]=e[t],n},{})},n.mapValues=c,n.mapValuesIndexed=function(r,e){return Object.keys(e).reduce(function(n,t){return n[t]=r(e[t],t),n},{})},n.merge=y,n.mergeAll=function(n){if(0===n.length)return{};var t=n[0];return n.slice(1).reduce(function(n,t){return y(n,t)},t)},n.memoize=function(e){var u=[],o=[];return function(){var n=0<arguments.length?arguments[0]:void 0,t=u.indexOf(n);if(-1!==t)return o[t];var r=e.apply(void 0,arguments);return u.push(n),o.push(r),r}},n.memoizeOne=function(n){var t=void 0,r=void 0;return function(){return(0<arguments.length?arguments[0]:void 0)===r?t:(r=0<arguments.length?arguments[0]:void 0,t=n.apply(void 0,arguments))}},n.noop=function(){},n.numericSortBy=function(t,n){var r="function"==typeof t?t:function(n){return s(t,n)};return(e(n)?[].concat(n):v(n)).sort(function(n,t){return r(n)-r(t)})},n.omit=function(r,n){return m(function(n,t){return-1!==r.indexOf(t)},n)},n.omitBy=function(r,e){return Object.keys(e).reduce(function(n,t){return r(e[t])||(n[t]=e[t]),n},{})},n.omitByIndexed=m,n.once=function(n){var t=!1,r=void 0;return function(){return t?r:(t=!0,r=n.apply(void 0,arguments))}},n.pick=function(n,r){return n.reduce(function(n,t){return n[t]=r[t],n},{})},n.pickBy=function(r,e){return Object.keys(e).reduce(function(n,t){return r(e[t])&&(n[t]=e[t]),n},{})},n.pickByIndexed=function(r,e){return Object.keys(e).reduce(function(n,t){return r(e[t],t)&&(n[t]=e[t]),n},{})},n.pickOwn=function(n,r){return n.reduce(function(n,t){return o(t,r)&&(n[t]=r[t]),n},{})},n.removeAt=function(n,t){var r=[].concat(t);return r.splice(n,1),r},n.splitAt=g,n.splitRightWhenAccum=function(n,t,r){for(var e=r.length;0<e;e--){var u=n(r[e-1],t);if(t=u[1],u[0])return g(e-1,r)}return[[],r]},n.throttle=function(u,n){var o=Date.now()-2*u,i=void 0,c=void 0,f=function(){return o=Date.now(),i=n.apply(void 0,arguments)};return function(){for(var n=arguments.length,t=Array(n),r=0;r<n;r++)t[r]=arguments[r];var e=Date.now();return e-o<u?(clearTimeout(c),c=setTimeout.apply(void 0,[f,o-e+u].concat(t)),i):f.apply(void 0,t)}},n.toPairs=function(t){return Object.keys(t).map(function(n){return[n,t[n]]})},n.trimStart=function(n){return n.replace(h,"")},n.trimEnd=function(n){return n.replace(O,"")},n.uniq=function(n){var t=[];return n.filter(function(n){return-1===t.indexOf(n)&&(t.push(n),!0)})},n.values=v,n.without=function(t,n){return n.filter(function(n){return-1===t.indexOf(n)})},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.DataUtils={})}(this,function(n){"use strict";var r={}.hasOwnProperty;function o(n,t){return r.call(t,n)}function t(){return(t=Object.assign||function(r){for(var n=arguments.length,t=Array(1<n?n-1:0),e=1;e<n;e++)t[e-1]=arguments[e];return t.forEach(function(n){for(var t in n)o(t,n)&&(r[t]=n[t])}),r}).apply(void 0,arguments)}var e=Array.isArray,u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n};function i(n){return"object"===(void 0===n?"undefined":u(n))&&null!==n&&!e(n)}function c(r,e){return Object.keys(e).reduce(function(n,t){return n[t]=r(e[t]),n},{})}function f(n,t,r){for(var e=t;0<=e;e--)if(n(r[e]))return e;return-1}function a(n,t){var r;return(r=[]).concat.apply(r,t.map(n))}function l(n){return n}function d(t,r){return Object.keys(r).forEach(function(n){t(r[n],n)})}function s(){return Math.random().toString(36).substring(2)}function p(n,t){for(var r="string"==typeof n?n.split("."):n,e=0,u=t;u&&e<r.length;)u=u[r[e++]];return u}function y(n){return 0===(e(n)?n:Object.keys(n)).length}function v(r,e){if(y(e))return r;var u={};return d(function(n,t){u[t]=o(t,e)?i(r[t])&&i(e[t])?v(r[t],e[t]):e[t]:r[t]},r),d(function(n,t){o(t,u)||(u[t]=e[t])},e),u}function m(t){return Object.keys(t).map(function(n){return t[n]})}function h(r,e){return Object.keys(e).reduce(function(n,t){return r(e[t],t)||(n[t]=e[t]),n},{})}function g(n,t){return n===t?0!==n||0!==t||1/n==1/t:n!=n&&t!=t}function b(n,t){return[t.slice(0,n),t.slice(n,t.length)]}var O=/^\s+/;var j=/\s+$/;n.assign=t,n.cloneDeep=function n(t){return e(t)?t.map(n):i(t)?c(n,t):t},n.camelCase=function(n){return n.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,function(n,t){return t.toUpperCase()})},n.compact=function(r){return e(r)?r.filter(Boolean):Object.keys(r).reduce(function(n,t){return r[t]&&(n[t]=r[t]),n},{})},n.compose=function(){for(var n=arguments.length,t=Array(n),r=0;r<n;r++)t[r]=arguments[r];return t.reduce(function(n,t){return function(){return n(t.apply(void 0,arguments))}})},n.dropRight=function(n,t){return t.slice(0,-n)},n.find=function(n,t){for(var r=0;r<t.length;r++){var e=t[r];if(n(e))return e}},n.findIndex=function(n,t){for(var r=0;r<t.length;r++)if(n(t[r]))return r;return-1},n.findLast=function(n,t){for(var r=t.length-1;0<=r;r--)if(n(t[r]))return t[r]},n.findLastIndex=function(n,t){return f(n,t.length-1,t)},n.findLastIndexFrom=f,n.flatMap=a,n.flatten=function(n){return a(l,n)},n.forOwn=d,n.fromPairs=function(n){return n.reduce(function(n,t){return n[t[0]]=t[1],n},{})},n.generateRandomId=s,n.generateUniqueId=function n(t){var r=s();return o(r,t)?n(t):r},n.get=p,n.getOr=function(n,t,r){var e=p(t,r);return null!=e?e:n},n.groupBy=function(u,o){return Object.keys(o).reduce(function(n,t){var r=o[t],e=u(r);return n[e]=n[e]||[],n[e].push(r),n},{})},n.groupKeys=function(e,u){return Object.keys(u).reduce(function(n,t){var r=e(t);return n[r]=n[r]||{},n[r][t]=u[t],n},{})},n.hasOwn=o,n.identity=l,n.includes=function(n,t){return-1!==t.indexOf(n)},n.isArray=e,n.isEmpty=y,n.isObject=i,n.keyBy=function(r,n){return n.reduce(function(n,t){return n[t[r]]=t,n},{})},n.last=function(n){return 0<n.length?n[n.length-1]:null},n.mapKeys=function(r,e){return Object.keys(e).reduce(function(n,t){return n[r(t)]=e[t],n},{})},n.mapValues=c,n.mapValuesIndexed=function(r,e){return Object.keys(e).reduce(function(n,t){return n[t]=r(e[t],t),n},{})},n.merge=v,n.mergeAll=function(n){if(0===n.length)return{};var t=n[0];return n.slice(1).reduce(function(n,t){return v(n,t)},t)},n.memoize=function(e){var u=[],o=[];return function(){var n=0<arguments.length?arguments[0]:void 0,t=u.indexOf(n);if(-1!==t)return o[t];var r=e.apply(void 0,arguments);return u.push(n),o.push(r),r}},n.memoizeOne=function(n){var t=void 0,r=void 0;return function(){return(0<arguments.length?arguments[0]:void 0)===r?t:(r=0<arguments.length?arguments[0]:void 0,t=n.apply(void 0,arguments))}},n.noop=function(){},n.numericSortBy=function(t,n){var r="function"==typeof t?t:function(n){return p(t,n)};return(e(n)?[].concat(n):m(n)).sort(function(n,t){return r(n)-r(t)})},n.omit=function(r,n){return h(function(n,t){return-1!==r.indexOf(t)},n)},n.omitBy=function(r,e){return Object.keys(e).reduce(function(n,t){return r(e[t])||(n[t]=e[t]),n},{})},n.omitByIndexed=h,n.once=function(n){var t=!1,r=void 0;return function(){return t?r:(t=!0,r=n.apply(void 0,arguments))}},n.pick=function(n,r){return n.reduce(function(n,t){return n[t]=r[t],n},{})},n.pickBy=function(r,e){return Object.keys(e).reduce(function(n,t){return r(e[t])&&(n[t]=e[t]),n},{})},n.pickByIndexed=function(r,e){return Object.keys(e).reduce(function(n,t){return r(e[t],t)&&(n[t]=e[t]),n},{})},n.pickOwn=function(n,r){return n.reduce(function(n,t){return o(t,r)&&(n[t]=r[t]),n},{})},n.reject=function(t,n){return n.filter(function(n){return!t(n)})},n.removeAt=function(n,t){var r=[].concat(t);return r.splice(n,1),r},n.shallowEqual=function(n,t){if(g(n,t))return!0;if("object"!==(void 0===n?"undefined":u(n))||null===n||"object"!==(void 0===t?"undefined":u(t))||null===t)return!1;var r=Object.keys(n);if(r.length!==Object.keys(t).length)return!1;for(var e=0;e<r.length;e++)if(!o(r[e],t)||!g(n[r[e]],t[r[e]]))return!1;return!0},n.splitAt=b,n.splitRightWhenAccum=function(n,t,r){for(var e=r.length;0<e;e--){var u=n(r[e-1],t);if(t=u[1],u[0])return b(e-1,r)}return[[],r]},n.takeRightWhileFrom=function(t,n,r){var e=f(function(n){return!t(n)},n,r);return e===n?[]:r.slice(e+1,n+1)},n.throttle=function(u,n){var o=Date.now()-2*u,i=void 0,c=void 0,f=function(){return o=Date.now(),i=n.apply(void 0,arguments)};return function(){for(var n=arguments.length,t=Array(n),r=0;r<n;r++)t[r]=arguments[r];var e=Date.now();return e-o<u?(clearTimeout(c),c=setTimeout.apply(void 0,[f,o-e+u].concat(t)),i):f.apply(void 0,t)}},n.toPairs=function(t){return Object.keys(t).map(function(n){return[n,t[n]]})},n.trimStart=function(n){return n.replace(O,"")},n.trimEnd=function(n){return n.replace(j,"")},n.uniq=function(n){var t=[];return n.filter(function(n){return-1===t.indexOf(n)&&(t.push(n),!0)})},n.values=m,n.without=function(t,n){return n.filter(function(n){return-1===t.indexOf(n)})},Object.defineProperty(n,"__esModule",{value:!0})}); |
{ | ||
"name": "@livechat/data-utils", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Collections utility functions", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
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
47951
1472