0.0.24 • Published 1 year ago

@firecamp/utils v0.0.24

Weekly downloads
-
License
AGPL-3.0
Repository
github
Last release
1 year ago

@firecamp/utils

Usage

import { _array, _object } from '@firecamp/utils';

API

Array

/**
 * Creates an array excluding all given values using SameValueZero for equality comparisons.
 *
 * @reference https://lodash.com/docs/4.17.15#without
 */
export type TWithout = (
  array: any[],
  element: string | number | Function
) => (string | number)[];

/**
 * This method is like _.sortBy except that it allows specifying the sort orders of
 * the iteratees to sort by. If orders is unspecified, all values are sorted in ascending order.
 * Otherwise, specify an order of "desc" for descending or "asc" for ascending sort order
 * of corresponding values.
 *
 * @reference https://lodash.com/docs/4.17.15#orderBy
 */
export type TOrderBy = (
  array: object[],
  iteratee: string | Function,
  order: 'asc' | 'desc'
) => object[];

/**
 * Creates an object composed of keys generated from the results of running each element of
 * collection thru iteratee. The corresponding value of each key is the last element responsible
 * for generating the key. The iteratee is invoked with one argument: (value).
 *
 * @reference https://lodash.com/docs/4.17.15#keyBy
 */
export type TKeyBy = (array: object[], prop: string) => object;

/**
 * Removes elements from array corresponding to indexes and returns an array of elements without values exist at indexes.
 *
 */
export type TRemoveItem = (array: any[], index: number) => any[];

/**
 * This method is like _.uniq except that it accepts iteratee which is invoked for each element in array to generate
 * the criterion by which uniqueness is computed. The order of result values is determined by the order they occur in the array.
 * The iteratee is invoked with one argument: (value).
 *
 * @reference https://lodash.com/docs/4.17.15#uniqBy
 */
export type TUniqBy = (
  array: any[],
  iteratee: string | number | Function
) => any[];

Object

import { Options } from 'deepmerge'

/**
 * Gets the size of collection by returning its length for array-like values or 
 * the number of own enumerable string keyed properties for objects.
 * 
 * @reference https://lodash.com/docs/4.17.15#size
 */
export type TSize = (object: object) => number

/**
 * Checks if path is a direct property of object.
 * 
 * @reference https://lodash.com/docs/4.17.15#has
 */
export type THas = (object: object, prop: string | number) => boolean

/**
 * The opposite of _object.pick; this method creates an object composed of the own and 
 * inherited enumerable property paths of object that are not omitted.
 */
export type TOmit = (object: object, paths: string[]) => object

/**
 * Creates an object composed of the picked object properties.
 * 
 * @reference https://lodash.com/docs/4.17.15#pick
 */
export type TPick = (object: object, properties: string[]) => object

/**
 * Checks if value is the language type of Object. (e.g. objects)
 * note: return false if an object is an array
 * 
 * @reference https://lodash.com/docs/4.17.15#isObject
 */
export type TIsObject = (object: any) => boolean

/**
 * Merges the enumerable properties of two or more objects deeply.
 * 
 * @reference https://www.npmjs.com/package/deepmerge
 */
export type TMergeDeep = (target: object, source: object, cleanDeep?: boolean, options?: Options) => object

/**
 * return the object which contains the changes performed into the new object
 */
export type TDifference = (oldObject: object, newObject: object) => object

/**
 * return the list of paths from the object which path value matched with the passed value
 */
export type TValuePath = (object: object, value: any, currentPath: string) => string[]

/**
 * return the object after removing the specific characters from the 
 * object properties to the n-th level
 */
export type TOmitCharsFromProp = (object: object, chars?: string[]) => object
0.0.20

1 year ago

0.0.21

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.24

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.17

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago