hikari-es-extensions v0.0.41
hikari-es-extensions
Logging
BasicFrontEndLoggerProvides the formatting for browser console that is commonly enough for early phase of web application development. Could be extended for adding of output destinations, limitations or formatting customization.ConsoleApplicationLoggerProvides the formatting for NodeJS terminal. Could be extended for upgrading to backend application logger with, for example, additional logging to data base.
Classes
Stopwatch
Quick example
const stopwatch: Stopwatch = new Stopwatch();
stopwatch.start();Or shortly:
const stopwatch: Stopwatch = new Stopwatch().start();It's possible to stop the stopwatch and get the elapsed time data in one line, too:
const ellaplesTime__seconds = stopwatch.stop().getElapsedTimeData().seconds;UML-like schema
Stopwatch {
+start(): Stopwatch
+stop(): Stopwatch
+getElapsedTimeData(): Stopwatch.ElapsedTimeData;
+reset(): void
}Here ElapsedTimeData is:
type ElapsedTimeData = {
readonly seconds: number;
readonly milliseconds: number;
};Random values generators
Get random string
getRandomString(
parametersObject: {
fixedSymbolsCount?: number;
minimalSymbolsCount?: number;
maximalSymbolsCount?: number;
prefix?: string;
} = {}
): string- If
fixedSymbolsCountspecified,minimalSymbolsCountandmaximalSymbolsCountwill be ignored. - If
maximalSymbolsCountandminimalSymbolsCountspecified,maximalSymbolsCountmust be greater thanminimalSymbolsCount. - If
prefixspecified, it must be smaller thanmaximalSymbolsCountandfixedSymbolsCount.
Browser JavaScript functionality
Create element
createElement(HTML_Code: string): ElementCreates single Element. If HTML code which first parameter
contains has more than one root Element, ImproperUsageError will be thrown. If are want to support the scenario for
multiple root elements, user createElements function instead.
Create elements
createElements(HTML_Code: string): HTMLCollectionAllows to create the HTMLCollection from HTML code by one line of code instead of below routine:
const container: Document = document.implementation.createHTMLDocument();
container.body.innerHTML = HTML_Code;
return container.body.children;Implementation for the front-end application
Implementation for the back-end application
Implementation for the console application
NodeJS functionality
Improved path
Theory
Path separators
Parse path
Retrieving of file name without extension ImprovedPath.filenameWithoutExtension
For /home/user/dir/file, Path.parse() will return Path.ParsedPath object with empty string value of name property.
In ImprovedPath.ParsedPath, filenameWithoutExtension will be undefined.
If you are expecting that filenameWithoutExtension must be defined, use getFilenameWithoutExtensionWhichExpectedToBeDefined
getter instead, but if actually filenameWithoutExtension will be undefined, UnexpectedEventError will be thrown.
- When filename has single extension only (e. g.
.gitignore),Path.parse()will consider it asbaseandextwill be empty. - When filename has multiple extensions, all of them except last one will be included to
filenameWithoutExtension.
Roadmap
Future ecosystem
@yamato-daiwa/es-extensions is being used and will be used by everythig that written in TypeScript by Tokugawa Takesi
and Yamato Daiwa, his future startup.
Libraries
@yamato-daiwa/automation@yamato-daiwa/frontend@yamato-daiwa/backend@yamato-daiwa/data
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago