intertype
Advanced tools
Comparing version 0.117.0 to 0.118.0
@@ -456,3 +456,3 @@ (function() { | ||
_create(type, cfg) { | ||
var R, create, ref1, t, type_dsc; | ||
var create, template, type_dsc; | ||
create = null; | ||
@@ -467,15 +467,26 @@ //....................................................................................................... | ||
if ((create = GUY.props.get(type_dsc, 'create', null)) === null) { | ||
if ((R = GUY.props.get(type_dsc, 'template', H.signals.nothing)) === H.signals.nothing) { | ||
if ((template = GUY.props.get(type_dsc, 'template', H.signals.nothing)) === H.signals.nothing) { | ||
throw new E.Intertype_ETEMPTBD('^intertype.create@12^', `type ${rpr(type)} does not have a \`template\` value or a \`create()\` method`); | ||
} | ||
} | ||
//....................................................................................................... | ||
return this._validate(type, this._create_no_validation({ | ||
create, | ||
template, | ||
freeze: type_dsc.freeze, | ||
cfg | ||
})); | ||
} | ||
//--------------------------------------------------------------------------------------------------------- | ||
_create_no_validation({create, template, freeze, cfg}) { | ||
var R, t; | ||
//....................................................................................................... | ||
if (create != null) { | ||
R = create.call(this, cfg); | ||
} else { | ||
/* If `create` is given, call it to obtain template value: */ | ||
//....................................................................................................... | ||
R = create.call(this, cfg); | ||
} | ||
//....................................................................................................... | ||
if (create == null) { | ||
if (cfg != null) { | ||
if ((t = H.js_type_of(R)) === '[object Object]' || t === '[object Array]') { | ||
R = Object.assign(H.deep_copy(R), cfg); | ||
if ((t = H.js_type_of(template)) === '[object Object]' || t === '[object Array]') { | ||
R = Object.assign(H.deep_copy(template), cfg); | ||
} else { | ||
@@ -485,13 +496,13 @@ R = cfg; | ||
} else { | ||
R = H.deep_copy(R); | ||
R = H.deep_copy(template); | ||
} | ||
} | ||
//....................................................................................................... | ||
if ((ref1 = type_dsc.freeze) === true || ref1 === 'shallow') { | ||
if (freeze === true || freeze === 'shallow') { | ||
R = Object.freeze(R); | ||
} else if (type_dsc.freeze === 'deep') { | ||
} else if (freeze === 'deep') { | ||
R = GUY.lft.freeze(H.deep_copy(R)); | ||
} | ||
//....................................................................................................... | ||
return this._validate(type, R); | ||
return R; | ||
} | ||
@@ -498,0 +509,0 @@ |
{ | ||
"name": "intertype", | ||
"version": "0.117.0", | ||
"version": "0.118.0", | ||
"description": "A JavaScript typechecker", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
364742
1968