refactor: remove AnyObject type
This commit is contained in:
@@ -1,18 +1,16 @@
|
||||
import { AnyObject } from '../types'
|
||||
|
||||
/**
|
||||
* Remove a property or an array of properties from an object
|
||||
* @param obj Object
|
||||
* @param key Key to remove
|
||||
*/
|
||||
export default function deleteProps(obj: AnyObject, propOrProps: string | string[]): AnyObject {
|
||||
export default function deleteProps(obj: Record<string, any>, propOrProps: string | string[]): Record<string, any> {
|
||||
const props = typeof propOrProps === 'string'
|
||||
? [propOrProps]
|
||||
: propOrProps
|
||||
|
||||
return Object
|
||||
.keys(obj)
|
||||
.reduce((newObj: AnyObject, prop) => {
|
||||
.reduce((newObj: Record<string, any>, prop) => {
|
||||
if (!props.includes(prop)) {
|
||||
newObj[prop] = obj[prop]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { AnyObject } from '../types'
|
||||
|
||||
export default function mergeAttributes(...objects: AnyObject[]): AnyObject {
|
||||
export default function mergeAttributes(...objects: Record<string, any>[]): Record<string, any> {
|
||||
return objects
|
||||
.filter(item => !!item)
|
||||
.reduce((items, item) => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { AnyObject } from '../types'
|
||||
import isPlainObject from './isPlainObject'
|
||||
|
||||
export default function mergeDeep(target: AnyObject, source: AnyObject): AnyObject {
|
||||
export default function mergeDeep(target: Record<string, any>, source: Record<string, any>): Record<string, any> {
|
||||
const output = { ...target }
|
||||
|
||||
if (isPlainObject(target) && isPlainObject(source)) {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { AnyObject } from '../types'
|
||||
|
||||
/**
|
||||
* Check if object1 includes object2
|
||||
* @param object1 Object
|
||||
* @param object2 Object
|
||||
*/
|
||||
export default function objectIncludes(object1: AnyObject, object2: AnyObject): boolean {
|
||||
export default function objectIncludes(object1: Record<string, any>, object2: Record<string, any>): boolean {
|
||||
const keys = Object.keys(object2)
|
||||
|
||||
if (!keys.length) {
|
||||
|
||||
Reference in New Issue
Block a user