You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
6 years ago
|
"use strict";
|
||
|
|
||
|
const typeRules = require("./type-rules");
|
||
|
const createType = require("./create-type");
|
||
|
const createTrait = require("./create-trait");
|
||
|
const guardFunction = require("./guard-function");
|
||
|
const errors = require("./errors");
|
||
|
|
||
|
/* Traits:
|
||
|
- Special 'slot' value; for use in trait implementations to indicate that the specified trait definition property should be filled in by the instance constructor, not by the trait implementation
|
||
|
|
||
|
Possible field types for a trait:
|
||
|
- Static value [add the value to the type's prototype?]
|
||
|
- Type/validation rule [check against implementation, see below]
|
||
|
|
||
|
Possible field types for a trait implementation (all of them fill in type/validation rules):
|
||
|
- Static value, including an appropriately guarded function [add the value to the type's prototype?]
|
||
|
- Slot [add the trait rule to the type rules]
|
||
|
|
||
|
Disallow extra fields in trait implementations!
|
||
|
|
||
|
TODO: Add full property paths to errors?
|
||
|
|
||
|
*/
|
||
|
|
||
|
module.exports = Object.assign({
|
||
|
createType: createType,
|
||
|
createTrait: createTrait,
|
||
|
guard: guardFunction,
|
||
|
ValidationError: errors.ValidationError
|
||
|
}, typeRules);
|