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

@livechat/data-utils

Package Overview
Dependencies
Maintainers
8
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@livechat/data-utils - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

21

dist/data-utils.es.js

@@ -71,2 +71,12 @@ /**

/**
* takes two arguments: a function and either an array or another function. The function applies the input function to every element of the input array or to the result of calling the input function on the input array. Then, the results are concatenated into a new array and returned.
* @example
* chain(n => [n, n], [1, 2, 3])
* // returns [1, 1, 2, 2, 3, 3]
* const head = list => list[0]
* const append = el => list => list.concat(el)
* chain(append, head)([1, 2, 3])
* // returns [1, 2, 3, 1]
*/
function chain(fn, listOrFn) {

@@ -228,2 +238,10 @@ if (typeof listOrFn === 'function') {

/**
* removes all nullish and NaN values from the provided object or array
* @example
* compact({ a: 1, b: null })
* // returns { a: 1 }
* compact(['hello', undefined])
* // returns ['hello']
*/
function compact(collection) {

@@ -250,3 +268,2 @@ return isArray(collection) ? collection.filter(function (value) {

*/
function compose() {

@@ -676,3 +693,2 @@ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {

*/
function includes(value, arrOrStr) {

@@ -1390,3 +1406,2 @@ return arrOrStr.indexOf(value) !== -1;

*/
function splitAt(splitPoint, arrOrStr) {

@@ -1393,0 +1408,0 @@ return [arrOrStr.slice(0, splitPoint), arrOrStr.slice(splitPoint, arrOrStr.length)];

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

/**
* takes two arguments: a function and either an array or another function. The function applies the input function to every element of the input array or to the result of calling the input function on the input array. Then, the results are concatenated into a new array and returned.
* @example
* chain(n => [n, n], [1, 2, 3])
* // returns [1, 1, 2, 2, 3, 3]
* const head = list => list[0]
* const append = el => list => list.concat(el)
* chain(append, head)([1, 2, 3])
* // returns [1, 2, 3, 1]
*/
function chain(fn, listOrFn) {

@@ -232,2 +242,10 @@ if (typeof listOrFn === 'function') {

/**
* removes all nullish and NaN values from the provided object or array
* @example
* compact({ a: 1, b: null })
* // returns { a: 1 }
* compact(['hello', undefined])
* // returns ['hello']
*/
function compact(collection) {

@@ -254,3 +272,2 @@ return isArray(collection) ? collection.filter(function (value) {

*/
function compose() {

@@ -680,3 +697,2 @@ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {

*/
function includes(value, arrOrStr) {

@@ -1394,3 +1410,2 @@ return arrOrStr.indexOf(value) !== -1;

*/
function splitAt(splitPoint, arrOrStr) {

@@ -1397,0 +1412,0 @@ return [arrOrStr.slice(0, splitPoint), arrOrStr.slice(splitPoint, arrOrStr.length)];

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

/**
* takes two arguments: a function and either an array or another function. The function applies the input function to every element of the input array or to the result of calling the input function on the input array. Then, the results are concatenated into a new array and returned.
* @example
* chain(n => [n, n], [1, 2, 3])
* // returns [1, 1, 2, 2, 3, 3]
* const head = list => list[0]
* const append = el => list => list.concat(el)
* chain(append, head)([1, 2, 3])
* // returns [1, 2, 3, 1]
*/
function chain(fn, listOrFn) {

@@ -234,2 +244,10 @@ if (typeof listOrFn === 'function') {

/**
* removes all nullish and NaN values from the provided object or array
* @example
* compact({ a: 1, b: null })
* // returns { a: 1 }
* compact(['hello', undefined])
* // returns ['hello']
*/
function compact(collection) {

@@ -256,3 +274,2 @@ return isArray(collection) ? collection.filter(function (value) {

*/
function compose() {

@@ -682,3 +699,2 @@ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {

*/
function includes(value, arrOrStr) {

@@ -1396,3 +1412,2 @@ return arrOrStr.indexOf(value) !== -1;

*/
function splitAt(splitPoint, arrOrStr) {

@@ -1399,0 +1414,0 @@ return [arrOrStr.slice(0, splitPoint), arrOrStr.slice(splitPoint, arrOrStr.length)];

2

package.json
{
"name": "@livechat/data-utils",
"version": "1.0.3",
"version": "1.0.4",
"description": "Collection of utility functions",

@@ -5,0 +5,0 @@ "contributors": [

@@ -19,2 +19,5 @@ ## Functions

</dd>
<dt><a href="#chain">chain()</a></dt>
<dd><p>takes two arguments: a function and either an array or another function. The function applies the input function to every element of the input array or to the result of calling the input function on the input array. Then, the results are concatenated into a new array and returned.</p>
</dd>
<dt><a href="#chunk">chunk()</a></dt>

@@ -41,2 +44,5 @@ <dd><p>chunks provided array to specified size chunks</p>

</dd>
<dt><a href="#compact">compact()</a></dt>
<dd><p>removes all nullish and NaN values from the provided object or array</p>
</dd>
<dt><a href="#compose">compose()</a></dt>

@@ -396,2 +402,20 @@ <dd><p>returns a composed value from the provided arguments</p>

<a name="chain"></a>
## chain()
takes two arguments: a function and either an array or another function. The function applies the input function to every element of the input array or to the result of calling the input function on the input array. Then, the results are concatenated into a new array and returned.
**Kind**: global function
**Example**
```js
chain(n => [n, n], [1, 2, 3])
// returns [1, 1, 2, 2, 3, 3]
const head = list => list[0]
const append = el => list => list.concat(el)
chain(append, head)([1, 2, 3])
// returns [1, 2, 3, 1]
```
<a name="chunk"></a>

@@ -499,2 +523,18 @@

<a name="compact"></a>
## compact()
removes all nullish and NaN values from the provided object or array
**Kind**: global function
**Example**
```js
compact({ a: 1, b: null })
// returns { a: 1 }
compact(['hello', undefined])
// returns ['hello']
```
<a name="compose"></a>

@@ -501,0 +541,0 @@

import type { AnyFunction } from './types';
type AnyArrayFunction = (array: any[]) => any;
/**
* takes two arguments: a function and either an array or another function. The function applies the input function to every element of the input array or to the result of calling the input function on the input array. Then, the results are concatenated into a new array and returned.
* @example
* chain(n => [n, n], [1, 2, 3])
* // returns [1, 1, 2, 2, 3, 3]
* const head = list => list[0]
* const append = el => list => list.concat(el)
* chain(append, head)([1, 2, 3])
* // returns [1, 2, 3, 1]
*/
export default function chain(fn: AnyFunction, listOrFn: AnyArrayFunction): AnyArrayFunction;

@@ -14,0 +4,0 @@ export default function chain(fn: AnyFunction, listOrFn: any[]): any[];

import type { AnyObject, IsUnion } from './types';
/**
* removes all nullish and NaN values from the provided object or array
* @example
* compact({ a: 1, b: null })
* // returns { a: 1 }
* compact(['hello', undefined])
* // returns ['hello']
*/
export default function compact<T>(collection: T[]): NonNullable<T>[];

@@ -11,0 +3,0 @@ export default function compact<T extends AnyObject>(collection: T): {

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

/**
* returns a composed value from the provided arguments
* @example
* const f3 = (a: string) => `f3(${a})`
* const f2 = (a: string) => `f2(${a})`
* const f1 = (a: string) => `f1(${a})`
* compose(f3, f2, f1)('arg')
* // returns 'f3(f2(f1(arg)))'
*/
export default function compose<Input, Return, T1>(second: (a: T1) => Return, first: (a: Input) => T1): (a: Input) => Return;

@@ -11,0 +2,0 @@ export default function compose<Input, Return, T1, T2>(third: (a: T2) => Return, second: (a: T1) => T2, first: (a: Input) => T1): (a: Input) => Return;

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

/**
* returns true or false depending if the provided value is present inside the provided array or string
* @example
* includes('a', ['a', 'b', 'c'])
* // returns true
* includes('d', 'abc')
* // returns false
*/
export default function includes<T>(value: T, arr: ReadonlyArray<T>): boolean;
export default function includes(value: string, str: string): boolean;
//# sourceMappingURL=includes.d.ts.map

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

/**
* splits an array or a string at the given index
* @example
* splitAt(2, [1, 2, 3, 4, 5])
* // returns [[1, 2], [3, 4, 5]]
* splitAt(2, 'foobar')
* // returns ['fo', 'obar']
*/
export default function splitAt<T>(splitPoint: number, arr: T[]): [T[], T[]];
export default function splitAt(splitPoint: number, str: string): [string, string];
//# sourceMappingURL=splitAt.d.ts.map
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc