3.0.2 • Published 3 years ago
@leyyo/builder v3.0.2
Builder
Builder component for JavaScript/TypeScript
- It generates virtual setter methods with returning existing object to use continuously
- It takes care of types of properties
Install
npm i @leyyo/builder
Sample - Object
import {Builder} from "@leyyo/builder";
interface Person {
name: string;
age: number;
married: boolean;
}
const person = Builder.build<Person>();
person
.age(32)
.name('foo bar')
.married(true);
console.log(person);
// {age: 32, name: 'foo bar', married: true}
person.age('aaa'); // compile error
person.name(55); // compile error
person.married('yes'); // compile errorSample - Class
type CarColor = 'white'|'black'|'red'|'blue'|'green'|'yellow';
class Car {
brand: string;
year: number;
color: CarColor;
}
const car = Builder.build<Car>(Car);
car.brand('Toyota').year(2023).color('red');
console.log(car);
// {brand: 'Toyota', year: 2023, color: 'red'}
console.log(car.$return()); // it is casted to Car class
// Car {brand: 'Toyota', year: 2023, color: 'red'}Standards
- Language:
TS - Eslint:
Yes - Static Code Analysis:
YesIntelliJ Code Inspections - DDD - Document Driven:
NoNo required - EDD - Exception Driven:
NoNo required - TDD - Test Driven:
No
Commands
npm run clear// clears "dist" foldernpm run lint// runs eslint for static code analysisnpm run build// builds JS files at "dist" foldernpm run test// runs test files in "test" foldernpm run test:watch*// runs test with watch optionnpm run test:coverage*// runs test with coverage
Author
Date2022-12-10NameMustafa YelmerRepogithub.com/leyyonet/builder