0.1.0 • Published 3 years ago

@h-utils/utils v0.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

@h-utils/utils

@h-utils/utils - v0.0.1

Table of contents

Functions

Functions

filterEmptyContent

filterEmptyContent(target, isDeep?, filterConfig?): unknown

filter the content of array or object, bump the field which value is ''、undefined、null、{}、[]

Parameters

NameTypeDescription
targetunknownThe value you want to filter,except object or array.
isDeep?booleanIf field is an array of object,filter it or not.
filterConfig?IFilterConfig | checkIsNeedTypeThe method or config to filter value.

Returns

unknown

filter result


getValueType

getValueType(value): string

get type of the value

Example

import getValueType from '@h-utils/getValueType';

getValueType('value'); // 'String'
getValueType(1); // 'Number'
getValueType(NaN); // 'NaN'
getValueType(true); // 'Boolean'
getValueType(Symbol()); // 'Symbol'
getValueType(null); // 'null'
getValueType({}); // 'Object'
getValueType([]); // 'Array'
getValueType(new CustomClass()); // 'CustomClass'

Parameters

NameTypeDescription
valueunknownthe value that you want to get type

Returns

string

type of the value


operateObject

operateObject(objOrArr, operation): null | IUniformObject<unknown> | unknown[] | unknown

get a new object/array that performed particular operation

Parameters

NameTypeDescription
objOrArrunknownany object or array that you want to operate.
operationIOperationdefine to set or not set content, and how to set.

Returns

null | IUniformObject<unknown> | unknown[] | unknown

the operation result