GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - OpenFoxes/ts-builder: Dynamic Builder for realizing the Builder pattern on interfaces

BranchesTags
Open more actions menu

Latest commit

 

History

27 Commits
27 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.idea
.idea
 
 
internal
internal
 
 
src
src
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
jest.config.js
jest.config.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
sonar-project.properties
sonar-project.properties
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

Attention!

This package is in an early development stage!

Currently there is no stable builder available.

The current phase tests different approaches as well as the deployment itself.


👷

TS-Builder

The builder pattern for TypeScript

Version 0.2.0

Quality gate


Information

This library allows you to use the Builder Pattern for types and interfaces in TypeScript. It aims to work dynamically without the need for separately generated builder classes. It should be applicable to existing code without requiring additional modifications.

Usage

To generate a builder for the interface "Frog" just create a TSBuilder:

import TsBuilder from "@openfoxes/ts-builder";

interface Frog {
  name: string;
  color: "green" | "red";
  calm: boolean;
}

// Use the TsBuilder:
const immutableFrogBuilder = TsBuilderImmutable.makeBuilderFor<Frog>();
const frog = immutableFrogBuilder
  .set("name", "Klaus")
  .set("color", "green")
  .set("calm", true)
  .build();

/**
 * In the future the current usages should be possible:
 */

// The js-classic-builder, currently NOT possible:
const classicFrogBuilder = TsBuilder.makeBuilderFor<Frog>();
classicFrogBuilder.set("name", "Klaus").set("color", "green").set("calm", true);
const frog = classicFrogBuilder.build();

// The optimal TsBuilder (using Proxy), currently NOT possible:
const frogBuilder = TsBuilder.makeBuilderFor<Frog>();
const frog = frogBuilder
  .set("name", "Klaus")
  .set("color", "green")
  .set("calm", true)
  .build();

Pre-requisites

Install the package:

npm install @openfoxes/ts-builder

or

npm install -E @openfoxes/[email protected]

Development

This repository strives to make the best possible use of TypeScript's capabilities. However, it is unfortunately not easily possible to provide a fully-fledged builder dynamically and in real-time. Work is ongoing to offer more user-friendly methods in the future and to improve error handling. For now, though, it is already an improvement over relying solely on constructors or manually creating builders.

Code Quality

This project aims to provide a clean and secure design. In order to optimize the underlying code and reducing the risk of bugs, quality tools are used:

Quality gate

Bugs Code Smells Duplicated Lines (%)

About

Dynamic Builder for realizing the Builder pattern on interfaces

Resources

Readme
Activity
Custom properties

Stars

3 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.