Refactor
This commit is contained in:
parent
a8a2a7c708
commit
b019ac8dce
|
@ -1,5 +1,6 @@
|
|||
import { Printer } from './Printer.mjs'
|
||||
import fs from 'fs'
|
||||
import { PrinterJSON } from './types.mjs'
|
||||
|
||||
export class PrinterRepository {
|
||||
constructor() {
|
||||
|
@ -13,9 +14,12 @@ export class PrinterRepository {
|
|||
static instance: PrinterRepository
|
||||
|
||||
loadFromJSON() {
|
||||
const json = JSON.parse(fs.readFileSync('./data/printers.json', 'utf8'))
|
||||
const json: PrinterJSON[] = JSON.parse(
|
||||
fs.readFileSync('./data/printers.json', 'utf8')
|
||||
)
|
||||
|
||||
this.printers = json.map(
|
||||
({ name, ip, model }: Printer) => new Printer(name, ip, model)
|
||||
({ name, ip, model }) => new Printer(name, ip, model)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ export type PrinterInfo = {
|
|||
}
|
||||
}
|
||||
|
||||
export type Printer = {
|
||||
export type PrinterJSON = {
|
||||
name: string
|
||||
ip: string
|
||||
model: PrinterModel
|
||||
|
|
Loading…
Reference in New Issue
Block a user