type-enforcer

A type enforcement library for javascript

MIT 63 个版本
安装
npm install type-enforcer
yarn add type-enforcer
pnpm add type-enforcer
bun add type-enforcer
README

Type Enforcer

A type enforcement library for javascript

npm build coverage deps size vulnerabilities license


Installation

npm install type-enforcer

Requires Babel 7.2+


Objects

assert : object

An assertion library for testing. Assertions do nothing if the test passes, and throw an AssertionError if they fail.

is : object

Utility functions for checking if a value is a particular data type.

enforce : object

Utility functions for enforcing data types.

method : object

Enforce data types and remove common boilerplate code on class methods.


Classes

Enum

Freezes an enumerable object and adds a few helper methods

Queue

A simple queue for callbacks that allows for adding, removing, and triggering all or specific callbacks

Removable

A mixin that adds methods to a class to facilitate clean-up

PrivateVars

A thin wrapper over WeakMap for storing private variables


Functions

abstractEquality(a, b)boolean

Performs an abstract equality check (==) between two values.

sameValue(a, b)boolean

Performs a SameValue equality check (Object.is) between two values.

sameValueZero(a, b)boolean

Performs a SameValueZero equality check between two values.

strictEquality(a, b)boolean

Performs a strict equality check (===) between two values.

applySettings(target, settings, [priority], [deferred])

Iterates over the provided settings and calls any methods of the same name, passing the value in as the argument.

castArray(value)Array

Casts a value to an array.

版本列表
1.2.7 2025-03-22
1.2.6 2023-09-18
1.2.5 2023-09-12
1.2.4 2022-08-04
1.2.3 2022-08-04
1.2.2 2021-06-20
1.2.1 2020-08-20
1.2.0 2020-07-15
1.1.5 2020-06-09
1.1.4 2020-06-09
1.1.3 2020-04-01
1.1.2 2020-03-30
1.1.1 2020-02-15
1.1.0 2020-02-14
1.0.6 2020-01-15
1.0.5 2019-12-26
1.0.4 2019-12-09
1.0.3 2019-12-09
1.0.2 2019-12-07
1.0.1 2019-12-04
1.0.0-beta.4 2019-11-28
1.0.0-beta.3 2019-11-20
1.0.0-beta.2 2019-10-30
1.0.0-beta.1 2019-10-29
1.0.0-beta.0 2019-10-14
1.0.0 2019-12-04
0.6.4 2019-10-22
0.6.3 2019-10-21
0.6.2 2019-10-10
0.6.1 2019-10-09
0.6.0 2019-10-08
0.5.8 2019-10-01
0.5.7 2019-08-28
0.5.6 2019-08-16
0.5.5 2019-07-30
0.5.4 2019-07-28
0.5.3 2019-07-19
0.5.2 2019-07-16
0.5.1 2019-07-13
0.5.0 2019-07-04
0.4.4 2019-06-06
0.4.3 2019-05-31
0.4.2 2019-03-27
0.4.1 2019-03-11
0.4.0 2019-03-11
0.3.3 2019-02-16
0.3.2 2019-02-14
0.3.1 2019-02-10
0.3.0 2019-02-03
0.2.4 2019-01-31
0.2.3 2019-01-31
0.2.2 2019-01-25
0.2.1 2019-01-24
0.2.0 2019-01-18
0.1.6 2019-01-02
0.1.5 2018-12-30
0.1.4 2018-12-30
0.1.3 2018-12-29
0.1.2 2018-12-29
0.1.1 2018-12-29
0.1.0 2018-12-29
0.0.2 2018-12-28
0.0.1 2018-12-28