@t15i/webspecs
v1.0.1
Published
TypeScript implementations of web platform specifications
Maintainers
Readme
webspecs - TypeScript implementations of web platform specifications
A reference implementation of selected algorithms and types from the WHATWG, W3C, and TC39 specifications. Each module's path mirrors the section ID of the spec it implements, so navigating the source feels like navigating the spec.
Coverage is intentionally narrow — this is a knowledge base, not a polyfill. Only the algorithms that have been ported so far are listed below; everything else is marked with
....
Install
npm install @t15i/webspecsUsage
Each spec is exposed as its own subpath export:
import { ... } from "@t15i/webspecs/dom";
import { ... } from "@t15i/webspecs/ecma";
import { ... } from "@t15i/webspecs/html";
import { ... } from "@t15i/webspecs/infra";
import { ... } from "@t15i/webspecs/share";
import { ... } from "@t15i/webspecs/url";
import { ... } from "@t15i/webspecs/webidl";The package is side-effect free and ships per-module ES output, so unused algorithms are tree-shaken away.
What's implemented
Expand a spec to see what is currently ported. ... marks sections with un-ported content.
- §1 Infrastructure
- §1.4 Namespaces
- [x]
validAttributeLocalName/isValidAttributeLocalName/validateAttributeLocalName
- [x]
- ...
- §1.4 Namespaces
- §4 Nodes
- §4.9 Interface Element
- [x]
Element(defineContentAttribute/getContentAttributeDescriptor) - [x]
ContentAttributeDescriptor - [x]
getID - ...
- [x]
- ...
- §4.9 Interface Element
- ...
- §5 Notational Conventions
- §5.2.6 Mathematical Operations
- [x]
R - [x]
sign - [x]
modulo - [x]
truncate - ...
- [x]
- ...
- §5.2.6 Mathematical Operations
- §6 ECMAScript Data Types and Values
- §6.1 ECMAScript Language Types
- §6.1.3 The Boolean Type
- [x]
isBoolean
- [x]
- §6.1.4 The String Type
- [x]
isString
- [x]
- §6.1.6 Numeric Types
- §6.1.6.1 The Number Type
- [x]
isNumber
- [x]
- §6.1.6.2 The BigInt Type
- [x]
isBigInt
- [x]
- §6.1.6.1 The Number Type
- §6.1.7 The Object Type
- [x]
isObject - [x]
PropertyKey - [x]
PropertyName
- [x]
- ...
- §6.1.3 The Boolean Type
- §6.2 ECMAScript Specification Types
- §6.2.6 The Property Descriptor Specification Type
- §6.2.6.1 IsAccessorDescriptor
- [x]
isAccessorDescriptor
- [x]
- §6.2.6.2 IsDataDescriptor
- [x]
isDataDescriptor
- [x]
- ...
- §6.2.6.1 IsAccessorDescriptor
- ...
- §6.2.6 The Property Descriptor Specification Type
- §6.1 ECMAScript Language Types
- §7 Abstract Operations
- §7.1 Type Conversion
- §7.1.1 ToPrimitive
- [x]
toPrimitive - §7.1.1.1 OrdinaryToPrimitive
- [x]
ordinaryToPrimitive
- [x]
- [x]
- §7.1.3 ToNumeric
- [x]
toNumeric
- [x]
- §7.1.4 ToNumber
- [x]
toNumber
- [x]
- §7.1.5 ToIntegerOrInfinity
- [x]
toIntegerOrInfinity
- [x]
- §7.1.6 ToFixedSizeInteger
- [x]
toFixedSizeInteger
- [x]
- §7.1.8 ToUint32
- [x]
toUint32
- [x]
- §7.1.14 ToBigInt
- [x]
toBigInt
- [x]
- §7.1.18 ToString
- [x]
toString
- [x]
- §7.1.22 CanonicalNumericIndexString
- [x]
canonicalNumericIndexString
- [x]
- ...
- §7.1.1 ToPrimitive
- §7.2 Testing and Comparison Operations
- §7.2.3 IsCallable
- [x]
isCallable
- [x]
- ...
- §7.2.3 IsCallable
- §7.3 Operations on Objects
- §7.3.5 CreateDataProperty
- [x]
createDataProperty
- [x]
- §7.3.6 CreateDataPropertyOrThrow
- [x]
createDataPropertyOrThrow
- [x]
- §7.3.8 DefinePropertyOrThrow
- [x]
definePropertyOrThrow
- [x]
- §7.3.10 GetMethod
- [x]
getMethod
- [x]
- ...
- §7.3.5 CreateDataProperty
- §7.4 Operations on Iterator Objects
- §7.4.1 Iterator Records
- [x]
IteratorRecord
- [x]
- §7.4.2 GetIteratorDirect
- [x]
getIteratorDirect
- [x]
- §7.4.3 GetIteratorFromMethod
- [x]
getIteratorFromMethod
- [x]
- ...
- §7.4.1 Iterator Records
- ...
- §7.1 Type Conversion
- §10 Ordinary and Exotic Objects Behaviours
- §10.1 Ordinary Object Internal Methods and Internal Slots
- §10.1.5.1 OrdinaryGetOwnProperty
- [x]
ordinaryGetOwnProperty
- [x]
- §10.1.6.1 OrdinaryDefineOwnProperty
- [x]
ordinaryDefineOwnProperty
- [x]
- §10.1.9.2 OrdinarySetWithOwnDescriptor
- [x]
ordinarySetWithOwnDescriptor
- [x]
- §10.1.12 OrdinaryObjectCreate
- [x]
ordinaryObjectCreate
- [x]
- ...
- §10.1.5.1 OrdinaryGetOwnProperty
- §10.2 ECMAScript Function Objects
- §10.2.8 DefineMethodProperty
- [x]
defineMethodProperty
- [x]
- §10.2.9 SetFunctionName
- [x]
setFunctionName
- [x]
- §10.2.10 SetFunctionLength
- [x]
setFunctionLength
- [x]
- ...
- §10.2.8 DefineMethodProperty
- §10.3 Built-in Function Objects
- §10.3.4 CreateBuiltinFunction
- [x]
createBuiltinFunction/CreateBuiltinFunctionOptions
- [x]
- ...
- §10.3.4 CreateBuiltinFunction
- §10.4 Built-in Exotic Object Internal Methods and Slots
- §10.4.3 String Exotic Objects
- [x]
hasStringDataInternalSlot
- [x]
- ...
- §10.4.3 String Exotic Objects
- ...
- §10.1 Ordinary Object Internal Methods and Internal Slots
- §23 Indexed Collections
- §23.2 TypedArray Objects
- [x]
hasTypedArrayNameInternalSlot - ...
- [x]
- ...
- §23.2 TypedArray Objects
- §25 Structured Data
- §25.1 ArrayBuffer Objects
- [x]
hasArrayBufferDataInternalSlot
- [x]
- §25.2 SharedArrayBuffer Objects
- [x]
isSharedArrayBuffer
- [x]
- §25.3 DataView Objects
- [x]
hasDataViewInternalSlot
- [x]
- ...
- §25.1 ArrayBuffer Objects
- ...
- §2 Infrastructure
- §2.3 Common microsyntaxes
- §2.3.3 Keywords and enumerated attributes
- [x]
EnumeratedAttributeState - [x]
EnumeratedAttributeStates
- [x]
- §2.3.4 Numbers
- §2.3.4.1 Signed integers
- [x]
integerParsing - [x]
shortestPossibleStringRepresentingAsValidInteger
- [x]
- §2.3.4.2 Non-negative integers
- [x]
nonNegativeIntegerParsing - [x]
shortestPossibleRepresentingAsValidNonNegativeInteger
- [x]
- §2.3.4.3 Floating-point numbers
- [x]
bestRepresentationAsFloatingPointNumber - [x]
floatingPointNumberParsing
- [x]
- ...
- §2.3.4.1 Signed integers
- ...
- §2.3.3 Keywords and enumerated attributes
- §2.4 URLs and fetching
- §2.4.2 Resolving URLs
- [x]
encodingParseURL - [x]
encodingParseAndSerializeURL
- [x]
- ...
- §2.4.2 Resolving URLs
- §2.6 Common DOM interfaces
- §2.6.1 Reflecting content attributes in IDL attributes
- Per-type reflection modules, each exposing
ReflectedIDLAttribute,getterandsetter(andattributeChangeStepswhere the type needs them):- [x]
ReflectedBoolean - [x]
ReflectedDOMString - [x]
ReflectedDouble - [x]
ReflectedLong - [x]
ReflectedNullableDOMString - [x]
ReflectedNullableElement - [x]
ReflectedNullableFrozenArrayOfElements - [x]
ReflectedUnsignedLong - [x]
ReflectedUSVString
- [x]
- [x]
ReflectedTarget/ReflectedTargetAssociations/ReflectedIDLAttributeOf - [x]
getContentAttributeOfElementReflectedTarget - [x]
setContentAttributeOfElementReflectedTarget - [x]
deleteContentAttributeOfElementReflectedTarget - [x]
getElementOfElementReflectedTarget - [x]
getAssociatedElement/getAssociatedElements - Reflection constraints:
- [x]
validateClampedToRange - [x]
validateDefaultValue - [x]
validateLimitedToOnlyKnownValues - [x]
validateLimitedToOnlyNonNegativeNumbers - [x]
validateLimitedToOnlyPositiveNumbers - [x]
validateLimitedToOnlyPositiveNumbersWithFallback - [x]
validateTreatedAsURL
- [x]
- ...
- Per-type reflection modules, each exposing
- §2.6.2 Using reflect via IDL extended attributes
- [x]
Reflect - [x]
ReflectDefault - [x]
ReflectNonNegative - [x]
ReflectPositive - [x]
ReflectPositiveWithFallback - [x]
ReflectRange - [x]
ReflectSetter - [x]
ReflectURL - [x]
ReflectionTrigger/reflectionTriggers - [x]
ReflectionSupplements/reflectionSupplements - [x]
validateReflectionExtendedAttributes
- [x]
- ...
- §2.6.1 Reflecting content attributes in IDL attributes
- ...
- §2.3 Common microsyntaxes
- ...
- §4 Primitive data types
- §4.6 Code points
- [x]
surrogate/surrogates - [x]
leadingSurrogate/leadingSurrogates - [x]
trailingSurrogate/trailingSurrogates
- [x]
- §4.7 Strings
- [x]
convertStringIntoScalarValueString - [x]
splitOnASCIIWhitespace - ...
- [x]
- ...
- §4.6 Code points
- §8 Namespaces
- [x]
HTMLNamespace - [x]
MathMLNamespace - [x]
SVGNamespace - [x]
XLinkNamespace - [x]
XMLNamespace - [x]
XMLNSNamespace
- [x]
- ...
Values that several specs share and that belong to none of them.
- [x]
failure— the sentinel returned by algorithms that "return failure"
- §4 URLs
- §4.4 URL parsing
- [x]
urlParser
- [x]
- §4.5 URL serializing
- [x]
urlSerializer
- [x]
- ...
- §4.4 URL parsing
- ...
- §2 Interface definition language
- §2.1 Names
- [x]
Identifier - [x]
isIdentifier
- [x]
- §2.2 Interfaces
- [x]
Interface/InterfaceMembers/InterfaceStaticMembers - [x]
InterfaceExtendedAttributes/InterfaceBehaviors - [x]
validateInterface/interfaceExtraValidationRules
- [x]
- §2.5 Members
- [x]
Member/MemberSlot - [x]
iterateMembers/iterateMemberSlots - [x]
validateMemberSlot/validateRegularMemberSlot - §2.5.2 Attributes
- [x]
Attribute/AttributeExtendedAttributes - [x]
isAttribute - [x]
validateAttribute/attributeExtraValidationRules - [x]
RegularAttribute/isRegularAttribute - [x]
validateRegularAttribute/regularAttributeExtraValidationRules - [x]
isReadonlyAttribute/validateReadonlyAttribute - [x]
isDeclaredToInheritItsGetterAttribute
- [x]
- §2.5.3 Operations
- [x]
Operation/OperationExtendedAttributes - [x]
isOperation - [x]
validateOperation/operationExtraValidationRules - [x]
RegularOperation/isRegularOperation - [x]
Argument/ArgumentList/validateArgumentList - [x]
isOptionalArgument - [x]
isDeclaredWithDefaultValue/validateArgumentDefaultValue
- [x]
- §2.5.4 Constructors
- [x]
ConstructorOperation/ConstructorOperationExtendedAttributes - [x]
isConstructorOperation/validateConstructorOperation - [x]
getOwnConstructorOperations
- [x]
- §2.5.6 Special operations
- [x]
SpecialOperation/isSpecialOperation/validateSpecialOperation - [x]
iterateSpecialOperations - [x]
validateNamedSpecialOperationsAreMembers - [x]
validateAtMostOneSpecialOperationPerVariety - [x]
validateIndexedPropertyGetter/validateIndexedPropertyGetterDeterminator - [x]
validateIndexedPropertySetter/validateIndexedPropertySetterConstraints - [x]
validateNamedPropertyGetter/validateNamedPropertyGetterDeterminator - [x]
validateNamedPropertySetter/validateNamedPropertySetterConstraints - [x]
validateNamedPropertyDeleter/validateNamedPropertyDeleterConstraints - [x]
interfaceHasIndexedPropertyGetter - §2.5.6.1 Indexed properties
- [x]
IndexedPropertyGetterOperation/IndexedPropertySetterOperation - [x]
determineValueOfIndexedProperty - [x]
setValueOfNewIndexedProperty - [x]
setValueOfExistingIndexedProperty - [x]
supportsIndexedProperties/isInterfaceSupportIndexedProperties - [x]
isSupportedPropertyIndex/SupportedPropertyIndices - [x]
validateIndexedPropertiesLengthAttribute - [x]
validateSupportedPropertyIndicesDefined
- [x]
- §2.5.6.2 Named properties
- [x]
NamedPropertyGetterOperation/NamedPropertySetterOperation/NamedPropertyDeleterOperation - [x]
determineValueOfNamedProperty - [x]
setValueOfNewNamedProperty - [x]
setValueOfExistingNamedProperty - [x]
deleteExistingNamedProperty - [x]
supportsNamedProperties/isInterfaceSupportNamedProperties - [x]
isSupportedPropertyName/SupportedPropertyNames - [x]
validateSupportedPropertyNamesDefined
- [x]
- ...
- [x]
- §2.5.8 Overloading
- [x]
validateOverloads - [x]
EffectiveOverloadSet/computeEffectiveOverloadSet - [x]
OperationEffectiveOverloadSet/ConstructorOperationEffectiveOverloadSet/LegacyFactoryFunctionEffectiveOverloadSet - [x]
OperationEffectiveOverload/ConstructorOperationEffectiveOverload/LegacyFactoryFunctionEffectiveOverload - [x]
EffectiveOverloadSetCallable(and its operation / constructor / legacy-factory variants) - [x]
EffectiveOverloadSetEffectiveTypeList/EffectiveOverloadSetOptionalityList/EffectiveOverloadSetOptionalityValue - [x]
validateEffectiveOverloadSet - [x]
getDistinguishingArgumentIndex - [x]
isDistinguishable/getInnermostType - [x]
DISTINCTION_TABLE/DISTINCTION_CATEGORY/DistinctionRequirement - [x]
INTERFACELIKE_DISTINCTION_CATEGORIES/DICTIONARYLIKE_DISTINCTION_CATEGORIES/SEQUENCELIKE_DISTINCTION_CATEGORIES
- [x]
- ...
- [x]
- §2.7 Static attributes and operations
- [x]
StaticAttribute/isStaticAttribute/validateStaticAttribute - [x]
StaticOperation/isStaticOperation/validateStaticOperation - [x]
validateStaticMemberSlot
- [x]
- §2.12 Objects implementing interfaces
- [x]
PlatformObject(getPrimaryInterfaceOf/setPrimaryInterfaceOf) - [x]
isLegacyPlatformObject
- [x]
- §2.13 Types
- [x]
Type/TypeBase/TypeMap/NativeType - Each type ships its name constant, its type, and its predicate
(e.g.
LONG_TYPE_NAME,LongType,isLongType):- [x]
any,undefined,boolean,object - [x]
long(withLONG_MIN/LONG_MAX),unsigned long,double,bigint - [x]
DOMString,ByteString,USVString - [x] interface, callback interface, dictionary, callback function
- [x] nullable (with
validateNullableInnerType), sequence, async sequence, record (withRecordKeyType/validateRecordKeyType), promise, frozen array, observable array - [x] union —
isUnionType,getFlattenedMemberTypes,includesNullableType,includesUndefined,getNumberOfNullableMemberTypes, and their validators - [x] annotated types —
AnnotatedType,isAnnotatedType,TypeExtendedAttributes,ApplicableToTypeExtendedAttribute,getExtAttributesAssociatedWith,validateAnnotatedInnerType - [x] groupings —
IntegerType,NumericType,StringType(with their name sets and predicates)
- [x]
- ...
- [x]
- §2.14 Extended attributes
- [x]
ExtendedAttributesOf - [x]
AnnotatedWithExtendedAttribute - [x]
isAnnotatedWithExtAttribute
- [x]
- ...
- §2.1 Names
- §3 JavaScript binding
- §3.2 JavaScript type mapping
- §3.2.2 undefined
- [x]
asUndefined
- [x]
- §3.2.3 boolean
- [x]
asBoolean
- [x]
- §3.2.4 Integer types
- §3.2.4.5 long
- [x]
asLong
- [x]
- §3.2.4.6 unsigned long
- [x]
asUnsignedLong
- [x]
- §3.2.4.9 Abstract operations
- [x]
integerPart - [x]
convertToInt
- [x]
- ...
- §3.2.4.5 long
- §3.2.7 double
- [x]
asDouble
- [x]
- §3.2.9 bigint
- [x]
asBigInt - [x]
asNumericOrBigint
- [x]
- §3.2.10 DOMString
- [x]
asDOMString
- [x]
- §3.2.12 USVString
- [x]
asUSVString
- [x]
- §3.2.15 Interface types
- [x]
asInterfaceType
- [x]
- §3.2.20 Nullable types
- [x]
asNullable
- [x]
- §3.2.21 sequence
- [x]
asSequence - [x]
createSequenceFromIterable
- [x]
- §3.2.22 async sequence
- [x]
AsyncSequence
- [x]
- §3.2.23 record
- [x]
asRecord
- [x]
- §3.2.25 Union types
- [x]
asUnion
- [x]
- §3.2.27 Frozen array types
- [x]
asFrozenArray/createFrozenArray - [x]
createFrozenArrayFromIterable
- [x]
- ...
- §3.2.2 undefined
- §3.3 Extended attributes
- [x]
AllowResizable - [x]
AllowShared - [x]
Clamp - [x]
EnforceRange - [x]
Exposed/validateExposedOverloads - ...
- [x]
- §3.4 Legacy extended attributes
- [x]
LegacyNullToEmptyString - [x]
LegacyOverrideBuiltIns - [x]
LegacyTreatNonObjectAsNull - [x]
LegacyUnenumerableNamedProperties - [x]
LegacyUnforgeable—isUnforgeableOnInterface,isUnforgeable,validateUnforgeablePlacement,validateUnforgeableOverloads,validateUnforgeableInheritance - ...
- [x]
- §3.6 Overload resolution algorithm
- [x]
resolveOverloads
- [x]
- §3.7 Interfaces
- §3.7.1 Interface object
- [x]
InterfaceObject(getInterfaceOf/setInterfaceOf)
- [x]
- §3.7.3 Interface prototype object
- [x]
InterfacePrototypeObject(getInterfaceOf/setInterfaceOf)
- [x]
- §3.7.6 Attributes
- [x]
defineAttributes - [x]
defineRegularAttributes/defineStaticAttributes - [x]
defineUnforgeableRegularAttributes - [x]
createAttributeGetter/createAttributeSetter
- [x]
- §3.7.7 Operations
- [x]
defineOperations - [x]
defineRegularOperations/defineStaticOperations - [x]
defineUnforgeableRegularOperations - [x]
createOperationFunction
- [x]
- §3.7.9 Iterable declarations
- [x]
defineTheIterationMethods
- [x]
- ...
- §3.7.1 Interface object
- §3.8 Platform objects
- [x]
isPlatformObject - [x]
implementsInterface - [x]
implementsInterfaceWithExtAttribute
- [x]
- §3.9 Legacy platform objects
- [x]
LegacyPlatformObjectInternalMethods - [x]
isUnforgeablePropertyName - §3.9.1
[[GetOwnProperty]]- [x]
getOwnProperty
- [x]
- §3.9.2
[[Set]]- [x]
set
- [x]
- §3.9.3
[[DefineOwnProperty]]- [x]
defineOwnProperty
- [x]
- §3.9.4
[[Delete]]- [x]
del
- [x]
- §3.9.5
[[PreventExtensions]]- [x]
preventExtensions
- [x]
- §3.9.6
[[OwnPropertyKeys]]- [x]
ownPropertyKeys
- [x]
- §3.9.7 Abstract operations
- [x]
legacyPlatformObjectGetOwnProperty - [x]
isNamedPropertyVisible - [x]
invokeIndexedPropertySetter - [x]
invokeNamedPropertySetter - [x]
isArrayIndex
- [x]
- [x]
- ...
- §3.2 JavaScript type mapping
- ...
