# ♓️🪡 सूत्र ∷ X·S·D

♓️🪡 सूत्र ∷ X·S·D provides an implementation of the
[X·M·L Schema Definition Language][XSD-1], including the
[X·M·L Schema Definition Datatypes][XSD-2], for Ecmascript.

## Notes

### Typechecking

All of the functions provided by `./functions.js` will throw an error
if they are given arguments which do not match the expectations
established by the X·S·D spec. No type coersion occurs.

### Efficiency

♓️🪡 सूत्र ∷ X·S·D emphasizes algorithm correctness and takes a somewhat
extreme stance with regards to spec adherence. This means that the
algorithms used may be somewhat slow, although native platform features
will be leveraged when possible.

### Numeric values

♓️🪡 सूत्र ∷ X·S·D treats all numeric values as native Ecmascript
numbers. This may lead to rounding errors for decimals and extreme
values.

This behaviour may change in the future; see
<https://github.com/tc39/proposal-decimal> for progress on getting a
more precise decimal type into Ecmascript.

### Positive and Negative Zero

X·S·D only formally distinguishes positive and negative zero for floats
and doubles, but it allows them to be represented lexically in all
other signed numeric types. ♓️🪡 सूत्र ∷ X·S·D silently coerces negative
zero to positive zero for numeric datatypes in which it is not an
explicit part of the value space, as well as for numeric components of
other datatypes (e·g durations).

### Date∕times and Durations

♓️🪡 सूत्र ∷ X·S·D does not provide actual classes for X·S·D
date/timeSevenPropertyModel values or durations, treatings both as
simple objects. This approach was taken to maximize compatibility with
other modules. Formally :—

1. A duration is any object for which getting the `months` property
   returns an integer, getting the `seconds` property returns a finite
   number, and these two values have the same sign. (Positive and
   negative zero are treated as having the same sign for this
   comparison.)

   Note that `months` and `seconds` **must not** be undefined.

2. A date/timeSevenPropertyModel value is any object for which getting
   the `year`, `month`, `day`, `hour`, `minute`, `second`, and
   `timezoneOffset` properties returns values within the bounds
   specified in the X·S·D specification. Absent values can be
   represented with undefined, and need not actually be defined on the
   object).

Functions which return durations or date/timeSevenPropertyModel values
will always return a plain, extensible object which :—

- Inherits from `%ObjectPrototype%`,
- Has all of the applicable properties defined as enumerable,
  configurable, writable own data properties (absent properties will be
  defined with a value of undefined), and
- Has no other own properties.

[XSD-1]: <https://www.w3.org/TR/xmlschema11-1/>
[XSD-2]: <https://www.w3.org/TR/xmlschema11-2/>
