refactor: remove AnyObject type

This commit is contained in:
Philipp Kühn
2021-04-21 09:43:31 +02:00
parent d720d77e8d
commit 1c8ca95de2
64 changed files with 108 additions and 196 deletions

View File

@@ -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]
}

View File

@@ -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) => {

View File

@@ -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)) {

View File

@@ -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) {