Skip to content

Library of Node.js abstractions for side effects at the edges of software.

License

Notifications You must be signed in to change notification settings

paulshryock/node-abstractions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Abstractions

⚠️ This project is in early development and not for production use.

Library of Node.js abstractions for side effects at the edges of software.

Reduce accidental complexity and focus on application business logic.

Latest version badge npm bundle size npm downloads badge Socket badge GitHub License

Installation

npm install @paulshryock/abstractions

Usage

Command Line

CommandLine makes use of Node.js stdout and stderr streams.

import { CommandLine } from '@paulshryock/abstractions'

class MyClass {
    public construct(private commandLine: CommandLine) {}

    /** Prints 'Hello, world!' to stdout. */
    public printHelloWorldToStdout(): void {
        this.commandLine.out('Hello, world!')
    }

    /**
     * Prints 'What is your name?' to stdout and waits for an answer. Then
     * prints 'Hello, Paul!' to stdout (if the name given is 'Paul').
     */
    public async printHelloNameToStdout(): Promise<void> {
        const name = await this.commandLine.ask('What is your name?')

        this.commandLine.out(`Hello, ${name}!`)
    }

    /** Prints 'Hello, error!' to stderr. */
    public printHelloErrorToStderr(): void {
        this.commandLine.error('Hello, error!', { trace: true })
    }
}

const myClass = new MyClass(new CommandLine())

myClass.printHelloWorldToStdout()
myClass.printHelloNameToStdout()
myClass.printHelloErrorToStderr()

File System

import { FileSystem } from '@paulshryock/abstractions'

Support

Contributing

Contributions are welcome! Read the contribution guidelines, and then submit a pull request.

Maintainers

License

MIT License

About

Library of Node.js abstractions for side effects at the edges of software.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published