You can see examples in the pictures and more demo codes in the rest of post.
Javascript
TypeScript Usage of Namespace, Interface, Class, Abstract Class, Type Alias
Demo 1
Demo 2
TypeScript Enum to Builder Pattern
I just want to create some demo for enum to create a builder . I improved this concept step by step in demos. Notice that all the codes are doing same job but in a different way.
Demo 1
Continue readingTypeScript Syntax
Type Aliases, Union Types, Literal Types, Index Signature
You can find different usages of Type Aliases in the following demo code.
Type Aliases is defined with type
word.
Union Types is defined with the |
character to separate the different possible types.
Literal Types can be string, number or boolean
type SelectedEvent = "Click"; // string literal type
const buttonEvent: SelectedEvent = "Click";
type Color = "Red" | "Green" | "Blue"; // string literal type with union type
const buttonForeColor: Color = "Red";
type num = 1 | 3 | 5 | 7 | 9; // number literal type with union type
type bool = true | false; // boolean literal type with union type
type TRUE = true;
type FALSE = false;
Index Signature is defined as below
type Dictionary = {
[index: string]: any;
};
const person: Dictionary = {
"firstName": "Kenan",
"lastName": "Hancer",
"age": 36
};
interface StringArray {
[index: number]: string;
}
const names: StringArray = ["Bob", "Fred"];
let name1: string = names[0];
Type Aliases can be used with Union Types and Literal Types as below
type obj = {success: true} | {success: false}; // object
type Result<T> = { success: true, value: T } | { success: false, error: string | number }; // object
type PersonCommonFields = { firstName: string, lastName: string };
type Person = PersonCommonFields & { isDeleted: true | false };
type Name = string; // simple type
type NameResolver = () => string; // function
type NameOrResolver = Name | NameResolver;
Demo1
Continue readingJavaScript Object.assign(), Object.create()
Object.create()
The Object.create()
method creates a new object, using an existing object
Demo1
Continue readingJavaScript Object.entries(), Object.values(), Map, Set Usage
Demo1
Continue readingNode.js Axios Usage
Reverse String Algorithm
I will test different solutions to reverse a string value in JavaScript.
Syntax of String substr()
string.substr(start, length)
Solution 1: String substr()
Iteration starts from 1 to lenght of string.
Solution 2: String substr()
Iteration starts from lenght of string to 0.
Continue readingNode.js nut-ioc usage
nut-ioc npm package is a simple, lightweight and fast IoC Container Framework.
nut-ioc injects dependencies run-time so that developers don't need to require modules.
Developers can implement in their codes following OOP basics, principles, patterns and concepts and probably more than that 🙂
- Separation of Concern(SoC)
- Single Responsibility Principle(SRP)
- Open Closed Principle
- Dipendency Inversion(Injection) Principle(DIP)
- Chain of Responsibility Pattern
- Aspect Oriented Programming
you can reach github repository.
https://github.com/nodejs-projects-kenanhancer/nut-ioc
Installing nut-ioc with npm
npm i nut-ioc
Demo GitHub Repository
You can find different usages of nut-ioc framework in separate brances.
https://github.com/nodejs-projects-kenanhancer/nut-ioc-basic-demo.git
Branch list |
---|
load-dependencies-with-dependencyPath |
load-dependencies-with-dependencyPath-and_dynamically |
load-dependencies-with-different-loaders |
load-dependencies-with-interceptors |
load-dependencies-with-new-loaders-and-filters |
load-dependencies-with-programatic-notation |
nut-swagger-usage |
Node.js nut-swagger usage
nut-swagger npm package is a light-weight and flexible library to generate Node.js controller modules from swagger definition file. The controller modules generated by this npm package is also used by nut-ioc
you can reach github repository.
https://github.com/nodejs-projects-kenanhancer/nut-swagger
Continue reading