Comparing version
12
base.js
@@ -5,2 +5,3 @@ var deprecate = require('deprecate') | ||
var RAW = Symbol('raw') | ||
var VALUE = Symbol('value') | ||
@@ -13,3 +14,6 @@ | ||
var raw = val instanceof Base ? val[VALUE] : val | ||
var value = parse.call(this, val, ...args) | ||
prop(this, RAW, raw) | ||
prop(this, VALUE, value) | ||
@@ -39,2 +43,6 @@ prop(this, 'isError', value instanceof Error, 'e') | ||
Base.raw = function (opt) { | ||
return Base.prototype.raw.call(opt) | ||
} | ||
Base.unwrap = function (opt) { | ||
@@ -61,2 +69,6 @@ deprecate('Base.unwrap()', 'Use the equivalent Base.extract() instead.') | ||
Base.prototype.raw = function () { | ||
return this[RAW] | ||
} | ||
Base.prototype.use = function (map) { | ||
@@ -63,0 +75,0 @@ if (typeof map === 'function') { |
{ | ||
"name": "stdopt", | ||
"version": "9.2.0", | ||
"version": "9.3.0", | ||
"description": "Wrap and validate optional values", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,2 +11,4 @@ var test = require('tape') | ||
t.equal(opt().or().or('nope').value(), 'nope') | ||
t.equal(opt().raw(), undefined) | ||
t.equal(opt().or(null).raw(), null) | ||
t.throws(() => opt(null).or(undefined).value()) | ||
@@ -13,0 +15,0 @@ t.throws(() => opt(undefined).use()) |
27096
1.11%420
2.69%