1.2.40 • Published 2 days ago

@etsoo/shared v1.2.40

Weekly downloads
-
License
MIT
Repository
github
Last release
2 days ago

Shared

TypeScript shared utilities and functions.

Installing

Using npm:

$ npm install @etsoo/shared

Using yarn:

$ yarn add @etsoo/shared

ActionResult / IActionResult, IdActionResult, DynamicActionResult

NameDescription
static createCreate a result from error
dataResult data
detailDetails
errorsResult errors
fieldRelated field
okSuccess or failure
statusStatus code
titleTitle
traceIdTrace id
typeType

storage

Storage interface and browser storage implementation

ContentDisposition

Content disposition of HTTP

NameDescription
static parseParse header value
Methods
formatFormat to standard output

DataError

Error with custom data

EColor

Etsoo implmented Color

NameDescription
static getColorsGet HEX or RGB colors
static getEColorsGet EColors
static parseParse HTML color to EColor
Methods
cloneClone color with adjustments
getContrastRatioGet contrast ratio, a value between 0 and 1
getDeltaValueGet Delta value (perceptible by human eyes)
getLuminanceGet luminance
toHEXColorTo HEX color string
toLabValueTo Lab value
toRGBColorTo RGB color string

EventClass

Etsoo implmented abstract Event Class

NameDescription
hasEventsHas specific type and callback events
offRemove specific type and callback event
onAdd event listener
triggerTrigger event

Keyboard

Keyboard keys and codes

NameDescription
KeysKeyboardEvent.key constants
CodesKeyboardEvent.code constants

|isTypingContent|Is typing content or press command key|

EHistory

ETSOO Extended abstract history class

NameDescription
indexCurrent index
lengthStates length
stateCurrent state
statesStates
Methods
backBack to the previous state
clearClear all states but keep event listeners
forwardForward to the next state
getStatusGet undo, redo status
goGo to the specific state
pushStateAdds an entry to the history stack
replaceStateModifies the current history entry

ArrayUtils

Array related utilities

NameDescription
differencesArray 1 items do not exist in Array 2 or reverse match
maxGet max number item or number item property
maxItemGet max field value item
minGet min number item or number item property
minItemGet min field value item
sumSum number items or number item properties
toUniqueMake all items are unique

DataTypes

Data type definitions and type safe functions. ListItemType, ListItemType1 and ListItemType2 are sugar types.

NameDescription
DataTypeData type enum
AddAndEditTypeAdd and edit data type
AddOrEditTypeAdd or edit conditional type
BasicBasic types, includes number, bigint, Date, boolean, string
BasicArrayBasic type name array
BasicConditionalConditional type based on BasicNames
BasicNamesBasic type and basic type array names array
BasicTemplateBasic type template
BasicTemplateTypeBasic template type
CombinedEnumCombined type enum
CultureDefinitionCulture definition
DIDynamic interface with multiple properties
DISDynamic interface with single property
EnumBaseEnum base type
EnumValueEnum value type
ExtendedEnumExtended type enum
FuncFunction type, R is return type
HAlignHorizontal align
HAlignEnumHorizontal align enum
IdDefaultTypeId default type
IdTypeNumber and string combination id type
IdItemItem with id or id generator
IdLabelItemItem with id and label
IdLabelTypeItem with id and label dynamic type
IdNameItemItem with id and name
IdTitleItemItem with id and title
KeyCollectionKey collection, like { key1: {}, key2: {} }
KeysGet specific type keys
LabelDefaultTypeLabel default type
MConstructorMixins constructor
ObjTypeGeneric object type
OptionalMake properties optional
PlacementEnumPlacement enum
PlacementPlacement type
RequireAtLeastOneRequire at least one property of the keys
SimpleBasic or basic array type
SimpleEnumSimple type enum
SimpleNamesSimple type names
SimpleObjectSimple object, string key, simple type and null value Record
StringDictionaryString key, string value Record
StringRecordString key, unknown value Record
TitleDefaultTypeTitle default type
VAlignVertical align
VAlignEnumVertical align enum
Methods
convertConvert value to target type
convertByTypeConvert by type name like 'string'
convertSimpleConvert value to target enum type
getBasicNameGet basic type name from Enum type
getBasicNameByValueGet value's basic type name
getEnumByKeyGet enum item from key
getEnumByValueGet enum item from value
getEnumKeyGet enum string literal type value
getEnumKeysGet Enum keys
getListItemLabelGet ListType2 item label
getIdValueGet object id field value
getIdValue1Get object id field value 1
getObjectItemLabelGet object item label
getResultGet input function or value result
getStringValueGet object string field value
getValueGet object field value
isBasicNameCheck the type is a basic type or not (type guard)
isSimpleObjectIs the target a simple object, all values are simple type (Type guard)
isSimpleTypeIs the input value simple type, include null and undefined
jsonReplacerJSON.stringify replacer with full path

DateUtils

Dates related utilities

NameDescription
DayFormatYYYY-MM-DD
MinuteFormatYYYY-MM-DD hh:mm
SecondFormatYYYY-MM-DD hh:mm:ss
Methods
getDaysGet month's days
formaFormat dates
formatForInputFormat to 'yyyy-MM-dd' or 'yyyy-MM-ddThh:mm:ss, especially used for date input min/max property
jsonParserJSON parser
parseParse string to date
sameDayTwo dates are in the same day
sameMonthTwo dates are in the same month
substractDate extended method, substract a date

DomUtils

DOM/window related utilities

NameDescription
clearFormDataClear form data
CultureMatchCulture match case Enum
dataAsCast data as template format
detectedCountryCurrent detected country
detectedCultureCurrent detected culture
dimensionEqualCheck two rectangles equality
downloadFileDownload file from API fetch response body
enGet English resources definition
fileToDataURLFile to data URL
formDataToObjectForm data to object
getCultureGet the available culture definition
getDataChangesGet data changed fields with input data updated
getInputValueGet input value depending on its type
getLocationKeyGet an unique key combined with current URL
headersToObjectConvert headers to object
isFormDataIs IFormData type guard
isJSONContentTypeIs JSON content type
mergeFormDataMerge form data to primary one
mergeURLSearchParamsMerge URL search parameters
setFocusSet HTML element focus by name
setupLoggingSetup frontend logging
verifyPermissionVerify file system permission
zhHansGet simplified Chinese resources definition
zhHantGet traditional Chinese resources definition

ExtendUtils

Extend current class/object functioning

NameDescription
applyMixinsApply mixins to current class
delayedExecutorCreate delayed executor
promiseHandlerPromise handler to catch error
sleepDelay promise

NumberUtils

Numbers related utilities

NameDescription
formatFormat number
formatFileSizeFormat file size
formatMoneyFormat money number
getCurrencySymbolGet currency symbol or name from ISO code
parseParse to number, with or without default value
toExactTo the exact precision number avoiding precision lost

StorageUtils

Storage related utilities

NameDescription
setLocalDataSet local storage data
setSessionDataSet session storage data
getLocalDataGet local storage data
getLocalObjectGet local storage object data
getSessionDataGet session storage data
getSessionObjectGet session storage object data

Utils

String and other related utilities

NameDescription
addBlankItemAdd blank item to collection
charsToNumberBase64 chars to number
containChineseCheck the input string contains Chinese character or not
correctTypesCorrect object's property value type
equalsTwo values equal
excludeExclude specific items
excludeAsyncAsync exclude specific items
formatInitialFormat inital character to lower case or upper case
formatStringFormat string with parameters
getDataChangesGet data changed fields with input data updated
getNestedValueGet nested value from object
getTimeZoneGet time zone
hideDataHide data
hideEmailHide email data
isDigitsIs digits string
isEmailIs email string
joinItemsJoin items as a string
mergeFormDataMerge form data to primary one
mergeClassesMerge class names
newGUIDCreate a GUID
numberToCharsNumber to base64 chars
objectEqualTest two objects are equal or not
objectKeysGet two object's unqiue properties
objectUpdatedGet the new object's updated fields contrast to the previous object
parseJsonArrayTry to parse JSON input to array
parsePathParse path similar with node.js path.parse
parseStringParse string (JSON) to specific type
removeNonLettersRemove non letters (0-9, a-z, A-Z)
replaceNullOrEmptyReplace null or empty with default value
setLabelsSet source with new labels
setNestedValueSet nested value to object
snakeNameToWordSnake name to works, 'snake_name' to 'Snake Name'
sortByFavorSort array by favored values
sortByFieldFavorSort array by favored field values
trimTrim chars
trimEndTrim end chars
trimStartTrim start chars
1.2.40

2 days ago

1.2.38

2 days ago

1.2.37

12 days ago

1.2.36

2 months ago

1.2.34

2 months ago

1.2.35

2 months ago

1.2.33

2 months ago

1.2.32

2 months ago

1.2.29

2 months ago

1.2.30

2 months ago

1.2.31

2 months ago

1.2.27

2 months ago

1.2.28

2 months ago

1.2.26

3 months ago

1.2.24

3 months ago

1.2.25

3 months ago

1.2.18

6 months ago

1.2.19

6 months ago

1.2.20

6 months ago

1.2.21

6 months ago

1.2.22

6 months ago

1.2.8

10 months ago

1.2.12

8 months ago

1.2.13

8 months ago

1.2.10

8 months ago

1.2.11

8 months ago

1.2.16

7 months ago

1.2.17

7 months ago

1.2.14

8 months ago

1.2.15

8 months ago

1.2.9

9 months ago

1.1.92

1 year ago

1.1.91

1 year ago

1.1.90

1 year ago

1.1.96

1 year ago

1.1.95

1 year ago

1.1.94

1 year ago

1.1.93

1 year ago

1.1.99

1 year ago

1.1.98

1 year ago

1.1.97

1 year ago

1.2.0

1 year ago

1.2.7

11 months ago

1.2.6

11 months ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.89

1 year ago

1.1.85

1 year ago

1.1.84

1 year ago

1.1.83

1 year ago

1.1.82

1 year ago

1.1.88

1 year ago

1.1.87

1 year ago

1.1.86

1 year ago

1.1.70

2 years ago

1.1.74

2 years ago

1.1.73

2 years ago

1.1.72

2 years ago

1.1.71

2 years ago

1.1.78

1 year ago

1.1.77

1 year ago

1.1.76

1 year ago

1.1.75

2 years ago

1.1.79

1 year ago

1.1.81

1 year ago

1.1.80

1 year ago

1.1.56

2 years ago

1.1.55

2 years ago

1.1.54

2 years ago

1.1.53

2 years ago

1.1.59

2 years ago

1.1.58

2 years ago

1.1.57

2 years ago

1.1.63

2 years ago

1.1.62

2 years ago

1.1.61

2 years ago

1.1.60

2 years ago

1.1.67

2 years ago

1.1.66

2 years ago

1.1.65

2 years ago

1.1.64

2 years ago

1.1.69

2 years ago

1.1.68

2 years ago

1.1.41

2 years ago

1.1.45

2 years ago

1.1.44

2 years ago

1.1.43

2 years ago

1.1.42

2 years ago

1.1.49

2 years ago

1.1.48

2 years ago

1.1.47

2 years ago

1.1.46

2 years ago

1.1.52

2 years ago

1.1.51

2 years ago

1.1.50

2 years ago

1.1.38

2 years ago

1.1.37

2 years ago

1.1.39

2 years ago

1.1.40

2 years ago

1.1.29

2 years ago

1.1.28

2 years ago

1.1.30

2 years ago

1.1.34

2 years ago

1.1.33

2 years ago

1.1.32

2 years ago

1.1.31

2 years ago

1.1.36

2 years ago

1.1.35

2 years ago

1.1.27

2 years ago

1.1.23

2 years ago

1.1.22

2 years ago

1.1.21

2 years ago

1.1.20

2 years ago

1.1.26

2 years ago

1.1.25

2 years ago

1.1.24

2 years ago

1.1.19

2 years ago

1.1.18

2 years ago

1.0.79

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.17

2 years ago

1.0.80

2 years ago

1.0.84

2 years ago

1.0.83

2 years ago

1.0.82

2 years ago

1.0.81

2 years ago

1.0.88

2 years ago

1.0.87

2 years ago

1.0.86

2 years ago

1.0.85

2 years ago

1.0.89

2 years ago

1.0.91

2 years ago

1.0.90

2 years ago

1.0.95

2 years ago

1.0.94

2 years ago

1.0.93

2 years ago

1.0.92

2 years ago

1.0.99

2 years ago

1.0.98

2 years ago

1.0.97

2 years ago

1.0.96

2 years ago

1.0.77

2 years ago

1.0.76

2 years ago

1.0.78

2 years ago

1.0.69

3 years ago

1.0.68

3 years ago

1.0.73

3 years ago

1.0.72

3 years ago

1.0.71

3 years ago

1.0.70

3 years ago

1.0.75

2 years ago

1.0.74

2 years ago

1.0.66

3 years ago

1.0.65

3 years ago

1.0.64

3 years ago

1.0.63

3 years ago

1.0.67

3 years ago

1.0.62

3 years ago

1.0.61

3 years ago

1.0.60

3 years ago

1.0.59

3 years ago

1.0.58

3 years ago

1.0.57

3 years ago

1.0.48

3 years ago

1.0.47

3 years ago

1.0.46

3 years ago

1.0.45

3 years ago

1.0.49

3 years ago

1.0.51

3 years ago

1.0.50

3 years ago

1.0.55

3 years ago

1.0.54

3 years ago

1.0.53

3 years ago

1.0.52

3 years ago

1.0.56

3 years ago

1.0.44

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.40

3 years ago

1.0.41

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.33

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.26

3 years ago

1.0.27

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.22

3 years ago

1.0.23

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago