@algebraic/type
Advanced tools
Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2
12
data.js
@@ -38,4 +38,7 @@ const { declaration, fNamed, is, getTypename } = require("./declaration"); | ||
const getChildren = () => children || (children = fParseMap(fieldDefinitions)); | ||
const constructor = fNamed(`${typename}`, function (fields) | ||
const create = fNamed(`[create ${typename}]`, function (fields) | ||
{ | ||
if (!(this instanceof type)) | ||
return new type(fields); | ||
if (!fields) | ||
@@ -63,6 +66,5 @@ throw TypeError(`${typename} cannot be created without any fields.`); | ||
}); | ||
constructor.prototype.toString = function () { return inspect(this) }; | ||
const create = fNamed(`[create ${typename}]`, | ||
fields => new constructor(fields)); | ||
const is = value => value instanceof constructor; | ||
type.prototype.toString = function () { return inspect(this) }; | ||
const is = value => value instanceof type; | ||
const serialize = [toSerialize(typename, getChildren), false]; | ||
@@ -69,0 +71,0 @@ const deserialize = toDeserialize(typename, getChildren, type); |
{ | ||
"name": "@algebraic/type", | ||
"version": "1.0.0-alpha.1", | ||
"version": "1.0.0-alpha.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "type.js", |
const Map = global.Map; | ||
const { getSerialize } = require("./declaration"); | ||
const { getPrototypeOf } = Object; | ||
@@ -5,0 +4,0 @@ |
12507
327