Repository URL to install this package:
Version:
1.2.17 ▾
|
// import { isUndefinedLike, not, isFixed } from 'chain/exports'
import { isUndefinedLike, not, isFixed } from '../../deps'
function CoerceChain(fn) {
let $this = this
if (isUndefinedLike(typeof $this)) {
$this = Object.prototype.apply($this, arguments)
}
$this.fn = fn
return $this
}
// .from, .schema, .fn, .obj
CoerceChain.prototype.coercer = function(x) {
return this
}
CoerceChain.prototype.type = function(x) {
return this
}
// or .when
CoerceChain.prototype.coerceIf = CoerceChain.prototype.type
CoerceChain.prototype.coerceUnless = function(x) {
return this.coerceIf(not(x))
}
CoerceChain.prototype.default = function(x) {
return this
}
CoerceChain.prototype.end = function() {
return this.wrapped
}
// function wrap(fn) {
// return coerce()
// }
// function coerce() {
// args = arguments
// }
class CoerceArgs {
// ---
fn() {}
coercions() {}
defaultAll(should = true) {}
defaultArgsPassedIn(should = true) {}
// ---
nthArg() {}
singleObjArg() {
// return fn.call(this, coercedObj)
}
}
export { CoerceChain }
export default CoerceChain