1.6.11 • Published 1 day ago

@yamato-daiwa/es-extensions v1.6.11

Weekly downloads
-
License
MIT
Repository
github
Last release
1 day ago

@yamato-daiwa/es-extensions

Helper functions and classes aimed to reduce the routine code. Build-in TypeScript type safety without any type.

Installation

npm i @yamato-daiwa/es-extensions -E

Temporary simple documentation

Please refer to this documentation during the official documentation is under development.

Get functionality

Most of the functionality is available for both Browser JavaScript and Node.js.

export { isUndefined, isNull } from "@yamato-daiwa/es-extensions";

BrowserJS functionality

export { delegateClickEventHandling } from "@yamato-daiwa/es-extensions/BrowserJS";

NodeJS functionality

export { NodeJS_Timer } from "@yamato-daiwa/es-extensions/NodeJS";

Functionality reference

Numbers

Strings

All functions working with strings supports the surrogate pairs. If some function works incorrectly with surrogate pairs, it means the bug; please feel free to open issue in this case.

  • areStringifiedDigitsOnly Checks is string value consists exclusively from the digits.
  • capitalizeFirstSymbol Capitalizes first symbol of target string value.
  • getLastSymbol Returns the last symbol of target string value.
  • getPositionsOfAllSubstringOccurrences Returns the positions of each occurrence of specified substring.
  • removeAllSpecifiedCharacters Removes specified characters from the string value.
  • removeNonDigitsCharacters Removes all characters from the string excepts digits.
  • removeNthSymbol Removes the symbol in specified position from the string. Supports the surrogate pairs.
  • replace2OrMoreSpacesTo1 eplaces 2 or more spaces to 1.
  • replaceBrHTML_TagToNewLineEscapeSequence Replaces the "br" HTML tag to new line (line feed) escape sequence.
  • insertSubstring Insets nullable substring with optional condition and transformations.
  • insertSubstringIf Insets substring conditionally.
  • reverseString Reverses the symbols sequence in string value.
  • splitString Alternative of native String.prototype.split() supporting surrogate pairs.
  • stringifyAndFormatUnknownAtAdvanceEntity Converts to readable string any type of data.

Arrays

  • getArrayElementWhichMustExistByPredicate Returns the first satisfies to predicate array element. If no such element, UnexpectedEventError will be thrown.
  • getLastElementOfNonEmptyArray Return the last element of array. If no such element, UnexpectedEventError will be thrown.
  • getIndexesOfArrayElementsWhichSatisfiesToPredicate Returns the array of indexes of elements of array which are satisfies to predicate function.
  • getIndexOfArrayElementByPredicate Returns the index of array element matching with predicate of null if no such element.

Sets

Maps

Date & Time

Types

  • ParsedJSON and related The native object including the Array case which could be the result of JSON parsing.
  • PartialBy Makes specified properties of base type optional.

Type guards

Default value subsituters

  • substituteWhenNull Substitutes the second argument's value when first one is null
  • substituteWhenUndefined Substitutes the second argument's value when first one is undefined

Value transformers

  • emptyStringToNull
  • nullToEmptyString
  • nullToUndefined
  • nullToZero
  • undefinedToEmptyArray
  • undefinedToEmptyString
  • undefinedToNull

Random values generators

  • getRandomArrayElement Returns the random element of specified array.
  • getRandomBoolean Returns true or false randomly.
  • getRandomInteger Returns random integer not less than specified minimalValue and more than maximalValue.
  • getRandomLatinSymbol Returns random latin symbol.
  • getRandomObjectPropertyValue Returns random object property value.
  • getSpecificBooleanValueWithProbability Returns specific boolean value with specified probability.

Constants and Enumerations

Pagination

