+6
-0
@@ -36,2 +36,8 @@ var inherits = require('inherits') | ||
| Base.construct = function (Opt) { | ||
| return new Proxy(Opt, { | ||
| apply: (Target, self, args) => new Target(...args) | ||
| }) | ||
| } | ||
| Base.extract = function (opt) { | ||
@@ -38,0 +44,0 @@ return Base.prototype.extract.call(opt) |
+1
-2
| var Base = require('./base') | ||
| var apply = require('./util/apply') | ||
@@ -20,2 +19,2 @@ function boolean (b) { | ||
| module.exports = apply(boolean) | ||
| module.exports = Base.construct(boolean) |
+1
-2
| var Base = require('./base') | ||
| var VError = require('verror') | ||
| var apply = require('./util/apply') | ||
@@ -63,2 +62,2 @@ function hash (obj, struct) { | ||
| module.exports = apply(hash) | ||
| module.exports = Base.construct(hash) |
+1
-2
| var Base = require('./base') | ||
| var VError = require('verror') | ||
| var apply = require('./util/apply') | ||
| var some = require('./opt') | ||
@@ -57,2 +56,2 @@ var isArrayish = require('is-arrayish') | ||
| module.exports = apply(list) | ||
| module.exports = Base.construct(list) |
+1
-2
| var Base = require('./base') | ||
| var apply = require('./util/apply') | ||
@@ -14,2 +13,2 @@ function nothing (n) { | ||
| module.exports = apply(nothing) | ||
| module.exports = Base.construct(nothing) |
+1
-2
| var Base = require('./base') | ||
| var apply = require('./util/apply') | ||
@@ -16,2 +15,2 @@ function number (n) { | ||
| module.exports = apply(number) | ||
| module.exports = Base.construct(number) |
+1
-2
| var Base = require('./base') | ||
| var apply = require('./util/apply') | ||
@@ -15,2 +14,2 @@ function opt (val) { | ||
| module.exports = apply(opt) | ||
| module.exports = Base.construct(opt) |
+1
-1
| { | ||
| "name": "stdopt", | ||
| "version": "10.1.0", | ||
| "version": "10.2.0", | ||
| "description": "Wrap and validate optional values", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+1
-2
| var Base = require('./base') | ||
| var apply = require('./util/apply') | ||
@@ -17,2 +16,2 @@ function string (s) { | ||
| module.exports = apply(string) | ||
| module.exports = Base.construct(string) |
+4
-5
@@ -21,5 +21,4 @@ var test = require('tape') | ||
| var Base = require('../base') | ||
| var apply = require('../util/apply') | ||
| var Custom = apply(function Custom (input) { | ||
| var Custom = Base.construct(function Custom (input) { | ||
| Base.call(this, input) | ||
@@ -41,3 +40,3 @@ }) | ||
| var Nested = apply(function Nested (input) { | ||
| var Nested = Base.construct(function Nested (input) { | ||
| Base.call(this, input) | ||
@@ -50,7 +49,7 @@ }) | ||
| var Fail = apply(function Fail (input) { | ||
| var Fail = Base.construct(function Fail (input) { | ||
| Base.call(this, input) | ||
| }) | ||
| var Unparseable = apply(function Unparseable (input) { | ||
| var Unparseable = Base.construct(function Unparseable (input) { | ||
| Base.call(this, input) | ||
@@ -57,0 +56,0 @@ }) |
| module.exports = function (Opt) { | ||
| return new Proxy(Opt, { | ||
| apply (Target, self, args) { | ||
| return new Target(...args) | ||
| } | ||
| }) | ||
| } |
27521
-0.75%22
-4.35%436
-2.24%