Прогнал линтером для автоматических доделок, но оставлять его не стал - слишком много ошибок

This commit is contained in:
Nikita Dezzpil Orlov committed 2021-09-29 18:01:08 +03:00
1 parent ce3a192cbd
commit c6db8bc2fe
14 files changed
+118 -8324

No files matched your search

+16 -16
View File
@@ -1,33 +1,32 @@
import rfdc from 'rfdc'
interface ValuesObject {
[key: string]: any
}
type ValuesObject = Record<string, any>
export abstract class Data {
[key: string]: any
static assign(vo: Data, values: ValuesObject): Data {
for (let key of Object.getOwnPropertyNames(values)) {
for (const key of Object.getOwnPropertyNames(values)) {
vo[key] = values[key]
}
return vo
}
[key: string]: any
set(key: string, value: any) {
this[key] = value
}
fromObject(obj: ValuesObject): void {
for (let key of Object.getOwnPropertyNames(obj)) {
fromObject(object: ValuesObject): void {
for (const key of Object.getOwnPropertyNames(object)) {
if (key === '_id') continue
this[key] = obj[key]
this[key] = object[key]
}
}
toObject(exclude: string[] = []): object {
const obj = {} as ValuesObject
for (let key of Object.getOwnPropertyNames(this)) {
toObject(exclude: string[] = []): Record<string, any> {
const object = {} as ValuesObject
for (const key of Object.getOwnPropertyNames(this)) {
if (key.startsWith('__')) {
continue
}
@@ -36,14 +35,15 @@ export abstract class Data {
const type = typeof this[key]
if (type === 'object') {
obj[key] = rfdc()(this[key])
} else if (['function', 'undefined'].indexOf(type) >= 0) {
object[key] = rfdc()(this[key])
} else if (['function', 'undefined'].includes(type)) {
// ...
} else {
obj[key] = this[key]
object[key] = this[key]
}
}
return obj
return object
}
abstract uniqKey(): string