@codegateinc/g-utils
Advanced tools
Comparing version 0.0.26 to 0.0.28
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.isEmpty = exports.compareFunctions = exports.is = exports.values = exports.clearObject = exports.fromPairs = exports.toPairs = exports.all = exports.hasElements = exports.hasKeys = exports.always = exports.T = exports.call = exports.ifDefined = exports.isDefined = exports.cond = exports.compose = void 0; | ||
exports.splitEvery = exports.isEmpty = exports.compareFunctions = exports.is = exports.values = exports.clearObject = exports.fromPairs = exports.toPairs = exports.all = exports.hasElements = exports.hasKeys = exports.always = exports.T = exports.call = exports.ifDefined = exports.isDefined = exports.cond = exports.compose = void 0; | ||
@@ -100,2 +100,6 @@ const compose = (...functions) => firstArg => functions.reverse().reduce((acc, fn) => fn(acc), firstArg); | ||
exports.isEmpty = isEmpty; | ||
exports.isEmpty = isEmpty; | ||
const splitEvery = (limit, collection) => Array.from(new Array(Math.ceil(collection.length / limit))).map((_, index) => collection.slice(index * limit, limit * (index + 1))); | ||
exports.splitEvery = splitEvery; |
@@ -21,2 +21,3 @@ import { CondItem, KeyValuePair } from './src/types' | ||
export function isEmpty(subject: any): boolean | ||
export function splitEvery<T = [] | string>(limit: number, collection: T): T[][] | ||
} |
@@ -6,3 +6,3 @@ { | ||
"typings": "index.d.ts", | ||
"version": "0.0.26", | ||
"version": "0.0.28", | ||
"main": "dist/index.js", | ||
@@ -9,0 +9,0 @@ "description": "This library is a package of useful functions", |
@@ -23,20 +23,21 @@ ## [![Coverage Status](https://coveralls.io/repos/github/codegateinc/gUtils/badge.svg?branch=master)](https://coveralls.io/github/codegateinc/gUtils?branch=master) | ||
| function | props | description | | ||
|----------------|-----------------------------------------------------|-----------------------------------------| | ||
|compose |`(Array<Function>)` |calls functions in reversed order | ||
|cond |`<T = any, S = any>(array: Array<CondItem<T, S>>)` |replaces switch with array of conditions | ||
|isDefined |`(subject: any)` |check if given value is defined and not nullable | ||
|ifDefined |`<T = any>(subject: any, then: (subject: T) => void)`|calls the function if predicate is defined | ||
|call |`(fn: Function)` |calls given `fn` function | ||
|T |none |returns empty function | ||
|always |`<T>(subject: any)` |always returns given value | ||
|hasKeys |`(subject: any)` |checks if object has any keys | ||
|toPairs |`<T extends {}>(subject: {[key: string]: any})` |extracts object to array of key value tuple | ||
|fromPairs |`<T extends {}>(subject: Array<[string, any]>)` |returns object made from Array of key value tuple | ||
|clearObject |`(subject: {[key: string]: any})` |clears object from nullable or undefined values | ||
|values |`<T extends {}>(subject: {[key: string]: any})` |returns object's values as Array | ||
|is |`(type: any, subject: any)` |validates if give value has provided type | ||
|all |`(Array<boolean>)` |check if all passed arguments are truthy | ||
|hasElements |`(subject: any): boolean` |check if given value is array and has got any elements | ||
|compareFunctions|`(a: Function, b: Function): boolean` |check if given functions are the same | ||
|isEmpty |`(subject: any):boolean` |check if given value is empty | ||
| function | props | description | | ||
|----------------|------------------------------------------------------------|-----------------------------------------| | ||
|compose |`(Array<Function>)` |calls functions in reversed order | ||
|cond |`<T = any, S = any>(array: Array<CondItem<T, S>>)` |replaces switch with array of conditions | ||
|isDefined |`(subject: any)` |check if given value is defined and not nullable | ||
|ifDefined |`<T = any>(subject: any, then: (subject: T) => void)` |calls the function if predicate is defined | ||
|call |`(fn: Function)` |calls given `fn` function | ||
|T |none |returns empty function | ||
|always |`<T>(subject: any)` |always returns given value | ||
|hasKeys |`(subject: any)` |checks if object has any keys | ||
|toPairs |`<T extends {}>(subject: {[key: string]: any})` |extracts object to array of key value tuple | ||
|fromPairs |`<T extends {}>(subject: Array<[string, any]>)` |returns object made from Array of key value tuple | ||
|clearObject |`(subject: {[key: string]: any})` |clears object from nullable or undefined values | ||
|values |`<T extends {}>(subject: {[key: string]: any})` |returns object's values as Array | ||
|is |`(type: any, subject: any)` |validates if give value has provided type | ||
|all |`(Array<boolean>)` |check if all passed arguments are truthy | ||
|hasElements |`(subject: any): boolean` |check if given value is array and has got any elements | ||
|compareFunctions|`(a: Function, b: Function): boolean` |check if given functions are the same | ||
|isEmpty |`(subject: any): boolean` |check if given value is empty | ||
|splitEvery |`<T = [] \| string>(limit: number, collection: T): Array<T>`|splits an array or string in given limit |
@@ -69,1 +69,5 @@ import { KeyValuePair, CondItem } from './types' | ||
} | ||
export const splitEvery = <T>(limit: number, collection: Array<T> | string) => Array | ||
.from(new Array(Math.ceil(collection.length / limit))) | ||
.map((_, index) => collection.slice(index * limit, limit * (index + 1))) |
25094
32
548
43