Logging

  • Logger facade Basic facade for providing of the high-quality logging with customizable output destinations, formatting and limitations.
  • BasicFrontEndLogger The implementation of ILogger interface for the Logger facade which could be used as the base of the custom implementation for the frontend side of the websites / web application.
  • Pre-made errors
    • AlgorithmMismatchError Recommended to throw in general cases when real behaviour of the program is not corresponding to desired.
    • ClassRedundantSubsequentInitializationError Recommended to throw when the class intended to be a singleton has been attempted to initialize twice.
    • ClassRequiredInitializationHasNotBeenExecutedError Recommended to throw when the class besides the construction requires the initialization, but the initialization has not been executed.
    • ConfigFileNotFoundError Recommended to throw when some utility requires the config file bit it has not been found.
    • CrossBrowserIssueError Recommended to throw when some processing could not be executed because of certain browsers's limitations.
    • DataRetrievingFailedError Recommended to throw when the data retrieving from any external resource (server, database, etc.) was failed.
    • DataSubmittingFailed Recommended to throw when the data submitting to any external resource (server, database, etc.) was failed.
    • DOM_ElementRetrievingFailedError Recommended to throw when some requiring element retrieving from the DOM has been failed.
    • FileReadingFailedError Recommended to throw when the file reading was not go as expected.
    • FileWritingFailed Recommended to throw when the file writing was not go as expected.
    • ImproperUsageError Recommended to throw when the cass/function has been attempted to use improperly. However, try to name the function/methods such as it will be obvious how to use it and also limit the usage by TypeScript typing.
    • IncompatiblePropertiesInObjectTypeParameterError Recommended to throw when in parameter exampleParameter of object type one of properties exampleParameter.propertyA and exampleParameter.propertyB must be omitted but both has been specified.
    • InterProcessInteractionFailedError Recommended to throw when the interaction between NodeJS processed is not going as expected. Could be actual for the Electron.js where the main process and render process exchanging by data.
    • InvalidConfigError Recommended to throw when config validation was not passed. Append the validation errors messages to InvalidConfigError's message.
    • InvalidExternalDataError Recommended to throw when the data from the external data source does not match with expected. Append the validation errors messages to InvalidExternalDataError's message.
    • InvalidParameterValueError Recommended to throw when the parameter's does not fit to some limitations. Although the TypeScript allows to define and check the parameter's type, this functionality will not be available if the library will be used by JavaScript users. Also, is the parameter has limitations like smallest numerical value or maximal symbols count, InvalidParameterValueError has been developed for such cases.
    • ModuleDynamicLoadingFailedError Recommended to throw when the module dynamical loading failed.
    • UnexpectedEventError Recommended to throw when the probability of the occurrence of some else if branch is very small and impossible for normal operation of the program.
    • UnsupportedScenarioError Recommended to throw when occurred some scenario which the does not supports yet.
1.7.0-rc.0

1 day ago

1.7.0-alpha.13

1 month ago

1.7.0-alpha.12

1 month ago

1.7.0-alpha.14

22 days ago

1.7.0-alpha.11

2 months ago

1.7.0-alpha.10

3 months ago

1.7.0-alpha.9

3 months ago

1.7.0-alpha.7

3 months ago

1.7.0-alpha.8

3 months ago

1.7.0-alpha.6

4 months ago

1.6.11

5 months ago

1.6.10

5 months ago

1.7.0-alpha.5

6 months ago

1.7.0-alpha.3

8 months ago

1.7.0-alpha.4

8 months ago

1.7.0-alpha.1

8 months ago

1.7.0-alpha.2

8 months ago

1.7.0-alpha.0

8 months ago

1.6.9

1 year ago

1.6.8

1 year ago

1.6.7

1 year ago

1.6.5

1 year ago

1.6.4

1 year ago

1.6.2

1 year ago

1.5.3-alpha.0

2 years ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.5

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.6.0-alpha.1

2 years ago

1.5.1

2 years ago

1.6.0-alpha.0

2 years ago

1.5.0

2 years ago

1.6.0-alpha.5

1 year ago

1.6.0-alpha.4

2 years ago

1.6.0-alpha.3

2 years ago

1.6.0-alpha.2

2 years ago

1.6.0-alpha.7

1 year ago

1.6.0-alpha.6

1 year ago

1.5.0-alpha.0

2 years ago

1.5.0-alpha.1

2 years ago

1.5.0-alpha.2

2 years ago

1.5.0-alpha.3

2 years ago

1.5.0-alpha.4

2 years ago

1.5.0-alpha.5

2 years ago

1.5.0-alpha.6

2 years ago

1.5.0-alpha.7

2 years ago

1.5.0-alpha.8

2 years ago

1.5.0-alpha.9

2 years ago

1.4.5

2 years ago

1.5.8

1 year ago

1.5.7

2 years ago

1.5.6

2 years ago

1.4.0-alpha.0

2 years ago

1.4.0-alpha.1

2 years ago

1.4.0-alpha.2

2 years ago

1.4.0-alpha.3

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.4.0-alpha.8

2 years ago

1.4.0-alpha.9

2 years ago

1.4.0-alpha.4

2 years ago

1.4.0-alpha.5

2 years ago

1.4.0-alpha.6

2 years ago

1.4.0-alpha.7

2 years ago

1.3.0-alpha.8

3 years ago

1.3.0-alpha.7

3 years ago

1.4.0-alpha.15

2 years ago

1.4.0-alpha.13

2 years ago

1.4.0-alpha.14

2 years ago

1.4.0-alpha.11

2 years ago

1.4.0-alpha.12

2 years ago

1.4.0-alpha.10

2 years ago

1.3.0

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.3.0-alpha.6

3 years ago

1.3.0-alpha.5

3 years ago

1.3.0-alpha.2

3 years ago

1.3.0-alpha.4

3 years ago

1.3.0-alpha.3

3 years ago

1.3.0-alpha.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.3.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.1.1

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago