3.0.11 β€’ Published 1 year ago

@p4ck493/ts-is v3.0.11

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

ts-is

NPM Latest Version Downloads Count Bundle Size Stars

🌍 Languages

πŸ‡ΊπŸ‡¦ ukraine | πŸ‡¬πŸ‡§ english

Introduction

Why you should use and support the package:

  1. βœ… Typification.
  2. βœ… Reducing the code in the project.
  3. βœ… Easier to read and understand the code.
  4. βœ… CDN support.
  5. βœ… Compatible with the oldest version of JavaScript (ES6 - ECMAScript 2015).
  6. βœ… Compatible with the oldest version of TypeScript (0.8.0).
  7. βœ… Maintenance of global contexts: globalThis, window, self, global.
  8. βœ… No dependencies
  9. βœ… AMD, Node & browser ready
  10. βœ… Small size: ~8KB.

πŸ’‘ Idea

this package was created in order to simplify writing in typescript / javascript, it often happens that you need to have checks for different types of data, these checks can be "huge", but if you could simply describe in words what we want to check?

For example, why write:

if (typeof variable === 'object' && variable !== null && !Array.isArray(variable) && Object.keys(variable)?.length) {
}

if you can write something like:

if (is.object.not.empty(variable)) {
}

πŸ“ Table of contents

πŸ’Ώ Installation

npm install @p4ck493/ts-is

πŸ”— CDN

<script>
  var exports = {};
</script>
<script src="//unpkg.com/@p4ck493/ts-is@3.0.8/dist/index.js"></script>
<script>
  const { is } = exports;
  console.log(is.string('')); // true
</script>

Back to table of contents

πŸ™Œ Usage

import {is} from "@p4ck493/ts-is";

Examples

Syntax

$method = 'ANY_METHOD_NAME';

is[$method]();
is[$method][$method]();
is[$method].or[$method]();
is[$method].not[$method]();

$model = 'ANY_MODEL_WICH_DECLARE_IN_PACKAGE_BY_DECORATOR'; // Decorator: @RegisterInIs()

is[$model]();
is[$model][$model]();
is[$model].or[$model]();
is[$model].not[$model]();

// And yes, you can mix:

is[$cmd][$model]();
is[$model].or[$cmd]();
is[$cmd].not[$model]();

Methods

import {IsConfig} from './index';

is.array([]); // true

is.bigInt(1n); // true

is.boolean(false); // true

is.compare({a: 1}, {a: 1}); // true
is.compare({a: 1}, {}); // false
is.compare({}, {a: 1}); // false
is.compare({}, {}); // true

is.Date(new Date()); // true

is.empty(''); // true
is.empty(' '); // true
is.empty(new Map()); // true
is.empty({}); // true
is.empty([]); // true

is.Error(new Error()); // true

is.EvalError(new EvalError()); // true

is.false(false); // true

is.DataView(new DataView(new ArrayBuffer(16), 0)); // true

is.falsy(''); // true

// This method will check if the argument is equal to the base type: Function
is.Function(() => {
}); // true

// This method checks not only if the argument is a function, but also if the argument is an asynchronous function or a generative
is.function(() => {
}); // true

is.instanceof(new Boolean(false), Boolean); // true

is.Map(new Map()); // true

is.null(null); // true

is.number(0); // true

is.object({}); // true

is.ReferenceError(new ReferenceError()); // true

is.RegExp(new RegExp()); // true

is.Set(new Set()); // true

is.string(''); // true

is.symbol(Symbol()); // true

is.SyntaxError(new SyntaxError()); // true

is.true(true); // true

is.truthy(1); // true

is.TypeError(new TypeError()); // true

is.undefined(undefined); // true

is.URIError(new URIError()); // true

is.WeakMap(new WeakMap()); // true

is.WeakSet(new WeakSet()); // true

is.len_5('words') // true
is.len_4('words') // false
is.len_gt_4('words') // true
is.len_lt_5('words') // false
is.len_lte_5('words') // true
is.len_gte_5('words') // true
is.len_gt_4_lt_6('words') // true
is.len_gte_5_lt_6('words') // true
is.len_gt_4_lte_5('words') // true

// You can also configure global package settings
IsConfig.error.enabled = false; // In this case, all console.error will be disabled, they are enabled by default.

// If you need to change the regex say for macAddress, here is an example:
IsConfig.regex.macAddress = /[Your regex]/;

// If you don't want the package to fight in the global context, then do it like this:
IsConfig.useGlobalContext = false;

Methods with connection

is.array.empty([]); // true

is.bigInt.or.number(-1); // true

is.boolean.or.truthy('false'); // true

is.false.or.falsy(''); // true

is.null.or.undefined(null); // true

is.object.or.Function({}); // true
is.object.or.function({}); // true

is.string.or.true.or.symbol(true); // true

Methods with wrappers

is.object.not.empty({ a: 1 }); // true

is.not.object({}); // false

is.not.number(1n); // true

Back to table of contents

Methods with your models

You have the option to add any class to the package yourself for further testing

@RegisterInIs({
  className: 'person', // You can customize the model name, i.e.: is.person((new Person())) // true
})
class PersonModel {}

@RegisterInIs({
  className: 'woman',
})
class WomanModel extends PersonModel {}

@RegisterInIs({
  className: 'man',
})
class ManModel extends PersonModel {}

@RegisterInIs()
class AddressModel {}

const person = new PersonModel();
const man = new ManModel();
const woman = new WomanModel();
const address = new AddressModel();

is.person(person); // true

is.person(man); // true

is.person(woman); // true

is.person(address); // false

is.man(person); // false

is.woman(person); // false

is.AddressModel(address); // true

is.woman.or.man(woman); // true

is.not.woman(man); // true

is.not.man(man); // false

// Good Example: Cart

@RegisterInIs()
class Cart {
  public size: number = 0;
}

const cart: Cart = new Cart();
is.Cart.empty(cart); // true
cart.size = 1;
is.Cart.empty(cart); // false

// Bad Example: Cart

@RegisterInIs()
class CartTwo {
  public total: number = 0;
}

const cartTwo: CartTwo = new CartTwo();
is.CartTwo.empty(cartTwo); // false
cartTwo.size = 1;
is.CartTwo.empty(cartTwo); // false
CDN
const { RegisterInIs } = exports;

// Person
class PersonModel {
  // Your code ...
}

RegisterInIs()(PersonModel);

// Woman
class WomanModel extends PersonModel {
  // Your code ...
}

RegisterInIs({
  className: 'woman',
})(WomanModel);

// Check
const person = new PersonModel();
const woman = new WomanModel();

// Check
is.PersonModel(person); // true
is.PersonModel(woman); // true
is.woman(woman); // true
is.woman(person); // false

Custom method

@RegisterInIs({
  customMethod: 'customNameOfMethod',
})
class PostModel {
  public static customNameOfMethod(argument: unknown): argument is PostModel {
    return `Hello ${argument}`;
  }
}

is.PostModel('world'); // Returns: Hello world

Back to table of contents

Use Cases

array:filter

const onlyNumbers: number[] = [0, 1, '', 'test'];
console.log(onlyNumbers.filter(is.number)); // [0, 1]

const onlyStringList: string[] = [0, 1, '', 'test'];
console.log(onlyStringList.filter(is.string)); // ['', 'test']

const onlyNotEmptyStringList: string[] = [0, 1, '', 'test'];
console.log(onlyNotEmptyStringList.filter(is.string.not.empty)); // ['test']

array:some

const onlyNumbers: number[] = [0, 1, '', 'test'];
console.log(onlyNumbers.some(is.string.or.object)); // true

const onlyStringList: string[] = [0, 1, '', 'test'];
console.log(onlyStringList.some(is.not.symbol)); // false

const onlyNotEmptyStringList: string[] = [0, 1, '', 'test'];
console.log(onlyNotEmptyStringList.some(is.string.empty)); // true

array:every

const onlyNumbers: number[] = [0, 1, '', 'test'];
console.log(onlyNumbers.every(is.string.or.number)); // true

const onlyStringList: string[] = [0, 1, '', 'test'];
console.log(onlyStringList.every(is.string)); // false

const onlyNotEmptyStringList: string[] = [0, 1, '', 'test'];
console.log(onlyNotEmptyStringList.every(is.not.object)); // true

observable:pipe:filter

const stream$: Stream<boolean> = new Stream<boolean>();

stream$.pipe(filter(is.boolean)).subscribe(console.log); // true, false

stream$.next([false]); // Bad[README.ua.md](README.ua.md)
stream$.next(0); // Bad

stream$.next(true); // Good

stream$.next({ false: false }); // Bad

stream$.next(false); // Good

stream$.next(1); // Bad
stream$.next('false'); // Bad

Back to table of contents

πŸ—ƒοΈ API

All methods return a boolean type

List of methods

NameTestsStatusNew nameComment
arrayβœ…
bigIntβœ…
booleanβœ…
charβœ…πŸ†•
compareβœ…
emptyβœ…
evenβœ…πŸ†•
falseβœ…
falsyβœ…
functionβœ…RETURNEDif there is a need to check whether something from the package is a function, use is.Function instead of is.function
asyncFunctionβž–
generatorFunctionβž–
instanceofβœ…
intβœ…πŸ†•
ipv4βœ…πŸ†•
ipv6βœ…πŸ†•
len_Nβœ…πŸ†•N - Any positive integer
len_gt_Nβœ…πŸ†•gt - greater than
len_lt_Nβœ…πŸ†•lt - less than
len_lte_Nβœ…πŸ†•lte - less then or equal
len_gte_Nβœ…πŸ†•gte - greater then or equal
len_gt_N_lt_Nβœ…πŸ†•
len_gte_N_lt_Nβœ…πŸ†•
len_gte_N_lte_Nβœ…πŸ†•
len_gt_N_lte_Nβœ…πŸ†•
macAddressβœ…πŸ†•
nullβœ…
numberβœ…
numericβœ…πŸ†•
objectβœ…
oddβœ…πŸ†•
stringβœ…
symbolβœ…
trueβœ…
truthyβœ…
infinityβœ…
undefinedβœ…
NaNβž–DELETEDisNaN()
wordβœ…
zeroβœ…
positiveβœ…Validate if number is more than 0
negativeβœ…Validate if number is less than 0
primitiveβœ…string, number, NaN, bigint, boolean, undefined, symbol, null
promiseβž–

Name - the name of a method that you can call to check certain types of data.

Tests - note the status of whether tests were written in the project to verify this method.

Status - we inform you that the method has been deleted, but if the tests are marked as OK, it means that this method is available, but has a different name and the tests are also written.

New name - informs that this method now has a new name.

List of wrappers and connections

NameTestsStatus
notβœ…
orβœ…
allβž–DELETED

New methods that are available through the package, but which are only declared in the package, but actually take data from outside the package.

Generale (841 methods)

NameTests
Mapβœ…
Stringβž–
Dateβœ…
Setβœ…
URIErrorβœ…
RegExpβœ…
WeakSetβœ…
WeakMapβœ…
DataViewβœ…
Float32Arrayβž–
Int32Arrayβž–
Uint8ClampedArrayβž–
Int8Arrayβž–
Uint8Arrayβž–
Int16Arrayβž–
Uint16Arrayβž–
Uint32Arrayβž–
Float64Arrayβž–
BigInt64Arrayβž–
BigUint64Arrayβž–
RangeErrorβž–
Errorβœ…
EvalErrorβœ…
ReferenceErrorβœ…
SyntaxErrorβœ…
TypeErrorβœ…
Algorithmβž–
AssignedNodesOptionsβž–
AudioBufferOptionsβž–
AudioBufferSourceOptionsβž–
AudioConfigurationβž–
AudioContextOptionsβž–
AudioNodeOptionsβž–
AudioTimestampβž–
AuthenticationExtensionsClientInputsβž–
AuthenticationExtensionsClientOutputsβž–
AuthenticatorSelectionCriteriaβž–
BlobEventInitβž–
BlobPropertyBagβž–
CSSStyleSheetInitβž–
CacheQueryOptionsβž–
CanvasRenderingContext2DSettingsβž–
ClientQueryOptionsβž–
ClipboardItemOptionsβž–
ComputedKeyframeβž–
ConstantSourceOptionsβž–
ConstrainBooleanParametersβž–
ConstrainDOMStringParametersβž–
CredentialCreationOptionsβž–
CredentialPropertiesOutputβž–
CredentialRequestOptionsβž–
CryptoKeyPairβž–
DOMMatrix2DInitβž–
DOMPointInitβž–
DOMQuadInitβž–
DOMRectInitβž–
DeviceMotionEventAccelerationInitβž–
DeviceMotionEventRotationRateInitβž–
DisplayMediaStreamOptionsβž–
DocumentTimelineOptionsβž–
DoubleRangeβž–
EffectTimingβž–
ElementCreationOptionsβž–
ElementDefinitionOptionsβž–
EventInitβž–
EventListenerOptionsβž–
EventSourceInitβž–
FileSystemFlagsβž–
FileSystemGetDirectoryOptionsβž–
FileSystemGetFileOptionsβž–
FileSystemRemoveOptionsβž–
FocusOptionsβž–
FontFaceDescriptorsβž–
FullscreenOptionsβž–
GetAnimationsOptionsβž–
GetNotificationOptionsβž–
GetRootNodeOptionsβž–
IDBDatabaseInfoβž–
IDBIndexParametersβž–
IDBObjectStoreParametersβž–
IDBTransactionOptionsβž–
IdleRequestOptionsβž–
ImageBitmapOptionsβž–
ImageBitmapRenderingContextSettingsβž–
ImageDataSettingsβž–
ImportMetaβž–
IntersectionObserverEntryInitβž–
IntersectionObserverInitβž–
JsonWebKeyβž–
KeyAlgorithmβž–
Keyframeβž–
LockInfoβž–
LockManagerSnapshotβž–
LockOptionsβž–
MediaCapabilitiesInfoβž–
MediaConfigurationβž–
MediaElementAudioSourceOptionsβž–
MediaImageβž–
MediaKeySystemConfigurationβž–
MediaKeySystemMediaCapabilityβž–
MediaMetadataInitβž–
MediaPositionStateβž–
MediaRecorderOptionsβž–
MediaSessionActionDetailsβž–
MediaStreamAudioSourceOptionsβž–
MediaStreamConstraintsβž–
MediaTrackCapabilitiesβž–
MediaTrackConstraintSetβž–
MediaTrackSettingsβž–
MediaTrackSupportedConstraintsβž–
MutationObserverInitβž–
NavigationPreloadStateβž–
NotificationActionβž–
NotificationOptionsβž–
OfflineAudioContextOptionsβž–
OptionalEffectTimingβž–
PaymentCurrencyAmountβž–
PaymentDetailsBaseβž–
PaymentDetailsModifierβž–
PaymentItemβž–
PaymentMethodDataβž–
PaymentValidationErrorsβž–
PerformanceMarkOptionsβž–
PerformanceMeasureOptionsβž–
PerformanceObserverInitβž–
PeriodicWaveConstraintsβž–
PermissionDescriptorβž–
PositionOptionsβž–
PropertyIndexedKeyframesβž–
PublicKeyCredentialCreationOptionsβž–
PublicKeyCredentialDescriptorβž–
PublicKeyCredentialEntityβž–
PublicKeyCredentialParametersβž–
PublicKeyCredentialRequestOptionsβž–
PushSubscriptionJSONβž–
PushSubscriptionOptionsInitβž–
QueuingStrategyInitβž–
RTCCertificateExpirationβž–
RTCConfigurationβž–
RTCDataChannelInitβž–
RTCDtlsFingerprintβž–
RTCEncodedAudioFrameMetadataβž–
RTCEncodedVideoFrameMetadataβž–
RTCErrorInitβž–
RTCIceCandidateInitβž–
RTCIceServerβž–
RTCLocalSessionDescriptionInitβž–
RTCOfferAnswerOptionsβž–
RTCRtcpParametersβž–
RTCRtpCapabilitiesβž–
RTCRtpCodecCapabilityβž–
RTCRtpCodecParametersβž–
RTCRtpCodingParametersβž–
RTCRtpContributingSourceβž–
RTCRtpHeaderExtensionCapabilityβž–
RTCRtpHeaderExtensionParametersβž–
RTCRtpParametersβž–
RTCRtpTransceiverInitβž–
RTCSessionDescriptionInitβž–
RTCStatsβž–
ReadableStreamGetReaderOptionsβž–
RegistrationOptionsβž–
RequestInitβž–
ResizeObserverOptionsβž–
ResponseInitβž–
RsaOtherPrimesInfoβž–
SVGBoundingBoxOptionsβž–
ScrollOptionsβž–
ShadowRootInitβž–
ShareDataβž–
StaticRangeInitβž–
StorageEstimateβž–
StreamPipeOptionsβž–
StructuredSerializeOptionsβž–
TextDecodeOptionsβž–
TextDecoderOptionsβž–
TextEncoderEncodeIntoResultβž–
TouchInitβž–
ULongRangeβž–
UnderlyingByteSourceβž–
ValidityStateFlagsβž–
VideoColorSpaceInitβž–
VideoConfigurationβž–
VideoFrameCallbackMetadataβž–
WebGLContextAttributesβž–
WorkerOptionsβž–
WorkletOptionsβž–
ANGLE_instanced_arraysβž–
ARIAMixinβž–
AbortControllerβž–
AbstractRangeβž–
AbstractWorkerβž–
Animatableβž–
AnimationEffectβž–
AnimationFrameProviderβž–
AnimationTimelineβž–
AudioBufferβž–
AudioListenerβž–
AudioParamβž–
AuthenticatorResponseβž–
BarPropβž–
Blobβž–
Bodyβž–
CSSRuleβž–
CSSRuleListβž–
CSSStyleDeclarationβž–
Cacheβž–
CacheStorageβž–
CanvasCompositingβž–
CanvasDrawImageβž–
CanvasDrawPathβž–
CanvasFillStrokeStylesβž–
CanvasFiltersβž–
CanvasGradientβž–
CanvasImageDataβž–
CanvasImageSmoothingβž–
CanvasPathβž–
CanvasPathDrawingStylesβž–
CanvasPatternβž–
CanvasRectβž–
CanvasShadowStylesβž–
CanvasStateβž–
CanvasTextβž–
CanvasTextDrawingStylesβž–
CanvasTransformβž–
CanvasUserInterfaceβž–
ClipboardItemβž–
Credentialβž–
CredentialsContainerβž–
Cryptoβž–
CryptoKeyβž–
CustomElementRegistryβž–
DOMImplementationβž–
DOMMatrixReadOnlyβž–
DOMParserβž–
DOMPointReadOnlyβž–
DOMQuadβž–
DOMRectListβž–
DOMRectReadOnlyβž–
DOMStringListβž–
DOMTokenListβž–
DataTransferβž–
DataTransferItemβž–
DataTransferItemListβž–
DeviceMotionEventAccelerationβž–
DeviceMotionEventRotationRateβž–
DocumentAndElementEventHandlersβž–
DocumentOrShadowRootβž–
EXT_blend_minmaxβž–
EXT_color_buffer_floatβž–
EXT_color_buffer_half_floatβž–
EXT_float_blendβž–
EXT_frag_depthβž–
EXT_sRGBβž–
EXT_shader_texture_lodβž–
EXT_texture_compression_bptcβž–
EXT_texture_compression_rgtcβž–
EXT_texture_filter_anisotropicβž–
EXT_texture_norm16βž–
ElementCSSInlineStyleβž–
ElementContentEditableβž–
Eventβž–
EventCountsβž–
EventListenerβž–
EventListenerObjectβž–
EventTargetβž–
Externalβž–
FileListβž–
FileSystemβž–
FileSystemDirectoryReaderβž–
FileSystemEntryβž–
FileSystemHandleβž–
FontFaceβž–
FontFaceSourceβž–
FormDataβž–
Gamepadβž–
GamepadButtonβž–
GamepadHapticActuatorβž–
GenericTransformStreamβž–
Geolocationβž–
GeolocationCoordinatesβž–
GeolocationPositionβž–
GeolocationPositionErrorβž–
GlobalEventHandlersβž–
Headersβž–
Historyβž–
IDBCursorβž–
IDBFactoryβž–
IDBIndexβž–
IDBKeyRangeβž–
IDBObjectStoreβž–
IdleDeadlineβž–
ImageBitmapβž–
ImageBitmapRenderingContextβž–
ImageDataβž–
InnerHTMLβž–
IntersectionObserverβž–
IntersectionObserverEntryβž–
KHR_parallel_shader_compileβž–
LinkStyleβž–
Locationβž–
Lockβž–
LockManagerβž–
MediaCapabilitiesβž–
MediaDeviceInfoβž–
MediaErrorβž–
MediaKeySystemAccessβž–
MediaKeysβž–
MediaListβž–
MediaMetadataβž–
MediaSessionβž–
MessageChannelβž–
MimeTypeβž–
MimeTypeArrayβž–
MutationObserverβž–
MutationRecordβž–
NavigationPreloadManagerβž–
NavigatorAutomationInformationβž–
NavigatorConcurrentHardwareβž–
NavigatorContentUtilsβž–
NavigatorCookiesβž–
NavigatorIDβž–
NavigatorLanguageβž–
NavigatorLocksβž–
NavigatorOnLineβž–
NavigatorPluginsβž–
NavigatorStorageβž–
NodeIteratorβž–
NodeListβž–
NonDocumentTypeChildNodeβž–
NonElementParentNodeβž–
OES_draw_buffers_indexedβž–
OES_element_index_uintβž–
OES_standard_derivativesβž–
OES_texture_floatβž–
OES_texture_float_linearβž–
OES_texture_half_floatβž–
OES_texture_half_float_linearβž–
OES_vertex_array_objectβž–
OVR_multiview2βž–
PerformanceEntryβž–
PerformanceNavigationβž–
PerformanceObserverβž–
PerformanceObserverEntryListβž–
PerformanceServerTimingβž–
PerformanceTimingβž–
PeriodicWaveβž–
Permissionsβž–
Pluginβž–
PluginArrayβž–
PushManagerβž–
PushSubscriptionβž–
PushSubscriptionOptionsβž–
RTCCertificateβž–
RTCEncodedAudioFrameβž–
RTCEncodedVideoFrameβž–
RTCIceCandidateβž–
RTCRtpReceiverβž–
RTCRtpSenderβž–
RTCRtpTransceiverβž–
RTCSessionDescriptionβž–
RTCStatsReportβž–
ReadableByteStreamControllerβž–
ReadableStreamBYOBRequestβž–
ReadableStreamGenericReaderβž–
ResizeObserverβž–
ResizeObserverEntryβž–
ResizeObserverSizeβž–
SVGAngleβž–
SVGAnimatedAngleβž–
SVGAnimatedBooleanβž–
SVGAnimatedEnumerationβž–
SVGAnimatedIntegerβž–
SVGAnimatedLengthβž–
SVGAnimatedLengthListβž–
SVGAnimatedNumberβž–
SVGAnimatedNumberListβž–
SVGAnimatedPointsβž–
SVGAnimatedPreserveAspectRatioβž–
SVGAnimatedRectβž–
SVGAnimatedStringβž–
SVGAnimatedTransformListβž–
SVGFilterPrimitiveStandardAttributesβž–
SVGFitToViewBoxβž–
SVGLengthβž–
SVGLengthListβž–
SVGNumberβž–
SVGNumberListβž–
SVGPointListβž–
SVGPreserveAspectRatioβž–
SVGStringListβž–
SVGTestsβž–
SVGTransformβž–
SVGTransformListβž–
SVGURIReferenceβž–
SVGUnitTypesβž–
Screenβž–
Selectionβž–
Slottableβž–
SpeechRecognitionAlternativeβž–
SpeechRecognitionResultβž–
SpeechRecognitionResultListβž–
SpeechSynthesisVoiceβž–
Storageβž–
StorageManagerβž–
StyleMediaβž–
StyleSheetβž–
StyleSheetListβž–
SubtleCryptoβž–
TextDecoderCommonβž–
TextEncoderCommonβž–
TextMetricsβž–
TextTrackCueListβž–
TimeRangesβž–
Touchβž–
TouchListβž–
TreeWalkerβž–
URLβž–
URLSearchParamsβž–
VTTRegionβž–
ValidityStateβž–
VideoColorSpaceβž–
VideoPlaybackQualityβž–
WEBGL_color_buffer_floatβž–
WEBGL_compressed_texture_astcβž–
WEBGL_compressed_texture_etcβž–
WEBGL_compressed_texture_etc1βž–
WEBGL_compressed_texture_s3tcβž–
WEBGL_compressed_texture_s3tc_srgbβž–
WEBGL_debug_renderer_infoβž–
WEBGL_debug_shadersβž–
WEBGL_depth_textureβž–
WEBGL_draw_buffersβž–
WEBGL_lose_contextβž–
WEBGL_multi_drawβž–
WebGL2RenderingContextBaseβž–
WebGL2RenderingContextOverloadsβž–
WebGLActiveInfoβž–
WebGLBufferβž–
WebGLFramebufferβž–
WebGLProgramβž–
WebGLQueryβž–
WebGLRenderbufferβž–
WebGLRenderingContextBaseβž–
WebGLRenderingContextOverloadsβž–
WebGLSamplerβž–
WebGLShaderβž–
WebGLShaderPrecisionFormatβž–
WebGLSyncβž–
WebGLTextureβž–
WebGLTransformFeedbackβž–
WebGLUniformLocationβž–
WebGLVertexArrayObjectβž–
WebGLVertexArrayObjectOESβž–
WindowEventHandlersβž–
WindowLocalStorageβž–
WindowOrWorkerGlobalScopeβž–
WindowSessionStorageβž–
Workletβž–
WritableStreamDefaultControllerβž–
XMLSerializerβž–
XPathEvaluatorBaseβž–
XPathExpressionβž–
XPathResultβž–
XSLTProcessorβž–
BlobCallbackβž–
CustomElementConstructorβž–
DecodeErrorCallbackβž–
DecodeSuccessCallbackβž–
ErrorCallbackβž–
FileCallbackβž–
FileSystemEntriesCallbackβž–
FileSystemEntryCallbackβž–
FrameRequestCallbackβž–
FunctionStringCallbackβž–
IdleRequestCallbackβž–
IntersectionObserverCallbackβž–
LockGrantedCallbackβž–
MediaSessionActionHandlerβž–
MutationCallbackβž–
NotificationPermissionCallbackβž–
OnBeforeUnloadEventHandlerNonNullβž–
OnErrorEventHandlerNonNullβž–
PerformanceObserverCallbackβž–
PositionCallbackβž–
PositionErrorCallbackβž–
RTCPeerConnectionErrorCallbackβž–
RTCSessionDescriptionCallbackβž–
RemotePlaybackAvailabilityCallbackβž–
ResizeObserverCallbackβž–
UnderlyingSinkAbortCallbackβž–
UnderlyingSinkCloseCallbackβž–
UnderlyingSinkStartCallbackβž–
UnderlyingSourceCancelCallbackβž–
VideoFrameRequestCallbackβž–
VoidFunctionβž–
AddEventListenerOptionsβž–
AesCbcParamsβž–
AesCtrParamsβž–
AesDerivedKeyParamsβž–
AesGcmParamsβž–
AesKeyAlgorithmβž–
AesKeyGenParamsβž–
AnalyserOptionsβž–
AnimationEventInitβž–
AnimationPlaybackEventInitβž–
AudioProcessingEventInitβž–
AudioWorkletNodeOptionsβž–
BiquadFilterOptionsβž–
ChannelMergerOptionsβž–
ChannelSplitterOptionsβž–
ClipboardEventInitβž–
CloseEventInitβž–
CompositionEventInitβž–
ComputedEffectTimingβž–
ConstrainDoubleRangeβž–
ConstrainULongRangeβž–
ConvolverOptionsβž–
DOMMatrixInitβž–
DelayOptionsβž–
DeviceMotionEventInitβž–
DeviceOrientationEventInitβž–
DragEventInitβž–
DynamicsCompressorOptionsβž–
EcKeyAlgorithmβž–
EcKeyGenParamsβž–
EcKeyImportParamsβž–
EcdhKeyDeriveParamsβž–
EcdsaParamsβž–
ErrorEventInitβž–
EventModifierInitβž–
FilePropertyBagβž–
FocusEventInitβž–
FontFaceSetLoadEventInitβž–
FormDataEventInitβž–
GainOptionsβž–
GamepadEventInitβž–
HashChangeEventInitβž–
HkdfParamsβž–
HmacImportParamsβž–
HmacKeyAlgorithmβž–
HmacKeyGenParamsβž–
IDBVersionChangeEventInitβž–
IIRFilterOptionsβž–
InputEventInitβž–
KeyboardEventInitβž–
KeyframeAnimationOptionsβž–
KeyframeEffectOptionsβž–
MediaCapabilitiesDecodingInfoβž–
MediaCapabilitiesEncodingInfoβž–
MediaDecodingConfigurationβž–
MediaEncodingConfigurationβž–
MediaEncryptedEventInitβž–
MediaKeyMessageEventInitβž–
MediaQueryListEventInitβž–
MediaStreamTrackEventInitβž–
MediaTrackConstraintsβž–
MouseEventInitβž–
MultiCacheQueryOptionsβž–
OfflineAudioCompletionEventInitβž–
OscillatorOptionsβž–
PageTransitionEventInitβž–
PannerOptionsβž–
PaymentDetailsInitβž–
PaymentDetailsUpdateβž–
PaymentMethodChangeEventInitβž–
PaymentRequestUpdateEventInitβž–
Pbkdf2Paramsβž–
PeriodicWaveOptionsβž–
PictureInPictureEventInitβž–
PointerEventInitβž–
PopStateEventInitβž–
ProgressEventInitβž–
PromiseRejectionEventInitβž–
PublicKeyCredentialRpEntityβž–
PublicKeyCredentialUserEntityβž–
RTCAnswerOptionsβž–
RTCDTMFToneChangeEventInitβž–
RTCDataChannelEventInitβž–
RTCErrorEventInitβž–
RTCIceCandidatePairStatsβž–
RTCInboundRtpStreamStatsβž–
RTCOfferOptionsβž–
RTCOutboundRtpStreamStatsβž–
RTCPeerConnectionIceErrorEventInitβž–
RTCPeerConnectionIceEventInitβž–
RTCReceivedRtpStreamStatsβž–
RTCRtpEncodingParametersβž–
RTCRtpReceiveParametersβž–
RTCRtpSendParametersβž–
RTCRtpStreamStatsβž–
RTCRtpSynchronizationSourceβž–
RTCSentRtpStreamStatsβž–
RTCTrackEventInitβž–
RTCTransportStatsβž–
RsaHashedImportParamsβž–
RsaHashedKeyAlgorithmβž–
RsaHashedKeyGenParamsβž–
RsaKeyAlgorithmβž–
RsaKeyGenParamsβž–
RsaOaepParamsβž–
RsaPssParamsβž–
ScrollIntoViewOptionsβž–
ScrollToOptionsβž–
SecurityPolicyViolationEventInitβž–
SpeechSynthesisErrorEventInitβž–
SpeechSynthesisEventInitβž–
StereoPannerOptionsβž–
StorageEventInitβž–
SubmitEventInitβž–
TouchEventInitβž–
TrackEventInitβž–
TransitionEventInitβž–
UIEventInitβž–
WaveShaperOptionsβž–
WebGLContextEventInitβž–
WheelEventInitβž–
WindowPostMessageOptionsβž–
AbortSignalβž–
AnalyserNodeβž–
Animationβž–
AnimationEventβž–
AnimationPlaybackEventβž–
Attrβž–
AudioBufferSourceNodeβž–
AudioContextβž–
AudioDestinationNodeβž–
AudioNodeβž–
AudioProcessingEventβž–
AudioScheduledSourceNodeβž–
AudioWorkletβž–
AudioWorkletNodeβž–
AuthenticatorAssertionResponseβž–
AuthenticatorAttestationResponseβž–
BaseAudioContextβž–
BeforeUnloadEventβž–
BiquadFilterNodeβž–
BlobEventβž–
BroadcastChannelβž–
CDATASectionβž–
CSSAnimationβž–
CSSConditionRuleβž–
CSSContainerRuleβž–
CSSCounterStyleRuleβž–
CSSFontFaceRuleβž–
CSSFontPaletteValuesRuleβž–
CSSGroupingRuleβž–
CSSImportRuleβž–
CSSKeyframeRuleβž–
CSSKeyframesRuleβž–
CSSLayerBlockRuleβž–
CSSLayerStatementRuleβž–
CSSMediaRuleβž–
CSSNamespaceRuleβž–
CSSPageRuleβž–
CSSStyleRuleβž–
CSSStyleSheetβž–
CSSSupportsRuleβž–
CSSTransitionβž–
CanvasCaptureMediaStreamTrackβž–
ChannelMergerNodeβž–
ChannelSplitterNodeβž–
ChildNodeβž–
ClientRectβž–
Clipboardβž–
ClipboardEventβž–
CloseEventβž–
Commentβž–
CompositionEventβž–
ConstantSourceNodeβž–
ConvolverNodeβž–
CountQueuingStrategyβž–
DOMMatrixβž–
DOMPointβž–
DOMRectβž–
DelayNodeβž–
DeviceMotionEventβž–
DeviceOrientationEventβž–
DocumentTimelineβž–
DragEventβž–
DynamicsCompressorNodeβž–
ElementInternalsβž–
ErrorEventβž–
EventSourceβž–
Fileβž–
FileReaderβž–
FileSystemDirectoryEntryβž–
FileSystemDirectoryHandleβž–
FileSystemFileEntryβž–
FileSystemFileHandleβž–
FocusEventβž–
FontFaceSetβž–
FontFaceSetLoadEventβž–
FormDataEventβž–
GainNodeβž–
GamepadEventβž–
HashChangeEventβž–
IDBCursorWithValueβž–
IDBDatabaseβž–
IDBTransactionβž–
IDBVersionChangeEventβž–
IIRFilterNodeβž–
InputDeviceInfoβž–
InputEventβž–
KeyboardEventβž–
KeyframeEffectβž–
MediaDevicesβž–
MediaElementAudioSourceNodeβž–
MediaEncryptedEventβž–
MediaKeyMessageEventβž–
MediaKeySessionβž–
MediaQueryListβž–
MediaQueryListEventβž–
MediaRecorderβž–
MediaSourceβž–
MediaStreamβž–
MediaStreamAudioDestinationNodeβž–
MediaStreamAudioSourceNodeβž–
MediaStreamTrackβž–
MediaStreamTrackEventβž–
MessagePortβž–
MouseEventβž–
MutationEventβž–
Nodeβž–
Notificationβž–
OfflineAudioCompletionEventβž–
OfflineAudioContextβž–
OffscreenCanvasβž–
OscillatorNodeβž–
OverconstrainedErrorβž–
PageTransitionEventβž–
PannerNodeβž–
ParentNodeβž–
Path2Dβž–
PaymentMethodChangeEventβž–
PaymentRequestβž–
PaymentRequestUpdateEventβž–
PaymentResponseβž–
Performanceβž–
PerformanceEventTimingβž–
PerformanceMarkβž–
PerformanceMeasureβž–
PerformanceNavigationTimingβž–
PerformancePaintTimingβž–
PerformanceResourceTimingβž–
PermissionStatusβž–
PictureInPictureEventβž–
PictureInPictureWindowβž–
PointerEventβž–
PopStateEventβž–
PromiseRejectionEventβž–
PublicKeyCredentialβž–
RTCDTMFSenderβž–
RTCDTMFToneChangeEventβž–
RTCDataChannelβž–
RTCDataChannelEventβž–
RTCDtlsTransportβž–
RTCErrorβž–
RTCErrorEventβž–
RTCIceTransportβž–
RTCPeerConnectionβž–
RTCPeerConnectionIceErrorEventβž–
RTCPeerConnectionIceEventβž–
RTCSctpTransportβž–
RTCTrackEventβž–
RadioNodeListβž–
Rangeβž–
ReadableStreamBYOBReaderβž–
RemotePlaybackβž–
Requestβž–
Responseβž–
SVGAnimateElementβž–
SVGAnimateMotionElementβž–
SVGAnimateTransformElementβž–
SVGCircleElementβž–
SVGClipPathElementβž–
SVGComponentTransferFunctionElementβž–
SVGDefsElementβž–
SVGDescElementβž–
SVGEllipseElementβž–
SVGFEDistantLightElementβž–
SVGFEFuncAElementβž–
SVGFEFuncBElementβž–
SVGFEFuncGElementβž–
SVGFEFuncRElementβž–
SVGFEMergeNodeElementβž–
SVGFEPointLightElementβž–
SVGFESpotLightElementβž–
SVGForeignObjectElementβž–
SVGGElementβž–
SVGGeometryElementβž–
SVGLineElementβž–
SVGLinearGradientElementβž–
SVGMaskElementβž–
SVGMetadataElementβž–
SVGPathElementβž–
SVGRadialGradientElementβž–
SVGRectElementβž–
SVGSetElementβž–
SVGStopElementβž–
SVGSwitchElementβž–
SVGTSpanElementβž–
SVGTextContentElementβž–
SVGTextElementβž–
SVGTextPositioningElementβž–
SVGTitleElementβž–
ScreenOrientationβž–
ScriptProcessorNodeβž–
SecurityPolicyViolationEventβž–
ServiceWorkerContainerβž–
ServiceWorkerRegistrationβž–
SourceBufferβž–
SourceBufferListβž–
SpeechSynthesisβž–
SpeechSynthesisErrorEventβž–
SpeechSynthesisEventβž–
SpeechSynthesisUtteranceβž–
StaticRangeβž–
StereoPannerNodeβž–
StorageEventβž–
SubmitEventβž–
TextDecoderβž–
TextEncoderβž–
TextTrackβž–
TextTrackCueβž–
TextTrackListβž–
TouchEventβž–
TrackEventβž–
TransitionEventβž–
UIEventβž–
VTTCueβž–
VisualViewportβž–
WaveShaperNodeβž–
WebGLContextEventβž–
WebSocketβž–
WheelEventβž–
XMLDocumentβž–
XMLHttpRequestβž–
XMLHttpRequestEventTargetβž–
XMLHttpRequestUploadβž–
XPathEvaluatorβž–

HTML (80 methods)

NameTests
HTMLDirectoryElementβž–
HTMLDocumentβž–
HTMLFontElementβž–
HTMLFrameElementβž–
HTMLMarqueeElementβž–
HTMLParamElementβž–
HTMLTableDataCellElementβž–
HTMLTableHeaderCellElementβž–
HTMLAllCollectionβž–
HTMLCollectionBaseβž–
HTMLHyperlinkElementUtilsβž–
HTMLOrSVGElementβž–
HTMLAnchorElementβž–
HTMLAreaElementβž–
HTMLAudioElementβž–
HTMLBRElementβž–
HTMLBaseElementβž–
HTMLBodyElementβž–
HTMLButtonElementβž–
HTMLCanvasElementβž–
HTMLCollectionβž–
HTMLDListElementβž–
HTMLDataElementβž–
HTMLDataListElementβž–
HTMLDetailsElementβž–
HTMLDialogElementβž–
HTMLDivElementβž–
HTMLElementβž–
HTMLEmbedElementβž–
HTMLFieldSetElementβž–
HTMLFormControlsCollectionβž–
HTMLFormElementβž–
HTMLHRElementβž–
HTMLHeadElementβž–
HTMLHeadingElementβž–
HTMLHtmlElementβž–
HTMLIFrameElementβž–
HTMLImageElementβž–
HTMLInputElementβž–
HTMLLIElementβž–
HTMLLabelElementβž–
HTMLLegendElementβž–
HTMLLinkElementβž–
HTMLMapElementβž–
HTMLMediaElementβž–
HTMLMenuElementβž–
HTMLMetaElementβž–
HTMLMeterElementβž–
HTMLModElementβž–
HTMLOListElementβž–
HTMLObjectElementβž–
HTMLOptGroupElementβž–
HTMLOptionElementβž–
HTMLOptionsCollectionβž–
HTMLOutputElementβž–
HTMLParagraphElementβž–
HTMLPictureElementβž–
HTMLPreElementβž–
HTMLProgressElementβž–
HTMLQuoteElementβž–
HTMLScriptElementβž–
HTMLSelectElementβž–
HTMLSlotElementβž–
HTMLSourceElementβž–
HTMLSpanElementβž–
HTMLStyleElementβž–
HTMLTableCaptionElementβž–
HTMLTableCellElementβž–
HTMLTableColElementβž–
HTMLTableElementβž–
HTMLTableRowElementβž–
HTMLTableSectionElementβž–
HTMLTemplateElementβž–
HTMLTextAreaElementβž–
HTMLTimeElementβž–
HTMLTitleElementβž–
HTMLTrackElementβž–
HTMLUListElementβž–
HTMLUnknownElementβž–
HTMLVideoElementβž–

Back to table of contents

βž• Additional

If you need to check arguments before executing a function, you can combine the package with @p4ck493/ts-type-guard.

Example

import { TypeGuard } from '@p4ck493/ts-type-guard';

class Person {
  #firstName: string;
  #secondName: string;
  #age: number;
  #somethink: any;

  @TypeGuard([is.string.not.empty])
  public setFirstName(firstName: string): void {
    this.#firstName = firstName;
  }

  @TypeGuard([is.string.not.empty])
  public setSecondName(secondName: string): void {
    this.#secondName = secondName;
  }

  // But it is not necessary to duplicate the check, if it is also the same for
  // the next argument, then you can not supplement it with new checks,
  // during the check, the previous one will be taken for the next argument.
  // @TypeGuard([is.string.not.empty]) - is equivalent
  @TypeGuard([is.string.not.empty, is.string.not.empty])
  public setSomeData(firstName: string, secondName: string): void {
    this.#firstName = firstName;
    this.#secondName = secondName;
  }

  // For optional argument use NULL value.
  @TypeGuard([is.string.not.empty, null])
  public setSomeData(firstName: string, age?: number): void {
    this.#firstName = firstName;
    this.#age = age;
  }

  @TypeGuard({
    result: [is.string],
  })
  public get firstName(): string {
    return this.#firstName;
  }

  @T
3.0.9-beta.0

1 year ago

3.0.11

1 year ago

3.0.9-beta.1

1 year ago

3.0.9-beta.2

1 year ago

3.0.9

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.8

1 year ago

3.0.7

1 year ago

3.0.6

1 year ago

3.0.5

1 year ago

3.0.8-beta.0

1 year ago

3.0.7-beta.0

1 year ago

3.0.6-beta.0

1 year ago

3.0.5-beta.0

1 year ago

3.0.4-beta.0

1 year ago

3.0.3-beta.1

1 year ago

3.0.8-beta.1

1 year ago

3.0.4-beta.1

1 year ago

3.0.3-beta.0

1 year ago

2.0.4-fix.0

1 year ago

3.0.1-beta.0

1 year ago

3.0.1-beta.1

1 year ago

3.0.0-beta.1

1 year ago

3.0.1-beta.2

1 year ago

3.0.0-beta.0

1 year ago

3.0.1-beta.3

1 year ago

3.0.0-beta.3

1 year ago

3.0.1-beta.4

1 year ago

3.0.0-beta.2

1 year ago

3.0.1-beta.5

1 year ago

3.0.1-beta.6

1 year ago

3.0.0-beta.4

1 year ago

3.0.1-beta.7

1 year ago

3.0.1-beta.8

1 year ago

2.0.3

1 year ago

2.0.4

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago