@akromio/doubles
Advanced tools
Comparing version 0.4.0 to 0.4.1
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const $Double = class Double { | ||
constructor(_) { | ||
/* c8 ignore start */if (_ == null) _ = {}; | ||
/* c8 ignore stop */ /* c8 ignore start */ | ||
if (this._pvt_cb9cf777cf7912870cb7631893f35053___init__ instanceof Function) this._pvt_cb9cf777cf7912870cb7631893f35053___init__(_); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (_ == null) _ = {}; | ||
/* c8 ignore stop */ | ||
if (this._pvt_cb9cf777cf7912870cb7631893f35053___post__ instanceof Function) this._pvt_cb9cf777cf7912870cb7631893f35053___post__(); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_cb9cf777cf7912870cb7631893f35053___init__ instanceof Function) this._pvt_cb9cf777cf7912870cb7631893f35053___init__(_); | ||
/* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_cb9cf777cf7912870cb7631893f35053___post__ instanceof Function) this._pvt_cb9cf777cf7912870cb7631893f35053___post__(); | ||
/* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_cb9cf777cf7912870cb7631893f35053___validate__ instanceof Function) this._pvt_cb9cf777cf7912870cb7631893f35053___validate__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_cb9cf777cf7912870cb7631893f35053___validate__ instanceof Function) this._pvt_cb9cf777cf7912870cb7631893f35053___validate__(); /* c8 ignore stop */ | ||
} | ||
}; | ||
}; | ||
const Double = new Proxy($Double, { | ||
/* c8 ignore start */ | ||
apply(receiver, self, args) { | ||
/* c8 ignore start */apply(receiver, self, args) { | ||
throw "'Double' is abstract."; | ||
} | ||
/* c8 ignore stop */ | ||
} /* c8 ignore stop */ | ||
}); | ||
module.exports = exports = Double; |
@@ -7,15 +7,8 @@ "use strict"; | ||
exports.simulator = exports.monitor = exports.method = exports.interceptor = exports.fun = exports.field = exports.constructor = void 0; | ||
var _core = require("@dogmalang/core"); | ||
const simulator = _core.dogma.use(require("./simulator")); | ||
exports.simulator = simulator; | ||
const monitor = _core.dogma.use(require("./monitor")); | ||
exports.monitor = monitor; | ||
const interceptor = _core.dogma.use(require("./interceptor")); | ||
exports.interceptor = interceptor; | ||
@@ -22,0 +15,0 @@ const { |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const Interceptor = _core.dogma.use(require("./Interceptor")); | ||
const createMembers = _core.dogma.use(require("../simulator/createMembers")); | ||
function interceptor(object, members) { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("object", object, _core.any); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */_core.dogma.expect("object", object, _core.any); /* c8 ignore next */ | ||
_core.dogma.expect("members", members, _core.map); | ||
{ | ||
@@ -21,13 +13,6 @@ return createObjectInterceptor(object, members); | ||
} | ||
module.exports = exports = interceptor; | ||
function createObjectInterceptor(object, members) { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("object", object); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */_core.dogma.expect("object", object); /* c8 ignore next */ | ||
_core.dogma.expect("members", members, _core.map); | ||
{ | ||
@@ -40,23 +25,11 @@ return createInterceptorProxy(Interceptor({ | ||
} | ||
function createInterceptorProxy(interceptor, members) { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("interceptor", interceptor); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */_core.dogma.expect("interceptor", interceptor); /* c8 ignore next */ | ||
_core.dogma.expect("members", members); | ||
{ | ||
return (0, _core.proxy)(interceptor.intercepted, { | ||
'get': (_, member) => { | ||
let result; | ||
/* c8 ignore next */ | ||
_core.dogma.expect("_", _); | ||
/* c8 ignore next */ | ||
let result; /* c8 ignore next */ | ||
_core.dogma.expect("_", _); /* c8 ignore next */ | ||
_core.dogma.expect("member", member); | ||
{ | ||
@@ -74,13 +47,6 @@ if (interceptor.hasToIntercept(member)) { | ||
} | ||
interceptor.modules = {}; | ||
interceptor.module = (path, members) => { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("path", path, _core.text); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */_core.dogma.expect("path", path, _core.text); /* c8 ignore next */ | ||
_core.dogma.expect("members", members, _core.map); | ||
{ | ||
@@ -90,9 +56,6 @@ const { | ||
} = require; | ||
if (!_core.dogma.includes(cache, path)) { | ||
require(path); | ||
} | ||
const mod = _core.dogma.getItem(cache, path); | ||
const inter = Interceptor({ | ||
@@ -103,19 +66,13 @@ 'intercepted': mod.exports, | ||
const interProxy = createInterceptorProxy(inter, members); | ||
_core.dogma.setItem("=", cache, path, _core.dogma.clone(mod, { | ||
"exports": interProxy | ||
}, {}, [], [])); | ||
_core.dogma.setItem("=", interceptor.modules, path, inter); | ||
} | ||
}; | ||
interceptor.clear = path => { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("path", path, _core.text); | ||
/* c8 ignore next */_core.dogma.expect("path", path, _core.text); | ||
{ | ||
{ | ||
const inter = _core.dogma.getItem(interceptor.modules, path); | ||
if (inter) { | ||
@@ -122,0 +79,0 @@ _core.dogma.getItem(require.cache, path).exports = inter.intercepted; |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const Simulator = _core.dogma.use(require("../simulator/Simulator")); | ||
const $Interceptor = class Interceptor extends Simulator { | ||
@@ -11,6 +9,4 @@ constructor(_) { | ||
/* c8 ignore start */ | ||
if (_ == null) _ = {}; | ||
/* c8 ignore stop */ | ||
(0, _core.expect)('intercepted', _['intercepted'], null); | ||
@@ -23,18 +19,10 @@ Object.defineProperty(this, 'intercepted', { | ||
/* c8 ignore start */ | ||
if (this._pvt_569315759c4f306b90867948a8bd3c13___init__ instanceof Function) this._pvt_569315759c4f306b90867948a8bd3c13___init__(_); | ||
/* c8 ignore stop */ | ||
if (this._pvt_569315759c4f306b90867948a8bd3c13___init__ instanceof Function) this._pvt_569315759c4f306b90867948a8bd3c13___init__(_); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_569315759c4f306b90867948a8bd3c13___post__ instanceof Function) this._pvt_569315759c4f306b90867948a8bd3c13___post__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_569315759c4f306b90867948a8bd3c13___post__ instanceof Function) this._pvt_569315759c4f306b90867948a8bd3c13___post__(); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_569315759c4f306b90867948a8bd3c13___validate__ instanceof Function) this._pvt_569315759c4f306b90867948a8bd3c13___validate__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_569315759c4f306b90867948a8bd3c13___validate__ instanceof Function) this._pvt_569315759c4f306b90867948a8bd3c13___validate__(); /* c8 ignore stop */ | ||
} | ||
}; | ||
}; | ||
const Interceptor = new Proxy($Interceptor, { | ||
@@ -44,12 +32,7 @@ apply(receiver, self, args) { | ||
} | ||
}); | ||
module.exports = exports = Interceptor; | ||
Interceptor.prototype.hasToIntercept = function (name) { | ||
const self = this; | ||
/* c8 ignore next */ | ||
const self = this; /* c8 ignore next */ | ||
_core.dogma.expect("name", name); | ||
{ | ||
@@ -56,0 +39,0 @@ return _core.dogma.is(name, _core.text) && _core.dogma.includes(this.members, name); |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const Monitor = _core.dogma.use(require("./Monitor")); | ||
const Result = _core.dogma.use(require("./Result")); | ||
const Log = _core.dogma.use(require("./log/Log")); | ||
const AccessKind = _core.dogma.use(require("./log/AccessKind")); | ||
const monitors = []; | ||
function monitor(object, opts) { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("object", object); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */_core.dogma.expect("object", object); /* c8 ignore next */ | ||
if (opts != null) _core.dogma.expect("opts", opts, _core.map); | ||
@@ -26,24 +16,13 @@ { | ||
} | ||
module.exports = exports = monitor; | ||
function createMonitor(object, opts) { | ||
let p; | ||
/* c8 ignore next */ | ||
_core.dogma.expect("object", object); | ||
/* c8 ignore next */ | ||
let p; /* c8 ignore next */ | ||
_core.dogma.expect("object", object); /* c8 ignore next */ | ||
_core.dogma.expect("opts", opts, _core.map); | ||
{ | ||
var _ref, _opts$members, _opts$log; | ||
const members = _core.dogma.copy((_ref = (_opts$members = opts.members) !== null && _opts$members !== void 0 ? _opts$members : opts.methods) !== null && _ref !== void 0 ? _ref : []); | ||
if (opts.method) { | ||
members.push(opts.method); | ||
} | ||
const m = Monitor({ | ||
@@ -54,32 +33,18 @@ 'target': object, | ||
}); | ||
if ((_core.dogma.includes(opts, "methods") || _core.dogma.includes(opts, "method")) && !_core.dogma.includes(opts, "members") && !_core.dogma.includes(opts, "onlyCalls")) { | ||
opts.onlyCalls = true; | ||
} | ||
p = (0, _core.proxy)(object, { | ||
["apply"]: (target, thisArg, args) => { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("target", target); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */_core.dogma.expect("target", target); /* c8 ignore next */ | ||
_core.dogma.expect("args", args); | ||
{ | ||
let result; | ||
let value; | ||
try { | ||
/*c8 ignore else*/ | ||
if (_core.dogma.is(target.apply, _core.func)) { | ||
/*c8 ignore else*/if (_core.dogma.is(target.apply, _core.func)) { | ||
value = target.apply(thisArg, args); | ||
} | ||
/* c8 ignore start */ | ||
else { | ||
} /* c8 ignore start */else { | ||
value = target(...args); | ||
} | ||
/* c8 ignore stop */ | ||
} /* c8 ignore stop */ | ||
result = Result.returned; | ||
@@ -90,3 +55,2 @@ } catch (e) { | ||
} | ||
m.saveCall({ | ||
@@ -98,7 +62,5 @@ 'target': target, | ||
}); | ||
if (_core.dogma.enumEq(result, "raised")) { | ||
_core.dogma.raise(value); | ||
} | ||
return value; | ||
@@ -108,13 +70,5 @@ } | ||
["get"]: (target, member, receiver) => { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("target", target); | ||
/* c8 ignore next */ | ||
_core.dogma.expect("member", member); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */_core.dogma.expect("target", target); /* c8 ignore next */ | ||
_core.dogma.expect("member", member); /* c8 ignore next */ | ||
_core.dogma.expect("receiver", receiver); | ||
{ | ||
@@ -124,6 +78,4 @@ if (!m.hasToBeMonitorized(member)) { | ||
} | ||
let result; | ||
let value; | ||
try { | ||
@@ -136,3 +88,2 @@ value = _core.dogma.getItem(target, member); | ||
} | ||
if (!opts.onlyCalls) { | ||
@@ -147,3 +98,2 @@ m.saveAccess({ | ||
} | ||
if (_core.dogma.enumEq(result, "raised")) { | ||
@@ -161,17 +111,6 @@ _core.dogma.raise(value); | ||
["set"]: (target, member, value, receiver) => { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("target", target); | ||
/* c8 ignore next */ | ||
_core.dogma.expect("member", member); | ||
/* c8 ignore next */ | ||
_core.dogma.expect("value", value); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */_core.dogma.expect("target", target); /* c8 ignore next */ | ||
_core.dogma.expect("member", member); /* c8 ignore next */ | ||
_core.dogma.expect("value", value); /* c8 ignore next */ | ||
_core.dogma.expect("receiver", receiver); | ||
{ | ||
@@ -181,8 +120,5 @@ if (!m.hasToBeMonitorized(member) || opts.onlyCalls) { | ||
} | ||
let result; | ||
try { | ||
_core.dogma.setItem("=", target, member, value); | ||
result = Result.returned; | ||
@@ -193,3 +129,2 @@ } catch (e) { | ||
} | ||
m.saveAccess({ | ||
@@ -202,3 +137,2 @@ 'target': target, | ||
}); | ||
if (_core.dogma.enumEq(result, "raised")) { | ||
@@ -219,3 +153,2 @@ _core.dogma.raise(value); | ||
} | ||
Object.defineProperty(monitor, "monitors", { | ||
@@ -229,3 +162,2 @@ ["enumerable"]: false, | ||
}); | ||
monitor.clearAll = () => { | ||
@@ -236,15 +168,9 @@ { | ||
}; | ||
monitor.clear = p => { | ||
let deleted = false; | ||
/* c8 ignore next */ | ||
let deleted = false; /* c8 ignore next */ | ||
_core.dogma.expect("p", p); | ||
{ | ||
{ | ||
const i = monitors.findIndex(i => { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("i", i); | ||
/* c8 ignore next */_core.dogma.expect("i", i); | ||
{ | ||
@@ -254,3 +180,2 @@ return i.proxy === p; | ||
}); | ||
if (i >= 0) { | ||
@@ -264,11 +189,5 @@ monitors.splice(i, 1); | ||
}; | ||
monitor.log = (p, opts) => { | ||
let log; | ||
/* c8 ignore next */ | ||
_core.dogma.expect("p", p); | ||
/* c8 ignore next */ | ||
let log; /* c8 ignore next */ | ||
_core.dogma.expect("p", p); /* c8 ignore next */ | ||
if (opts != null) _core.dogma.expect("opts", opts, _core.dogma.intf("inline", { | ||
@@ -287,7 +206,5 @@ clear: { | ||
log = item.monitor.log; | ||
if (clear) { | ||
monitor.clear(p); | ||
} | ||
break; | ||
@@ -294,0 +211,0 @@ } |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const Entry = _core.dogma.use(require("./Entry")); | ||
const AccessKind = _core.dogma.use(require("./AccessKind")); | ||
const $Access = class Access extends Entry { | ||
@@ -13,6 +10,4 @@ constructor(_) { | ||
/* c8 ignore start */ | ||
if (_ == null) _ = {}; | ||
/* c8 ignore stop */ | ||
(0, _core.expect)('member', _['member'], null); | ||
@@ -31,18 +26,10 @@ Object.defineProperty(this, 'member', { | ||
/* c8 ignore start */ | ||
if (this._pvt_88db894fc1b220e88bd447ff5857e995___init__ instanceof Function) this._pvt_88db894fc1b220e88bd447ff5857e995___init__(_); | ||
/* c8 ignore stop */ | ||
if (this._pvt_88db894fc1b220e88bd447ff5857e995___init__ instanceof Function) this._pvt_88db894fc1b220e88bd447ff5857e995___init__(_); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_88db894fc1b220e88bd447ff5857e995___post__ instanceof Function) this._pvt_88db894fc1b220e88bd447ff5857e995___post__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_88db894fc1b220e88bd447ff5857e995___post__ instanceof Function) this._pvt_88db894fc1b220e88bd447ff5857e995___post__(); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_88db894fc1b220e88bd447ff5857e995___validate__ instanceof Function) this._pvt_88db894fc1b220e88bd447ff5857e995___validate__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_88db894fc1b220e88bd447ff5857e995___validate__ instanceof Function) this._pvt_88db894fc1b220e88bd447ff5857e995___validate__(); /* c8 ignore stop */ | ||
} | ||
}; | ||
}; | ||
const Access = new Proxy($Access, { | ||
@@ -52,6 +39,4 @@ apply(receiver, self, args) { | ||
} | ||
}); | ||
module.exports = exports = Access; | ||
Access.prototype.isGet = function () { | ||
@@ -66,3 +51,2 @@ const self = this; | ||
}; | ||
Access.prototype.isSet = function () { | ||
@@ -69,0 +53,0 @@ const self = this; |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
class AccessKind { | ||
@@ -16,5 +15,4 @@ constructor(name, val) { | ||
} | ||
/* c8 ignore start */ | ||
toString() { | ||
@@ -24,4 +22,2 @@ return this.name; | ||
/* c8 ignore stop */ | ||
} | ||
@@ -28,0 +24,0 @@ |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const isEqual = _core.dogma.use(require("lodash.isequal")); | ||
const Entry = _core.dogma.use(require("./Entry")); | ||
const $Call = class Call extends Entry { | ||
@@ -13,6 +10,4 @@ constructor(_) { | ||
/* c8 ignore start */ | ||
if (_ == null) _ = {}; | ||
/* c8 ignore stop */ | ||
(0, _core.expect)('args', _['args'], _core.list); | ||
@@ -25,18 +20,10 @@ Object.defineProperty(this, 'args', { | ||
/* c8 ignore start */ | ||
if (this._pvt_87c7bff78982f609dde586d9cbb89392___init__ instanceof Function) this._pvt_87c7bff78982f609dde586d9cbb89392___init__(_); | ||
/* c8 ignore stop */ | ||
if (this._pvt_87c7bff78982f609dde586d9cbb89392___init__ instanceof Function) this._pvt_87c7bff78982f609dde586d9cbb89392___init__(_); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_87c7bff78982f609dde586d9cbb89392___post__ instanceof Function) this._pvt_87c7bff78982f609dde586d9cbb89392___post__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_87c7bff78982f609dde586d9cbb89392___post__ instanceof Function) this._pvt_87c7bff78982f609dde586d9cbb89392___post__(); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_87c7bff78982f609dde586d9cbb89392___validate__ instanceof Function) this._pvt_87c7bff78982f609dde586d9cbb89392___validate__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_87c7bff78982f609dde586d9cbb89392___validate__ instanceof Function) this._pvt_87c7bff78982f609dde586d9cbb89392___validate__(); /* c8 ignore stop */ | ||
} | ||
}; | ||
}; | ||
const Call = new Proxy($Call, { | ||
@@ -46,13 +33,8 @@ apply(receiver, self, args) { | ||
} | ||
}); | ||
module.exports = exports = Call; | ||
Call.prototype.calledWith = function (args) { | ||
const self = this; | ||
let yep = false; | ||
/* c8 ignore next */ | ||
let yep = false; /* c8 ignore next */ | ||
_core.dogma.expect("args", args, _core.list); | ||
{ | ||
@@ -59,0 +41,0 @@ if ((0, _core.len)(this.args) == (0, _core.len)(args)) { |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const Result = _core.dogma.use(require("../Result")); | ||
const $Entry = class Entry { | ||
constructor(_) { | ||
/* c8 ignore start */ | ||
if (_ == null) _ = {}; | ||
/* c8 ignore start */if (_ == null) _ = {}; | ||
/* c8 ignore stop */ | ||
Object.defineProperty(this, 'value', { | ||
@@ -25,26 +21,14 @@ value: (0, _core.coalesce)(_['value'], null), | ||
/* c8 ignore start */ | ||
if (this._pvt_08c8bd51d95a37d7d68928207c15d8da___init__ instanceof Function) this._pvt_08c8bd51d95a37d7d68928207c15d8da___init__(_); | ||
/* c8 ignore stop */ | ||
if (this._pvt_08c8bd51d95a37d7d68928207c15d8da___init__ instanceof Function) this._pvt_08c8bd51d95a37d7d68928207c15d8da___init__(_); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_08c8bd51d95a37d7d68928207c15d8da___post__ instanceof Function) this._pvt_08c8bd51d95a37d7d68928207c15d8da___post__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_08c8bd51d95a37d7d68928207c15d8da___post__ instanceof Function) this._pvt_08c8bd51d95a37d7d68928207c15d8da___post__(); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_08c8bd51d95a37d7d68928207c15d8da___validate__ instanceof Function) this._pvt_08c8bd51d95a37d7d68928207c15d8da___validate__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_08c8bd51d95a37d7d68928207c15d8da___validate__ instanceof Function) this._pvt_08c8bd51d95a37d7d68928207c15d8da___validate__(); /* c8 ignore stop */ | ||
} | ||
}; | ||
}; | ||
const Entry = new Proxy($Entry, { | ||
/* c8 ignore start */ | ||
apply(receiver, self, args) { | ||
/* c8 ignore start */apply(receiver, self, args) { | ||
throw "'Entry' is abstract."; | ||
} | ||
/* c8 ignore stop */ | ||
} /* c8 ignore stop */ | ||
}); | ||
@@ -70,3 +54,2 @@ module.exports = exports = Entry; | ||
}); | ||
Entry.prototype.returnedValue = function (value) { | ||
@@ -78,9 +61,5 @@ const self = this; | ||
}; | ||
Entry.prototype.returnedType = function (Type) { | ||
const self = this; | ||
/* c8 ignore next */ | ||
const self = this; /* c8 ignore next */ | ||
_core.dogma.expect("Type", Type); | ||
{ | ||
@@ -90,3 +69,2 @@ return this.returned && _core.dogma.is(this.value, Type); | ||
}; | ||
Entry.prototype.raisedValue = function (value) { | ||
@@ -98,9 +76,5 @@ const self = this; | ||
}; | ||
Entry.prototype.raisedType = function (Type) { | ||
const self = this; | ||
/* c8 ignore next */ | ||
const self = this; /* c8 ignore next */ | ||
_core.dogma.expect("Type", Type); | ||
{ | ||
@@ -107,0 +81,0 @@ return this.raised && _core.dogma.is(this.value, Type); |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const Access = _core.dogma.use(require("./Access")); | ||
const Call = _core.dogma.use(require("./Call")); | ||
const $Log = class Log { | ||
constructor(_) { | ||
/* c8 ignore start */ | ||
if (_ == null) _ = {}; | ||
/* c8 ignore start */if (_ == null) _ = {}; | ||
/* c8 ignore stop */ | ||
Object.defineProperty(this, 'items', { | ||
@@ -21,18 +16,10 @@ value: [], | ||
/* c8 ignore start */ | ||
if (this._pvt_cb769d1323fb42de11b4fe6146d48364___init__ instanceof Function) this._pvt_cb769d1323fb42de11b4fe6146d48364___init__(_); | ||
/* c8 ignore stop */ | ||
if (this._pvt_cb769d1323fb42de11b4fe6146d48364___init__ instanceof Function) this._pvt_cb769d1323fb42de11b4fe6146d48364___init__(_); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_cb769d1323fb42de11b4fe6146d48364___post__ instanceof Function) this._pvt_cb769d1323fb42de11b4fe6146d48364___post__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_cb769d1323fb42de11b4fe6146d48364___post__ instanceof Function) this._pvt_cb769d1323fb42de11b4fe6146d48364___post__(); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_cb769d1323fb42de11b4fe6146d48364___validate__ instanceof Function) this._pvt_cb769d1323fb42de11b4fe6146d48364___validate__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_cb769d1323fb42de11b4fe6146d48364___validate__ instanceof Function) this._pvt_cb769d1323fb42de11b4fe6146d48364___validate__(); /* c8 ignore stop */ | ||
} | ||
}; | ||
}; | ||
const Log = new Proxy($Log, { | ||
@@ -42,3 +29,2 @@ apply(receiver, self, args) { | ||
} | ||
}); | ||
@@ -58,3 +44,2 @@ module.exports = exports = Log; | ||
}); | ||
Log.prototype.getEntriesByType = function (Type) { | ||
@@ -65,7 +50,4 @@ const self = this; | ||
} = self; | ||
let entries = []; | ||
/* c8 ignore next */ | ||
let entries = []; /* c8 ignore next */ | ||
_core.dogma.expect("Type", Type); | ||
{ | ||
@@ -80,3 +62,2 @@ for (const i of items) { | ||
}; | ||
Object.defineProperty(Log.prototype, "calls", { | ||
@@ -142,3 +123,2 @@ enum: true, | ||
}); | ||
Log.prototype.saveCall = function (call) { | ||
@@ -148,7 +128,4 @@ const self = this; | ||
items | ||
} = self; | ||
/* c8 ignore next */ | ||
} = self; /* c8 ignore next */ | ||
_core.dogma.expect("call", call); | ||
{ | ||
@@ -158,3 +135,2 @@ items.push(Call(call)); | ||
}; | ||
Log.prototype.saveAccess = function (access) { | ||
@@ -164,7 +140,4 @@ const self = this; | ||
items | ||
} = self; | ||
/* c8 ignore next */ | ||
} = self; /* c8 ignore next */ | ||
_core.dogma.expect("access", access); | ||
{ | ||
@@ -174,3 +147,2 @@ items.push(Access(access)); | ||
}; | ||
Log.prototype.returnedValue = function (value) { | ||
@@ -191,3 +163,2 @@ const self = this; | ||
}; | ||
Log.prototype.returnedType = function (Type) { | ||
@@ -198,7 +169,4 @@ const self = this; | ||
} = self; | ||
let count = 0; | ||
/* c8 ignore next */ | ||
let count = 0; /* c8 ignore next */ | ||
_core.dogma.expect("Type", Type); | ||
{ | ||
@@ -213,3 +181,2 @@ for (const item of items) { | ||
}; | ||
Log.prototype.raisedValue = function (value) { | ||
@@ -230,3 +197,2 @@ const self = this; | ||
}; | ||
Log.prototype.raisedType = function (Type) { | ||
@@ -237,7 +203,4 @@ const self = this; | ||
} = self; | ||
let count = 0; | ||
/* c8 ignore next */ | ||
let count = 0; /* c8 ignore next */ | ||
_core.dogma.expect("Type", Type); | ||
{ | ||
@@ -252,3 +215,2 @@ for (const item of items) { | ||
}; | ||
Log.prototype.calledWith = function (args) { | ||
@@ -259,7 +221,4 @@ const self = this; | ||
} = self; | ||
let count = 0; | ||
/* c8 ignore next */ | ||
let count = 0; /* c8 ignore next */ | ||
_core.dogma.expect("args", args, _core.list); | ||
{ | ||
@@ -274,3 +233,2 @@ for (const item of items) { | ||
}; | ||
Log.prototype.getEntry = function (i) { | ||
@@ -280,7 +238,4 @@ const self = this; | ||
items | ||
} = self; | ||
/* c8 ignore next */ | ||
} = self; /* c8 ignore next */ | ||
_core.dogma.expect("i", i, _core.num); | ||
{ | ||
@@ -290,3 +245,2 @@ return _core.dogma.getItem(items, i); | ||
}; | ||
Object.defineProperty(Log.prototype, "entry", { | ||
@@ -304,3 +258,2 @@ enum: true, | ||
}); | ||
Log.prototype.getEntryByType = function (Type, i) { | ||
@@ -311,14 +264,7 @@ const self = this; | ||
} = self; | ||
let entry; | ||
/* c8 ignore next */ | ||
_core.dogma.expect("Type", Type); | ||
/* c8 ignore next */ | ||
let entry; /* c8 ignore next */ | ||
_core.dogma.expect("Type", Type); /* c8 ignore next */ | ||
_core.dogma.expect("i", i, _core.num); | ||
{ | ||
let pos = 0; | ||
for (const item of items) { | ||
@@ -337,3 +283,2 @@ if (_core.dogma.is(item, Type)) { | ||
}; | ||
Log.prototype.getCall = function (i) { | ||
@@ -343,7 +288,4 @@ const self = this; | ||
items | ||
} = self; | ||
/* c8 ignore next */ | ||
} = self; /* c8 ignore next */ | ||
_core.dogma.expect("i", i, _core.num); | ||
{ | ||
@@ -353,3 +295,2 @@ return this.getEntryByType(Call, i); | ||
}; | ||
Object.defineProperty(Log.prototype, "call", { | ||
@@ -367,3 +308,2 @@ enum: true, | ||
}); | ||
Log.prototype.getAccess = function (i) { | ||
@@ -373,7 +313,4 @@ const self = this; | ||
items | ||
} = self; | ||
/* c8 ignore next */ | ||
} = self; /* c8 ignore next */ | ||
_core.dogma.expect("i", i, _core.num); | ||
{ | ||
@@ -380,0 +317,0 @@ return this.getEntryByType(Access, i); |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const Double = _core.dogma.use(require("../Double")); | ||
const Log = _core.dogma.use(require("./log/Log")); | ||
const $Monitor = class Monitor extends Double { | ||
@@ -13,6 +10,4 @@ constructor(_) { | ||
/* c8 ignore start */ | ||
if (_ == null) _ = {}; | ||
/* c8 ignore stop */ | ||
(0, _core.expect)('log', _['log'], Log); | ||
@@ -42,18 +37,10 @@ Object.defineProperty(this, 'log', { | ||
/* c8 ignore start */ | ||
if (this._pvt_6d5d4d2373594d4f18d906d4ea54acf9___init__ instanceof Function) this._pvt_6d5d4d2373594d4f18d906d4ea54acf9___init__(_); | ||
/* c8 ignore stop */ | ||
if (this._pvt_6d5d4d2373594d4f18d906d4ea54acf9___init__ instanceof Function) this._pvt_6d5d4d2373594d4f18d906d4ea54acf9___init__(_); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_6d5d4d2373594d4f18d906d4ea54acf9___post__ instanceof Function) this._pvt_6d5d4d2373594d4f18d906d4ea54acf9___post__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_6d5d4d2373594d4f18d906d4ea54acf9___post__ instanceof Function) this._pvt_6d5d4d2373594d4f18d906d4ea54acf9___post__(); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_6d5d4d2373594d4f18d906d4ea54acf9___validate__ instanceof Function) this._pvt_6d5d4d2373594d4f18d906d4ea54acf9___validate__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_6d5d4d2373594d4f18d906d4ea54acf9___validate__ instanceof Function) this._pvt_6d5d4d2373594d4f18d906d4ea54acf9___validate__(); /* c8 ignore stop */ | ||
} | ||
}; | ||
}; | ||
const Monitor = new Proxy($Monitor, { | ||
@@ -63,6 +50,4 @@ apply(receiver, self, args) { | ||
} | ||
}); | ||
module.exports = exports = Monitor; | ||
Monitor.prototype.hasToBeMonitorized = function (name) { | ||
@@ -73,7 +58,4 @@ const self = this; | ||
members | ||
} = self; | ||
/* c8 ignore next */ | ||
} = self; /* c8 ignore next */ | ||
_core.dogma.expect("name", name, _core.text); | ||
{ | ||
@@ -83,3 +65,2 @@ return (0, _core.len)(members) == 0 || _core.dogma.includes(members, name); | ||
}; | ||
Monitor.prototype.saveCall = function (...args) { | ||
@@ -96,3 +77,2 @@ const self = this; | ||
}; | ||
Monitor.prototype.saveAccess = function (...args) { | ||
@@ -99,0 +79,0 @@ const self = this; |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
class Result { | ||
@@ -16,5 +15,4 @@ constructor(name, val) { | ||
} | ||
/* c8 ignore start */ | ||
toString() { | ||
@@ -24,4 +22,2 @@ return this.name; | ||
/* c8 ignore stop */ | ||
} | ||
@@ -28,0 +24,0 @@ |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const isEqual = _core.dogma.use(require("lodash.isequal")); | ||
const Behavior = _core.dogma.use(require("./Behavior")); | ||
const $ArgsBasedBehavior = class ArgsBasedBehavior extends Behavior { | ||
@@ -13,23 +10,12 @@ constructor(_) { | ||
/* c8 ignore start */ | ||
if (_ == null) _ = {}; | ||
/* c8 ignore stop */ | ||
/* c8 ignore stop */ /* c8 ignore start */ | ||
if (this._pvt_4737a5c8c83360a6985997432a25cf4e___init__ instanceof Function) this._pvt_4737a5c8c83360a6985997432a25cf4e___init__(_); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_4737a5c8c83360a6985997432a25cf4e___init__ instanceof Function) this._pvt_4737a5c8c83360a6985997432a25cf4e___init__(_); | ||
/* c8 ignore stop */ | ||
if (this._pvt_4737a5c8c83360a6985997432a25cf4e___post__ instanceof Function) this._pvt_4737a5c8c83360a6985997432a25cf4e___post__(); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_4737a5c8c83360a6985997432a25cf4e___post__ instanceof Function) this._pvt_4737a5c8c83360a6985997432a25cf4e___post__(); | ||
/* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_4737a5c8c83360a6985997432a25cf4e___validate__ instanceof Function) this._pvt_4737a5c8c83360a6985997432a25cf4e___validate__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_4737a5c8c83360a6985997432a25cf4e___validate__ instanceof Function) this._pvt_4737a5c8c83360a6985997432a25cf4e___validate__(); /* c8 ignore stop */ | ||
} | ||
}; | ||
}; | ||
const ArgsBasedBehavior = new Proxy($ArgsBasedBehavior, { | ||
@@ -39,16 +25,10 @@ apply(receiver, self, args) { | ||
} | ||
}); | ||
module.exports = exports = ArgsBasedBehavior; | ||
ArgsBasedBehavior.prototype.getResponse = function (args) { | ||
const self = this; | ||
let resp; | ||
/* c8 ignore next */ | ||
let resp; /* c8 ignore next */ | ||
_core.dogma.expect("args", args, _core.list); | ||
{ | ||
var _resp; | ||
for (const r of this.responses) { | ||
@@ -60,3 +40,2 @@ if (isEqual(args, r.args)) { | ||
} | ||
resp = (_resp = resp) !== null && _resp !== void 0 ? _resp : this.defaultResponse; | ||
@@ -63,0 +42,0 @@ } |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const Response = _core.dogma.use(require("./Response")); | ||
const Operation = _core.dogma.use(require("./Operation")); | ||
const $Behavior = class Behavior { | ||
constructor(_) { | ||
/* c8 ignore start */ | ||
if (_ == null) _ = {}; | ||
/* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (_['defaultResponse'] != null) (0, _core.expect)('defaultResponse', _['defaultResponse'], Response); | ||
/* c8 ignore stop */ | ||
/* c8 ignore start */if (_ == null) _ = {}; | ||
/* c8 ignore stop */ /* c8 ignore start */ | ||
if (_['defaultResponse'] != null) (0, _core.expect)('defaultResponse', _['defaultResponse'], Response); /* c8 ignore stop */ | ||
Object.defineProperty(this, 'defaultResponse', { | ||
@@ -31,39 +22,22 @@ value: (0, _core.coalesce)(_['defaultResponse'], null), | ||
/* c8 ignore start */ | ||
if (this._pvt_ec09dbab37e822c66ee398a96920b003___init__ instanceof Function) this._pvt_ec09dbab37e822c66ee398a96920b003___init__(_); | ||
/* c8 ignore stop */ | ||
if (this._pvt_ec09dbab37e822c66ee398a96920b003___init__ instanceof Function) this._pvt_ec09dbab37e822c66ee398a96920b003___init__(_); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_ec09dbab37e822c66ee398a96920b003___post__ instanceof Function) this._pvt_ec09dbab37e822c66ee398a96920b003___post__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_ec09dbab37e822c66ee398a96920b003___post__ instanceof Function) this._pvt_ec09dbab37e822c66ee398a96920b003___post__(); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_ec09dbab37e822c66ee398a96920b003___validate__ instanceof Function) this._pvt_ec09dbab37e822c66ee398a96920b003___validate__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_ec09dbab37e822c66ee398a96920b003___validate__ instanceof Function) this._pvt_ec09dbab37e822c66ee398a96920b003___validate__(); /* c8 ignore stop */ | ||
} | ||
}; | ||
}; | ||
const Behavior = new Proxy($Behavior, { | ||
/* c8 ignore start */ | ||
apply(receiver, self, args) { | ||
/* c8 ignore start */apply(receiver, self, args) { | ||
throw "'Behavior' is abstract."; | ||
} | ||
/* c8 ignore stop */ | ||
} /* c8 ignore stop */ | ||
}); | ||
module.exports = exports = Behavior; | ||
Behavior.prototype.addResponse = function (decl) { | ||
const self = this; | ||
/* c8 ignore next */ | ||
const self = this; /* c8 ignore next */ | ||
_core.dogma.expect("decl", decl); | ||
{ | ||
let value; | ||
let operation; | ||
if (_core.dogma.includes(decl, "returns")) { | ||
@@ -87,3 +61,2 @@ value = decl.returns; | ||
} | ||
const resp = Response({ | ||
@@ -94,3 +67,2 @@ 'args': decl.args, | ||
}); | ||
if (_core.dogma.includes(decl, "default")) { | ||
@@ -105,7 +77,4 @@ this.defaultResponse = resp; | ||
/* c8 ignore start */ | ||
Behavior.prototype.getResponse = function () { | ||
(0, _core.abstract)(); | ||
}; | ||
/* c8 ignore stop */ | ||
}; /* c8 ignore stop */ |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
class Operation { | ||
@@ -16,5 +15,4 @@ constructor(name, val) { | ||
} | ||
/* c8 ignore start */ | ||
toString() { | ||
@@ -24,4 +22,2 @@ return this.name; | ||
/* c8 ignore stop */ | ||
} | ||
@@ -28,0 +24,0 @@ |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const Behavior = _core.dogma.use(require("./Behavior")); | ||
const $PositionBasedBehavior = class PositionBasedBehavior extends Behavior { | ||
@@ -11,6 +9,4 @@ constructor(_) { | ||
/* c8 ignore start */ | ||
if (_ == null) _ = {}; | ||
/* c8 ignore stop */ | ||
Object.defineProperty(this, 'currentIndex', { | ||
@@ -27,18 +23,10 @@ value: -1, | ||
/* c8 ignore start */ | ||
if (this._pvt_d2551189215301f7ae9105ae582e2c2c___init__ instanceof Function) this._pvt_d2551189215301f7ae9105ae582e2c2c___init__(_); | ||
/* c8 ignore stop */ | ||
if (this._pvt_d2551189215301f7ae9105ae582e2c2c___init__ instanceof Function) this._pvt_d2551189215301f7ae9105ae582e2c2c___init__(_); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_d2551189215301f7ae9105ae582e2c2c___post__ instanceof Function) this._pvt_d2551189215301f7ae9105ae582e2c2c___post__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_d2551189215301f7ae9105ae582e2c2c___post__ instanceof Function) this._pvt_d2551189215301f7ae9105ae582e2c2c___post__(); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_d2551189215301f7ae9105ae582e2c2c___validate__ instanceof Function) this._pvt_d2551189215301f7ae9105ae582e2c2c___validate__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_d2551189215301f7ae9105ae582e2c2c___validate__ instanceof Function) this._pvt_d2551189215301f7ae9105ae582e2c2c___validate__(); /* c8 ignore stop */ | ||
} | ||
}; | ||
}; | ||
const PositionBasedBehavior = new Proxy($PositionBasedBehavior, { | ||
@@ -48,17 +36,11 @@ apply(receiver, self, args) { | ||
} | ||
}); | ||
module.exports = exports = PositionBasedBehavior; | ||
PositionBasedBehavior.prototype.getResponse = function (args) { | ||
const self = this; | ||
let resp; | ||
/* c8 ignore next */ | ||
let resp; /* c8 ignore next */ | ||
_core.dogma.expect("args", args, _core.list); | ||
{ | ||
{ | ||
const i = this.currentIndex += 1; | ||
if ((0, _core.len)(this.responses) > i) { | ||
@@ -65,0 +47,0 @@ resp = _core.dogma.getItem(this.responses, i); |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const Operation = _core.dogma.use(require("./Operation")); | ||
const $Response = class Response { | ||
constructor(_) { | ||
/* c8 ignore start */ | ||
if (_ == null) _ = {}; | ||
/* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (_['args'] != null) (0, _core.expect)('args', _['args'], _core.list); | ||
/* c8 ignore stop */ | ||
/* c8 ignore start */if (_ == null) _ = {}; | ||
/* c8 ignore stop */ /* c8 ignore start */ | ||
if (_['args'] != null) (0, _core.expect)('args', _['args'], _core.list); /* c8 ignore stop */ | ||
Object.defineProperty(this, 'args', { | ||
@@ -35,18 +27,10 @@ value: (0, _core.coalesce)(_['args'], null), | ||
/* c8 ignore start */ | ||
if (this._pvt_8c4971dc352f2b8fc05a675618226a13___init__ instanceof Function) this._pvt_8c4971dc352f2b8fc05a675618226a13___init__(_); | ||
/* c8 ignore stop */ | ||
if (this._pvt_8c4971dc352f2b8fc05a675618226a13___init__ instanceof Function) this._pvt_8c4971dc352f2b8fc05a675618226a13___init__(_); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_8c4971dc352f2b8fc05a675618226a13___post__ instanceof Function) this._pvt_8c4971dc352f2b8fc05a675618226a13___post__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_8c4971dc352f2b8fc05a675618226a13___post__ instanceof Function) this._pvt_8c4971dc352f2b8fc05a675618226a13___post__(); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_8c4971dc352f2b8fc05a675618226a13___validate__ instanceof Function) this._pvt_8c4971dc352f2b8fc05a675618226a13___validate__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_8c4971dc352f2b8fc05a675618226a13___validate__ instanceof Function) this._pvt_8c4971dc352f2b8fc05a675618226a13___validate__(); /* c8 ignore stop */ | ||
} | ||
}; | ||
}; | ||
const Response = new Proxy($Response, { | ||
@@ -56,4 +40,3 @@ apply(receiver, self, args) { | ||
} | ||
}); | ||
module.exports = exports = Response; |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const Behavior = _core.dogma.use(require("./behavior/Behavior")); | ||
function createMembers(def) { | ||
let members = {}; | ||
/* c8 ignore next */ | ||
let members = {}; /* c8 ignore next */ | ||
_core.dogma.expect("def", def, _core.map); | ||
{ | ||
@@ -19,3 +14,2 @@ for (const [name, value] of Object.entries(def)) { | ||
} | ||
_core.dogma.setItem("=", members, name, value); | ||
@@ -27,3 +21,2 @@ } | ||
} | ||
module.exports = exports = createMembers; |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const { | ||
Duplex | ||
} = _core.dogma.use(require("stream")); | ||
const uuid = _core.dogma.use(require("uuid")); | ||
const PositionBasedBehavior = _core.dogma.use(require("./behavior/PositionBasedBehavior")); | ||
function field(def) { | ||
let behavior; | ||
/* c8 ignore next */ | ||
let behavior; /* c8 ignore next */ | ||
_core.dogma.expect("def", def, [_core.list, _core.map]); | ||
{ | ||
behavior = PositionBasedBehavior(); | ||
if (_core.dogma.is(def, _core.list)) { | ||
@@ -34,5 +26,3 @@ for (const resp of def) { | ||
} | ||
module.exports = exports = field; | ||
field.returns = value => { | ||
@@ -49,3 +39,2 @@ let behavior; | ||
}; | ||
field.uuid = () => { | ||
@@ -62,9 +51,5 @@ let behavior; | ||
}; | ||
field.text = returns => { | ||
let behavior; | ||
/* c8 ignore next */ | ||
let behavior; /* c8 ignore next */ | ||
_core.dogma.expect("returns", returns, _core.text); | ||
{ | ||
@@ -79,9 +64,5 @@ behavior = PositionBasedBehavior(); | ||
}; | ||
field.bool = returns => { | ||
let behavior; | ||
/* c8 ignore next */ | ||
let behavior; /* c8 ignore next */ | ||
_core.dogma.expect("returns", returns, _core.bool); | ||
{ | ||
@@ -96,11 +77,7 @@ behavior = PositionBasedBehavior(); | ||
}; | ||
field.list = returns => { | ||
let behavior; | ||
/* c8 ignore next */ | ||
let behavior; /* c8 ignore next */ | ||
if (returns != null) _core.dogma.expect("returns", returns, _core.list); | ||
{ | ||
var _dogma$copy; | ||
behavior = PositionBasedBehavior(); | ||
@@ -114,11 +91,7 @@ behavior.addResponse({ | ||
}; | ||
field.map = returns => { | ||
let behavior; | ||
/* c8 ignore next */ | ||
let behavior; /* c8 ignore next */ | ||
if (returns != null) _core.dogma.expect("returns", returns, _core.map); | ||
{ | ||
var _dogma$copy2; | ||
behavior = PositionBasedBehavior(); | ||
@@ -132,9 +105,5 @@ behavior.addResponse({ | ||
}; | ||
field.any = returns => { | ||
let behavior; | ||
/* c8 ignore next */ | ||
let behavior; /* c8 ignore next */ | ||
_core.dogma.expect("returns", returns, _core.any); | ||
{ | ||
@@ -149,16 +118,9 @@ behavior = PositionBasedBehavior(); | ||
}; | ||
field.stream = { | ||
["duplex"]: () => { | ||
{ | ||
return ( | ||
/* c8 ignore start */ | ||
new Duplex({ | ||
return (/* c8 ignore start */new Duplex({ | ||
read() {}, | ||
write() {} | ||
}) | ||
/* c8 ignore stop */ | ||
}) /* c8 ignore stop */ | ||
); | ||
@@ -165,0 +127,0 @@ } |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const { | ||
Duplex | ||
} = _core.dogma.use(require("stream")); | ||
const Simulator = _core.dogma.use(require("./Simulator")); | ||
const Behavior = _core.dogma.use(require("./behavior/Behavior")); | ||
const PositionBasedBehavior = _core.dogma.use(require("./behavior/PositionBasedBehavior")); | ||
const ArgsBasedBehavior = _core.dogma.use(require("./behavior/ArgsBasedBehavior")); | ||
const field = _core.dogma.use(require("./field")); | ||
const createMembers = _core.dogma.use(require("./createMembers")); | ||
function simulator(...args) { | ||
@@ -26,3 +18,2 @@ let sim; | ||
const size = (0, _core.len)(args); | ||
switch (size) { | ||
@@ -32,31 +23,18 @@ case 0: | ||
sim = createObjectSimulator({}); | ||
} | ||
/* c8 ignore start */ | ||
} /* c8 ignore start */ | ||
break; | ||
/* c8 ignore stop */ | ||
case 1: | ||
{ | ||
sim = createObjectSimulator(_core.dogma.getItem(args, 0)); | ||
} | ||
/* c8 ignore start */ | ||
} /* c8 ignore start */ | ||
break; | ||
/* c8 ignore stop */ | ||
case 2: | ||
{ | ||
const [Type, members] = _core.dogma.getArrayToUnpack(args, 2); | ||
sim = _core.dogma.setTypeToObject(createObjectSimulator(members), Type); | ||
} | ||
/* c8 ignore start */ | ||
} /* c8 ignore start */ | ||
break; | ||
/* c8 ignore stop */ | ||
default: | ||
@@ -71,10 +49,5 @@ { | ||
} | ||
module.exports = exports = simulator; | ||
simulator.fun = simulator.method = (behavior, members) => { | ||
/* c8 ignore next */ | ||
if (behavior != null) _core.dogma.expect("behavior", behavior, [_core.list, _core.map]); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */if (behavior != null) _core.dogma.expect("behavior", behavior, [_core.list, _core.map]); /* c8 ignore next */ | ||
if (members != null) _core.dogma.expect("members", members, _core.map); | ||
@@ -85,43 +58,42 @@ { | ||
}; | ||
simulator.fun.resolves = value => { | ||
{ | ||
return createFunctionSimulator({ | ||
'resolves': value | ||
'resolves': value, | ||
'default': true | ||
}); | ||
} | ||
}; | ||
simulator.fun.rejects = value => { | ||
{ | ||
return createFunctionSimulator({ | ||
'rejects': value | ||
'rejects': value, | ||
'default': true | ||
}); | ||
} | ||
}; | ||
simulator.fun.returns = value => { | ||
{ | ||
return createFunctionSimulator({ | ||
'returns': value | ||
'returns': value, | ||
'default': true | ||
}); | ||
} | ||
}; | ||
simulator.fun.raises = value => { | ||
{ | ||
return createFunctionSimulator({ | ||
'raises': value | ||
'raises': value, | ||
'default': true | ||
}); | ||
} | ||
}; | ||
simulator.fun.invokes = fun => { | ||
{ | ||
return createFunctionSimulator({ | ||
'invokes': fun | ||
'invokes': fun, | ||
'default': true | ||
}); | ||
} | ||
}; | ||
simulator.constructor = simulator.fun; | ||
@@ -135,12 +107,6 @@ simulator.constructor.returns = simulator.fun.returns; | ||
{ | ||
return ( | ||
/* c8 ignore start */ | ||
new Duplex({ | ||
return (/* c8 ignore start */new Duplex({ | ||
read() {}, | ||
write() {} | ||
}) | ||
/* c8 ignore stop */ | ||
}) /* c8 ignore stop */ | ||
); | ||
@@ -150,7 +116,4 @@ } | ||
}; | ||
function createObjectSimulator(def) { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("def", def, _core.map); | ||
/* c8 ignore next */_core.dogma.expect("def", def, _core.map); | ||
{ | ||
@@ -162,9 +125,4 @@ const sim = Simulator({ | ||
["get"]: (_, member) => { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("_", _); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */_core.dogma.expect("_", _); /* c8 ignore next */ | ||
_core.dogma.expect("member", member); | ||
{ | ||
@@ -177,8 +135,4 @@ return sim.processGet(member); | ||
} | ||
function createFunctionSimulator(def, members) { | ||
/* c8 ignore next */ | ||
if (def != null) _core.dogma.expect("def", def, [_core.list, _core.map]); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */if (def != null) _core.dogma.expect("def", def, [_core.list, _core.map]); /* c8 ignore next */ | ||
if (members != null) _core.dogma.expect("members", members, _core.map); | ||
@@ -189,5 +143,3 @@ { | ||
} | ||
let behavior; | ||
if (_core.dogma.is(def, _core.list)) { | ||
@@ -197,3 +149,2 @@ let Behavior = PositionBasedBehavior; | ||
const _ = (0, _core.len)(def); | ||
switch (_) { | ||
@@ -203,9 +154,5 @@ case 0: | ||
_core.dogma.nop(); | ||
} | ||
/* c8 ignore start */ | ||
} /* c8 ignore start */ | ||
break; | ||
/* c8 ignore stop */ | ||
case 1: | ||
@@ -216,9 +163,5 @@ { | ||
} | ||
} | ||
/* c8 ignore start */ | ||
} /* c8 ignore start */ | ||
break; | ||
/* c8 ignore stop */ | ||
default: | ||
@@ -233,3 +176,2 @@ { | ||
behavior = Behavior(); | ||
for (const resp of def) { | ||
@@ -240,5 +182,8 @@ behavior.addResponse(resp); | ||
behavior = PositionBasedBehavior(); | ||
behavior.addResponse(_core.dogma.clone(def, { | ||
"default": true | ||
}, {}, [], [])); | ||
if (!_core.dogma.includes(def, "default")) { | ||
def = _core.dogma.clone(def, { | ||
"default": true | ||
}, {}, [], []); | ||
} | ||
behavior.addResponse(def); | ||
} else { | ||
@@ -251,3 +196,2 @@ behavior = PositionBasedBehavior(); | ||
} | ||
const sim = Simulator({ | ||
@@ -259,9 +203,4 @@ 'callBehavior': behavior, | ||
["construct"]: (_, args) => { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("_", _); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */_core.dogma.expect("_", _); /* c8 ignore next */ | ||
_core.dogma.expect("args", args); | ||
{ | ||
@@ -272,9 +211,4 @@ return sim.processCall(args); | ||
["apply"]: (_, thisArg, args) => { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("_", _); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */_core.dogma.expect("_", _); /* c8 ignore next */ | ||
_core.dogma.expect("args", args); | ||
{ | ||
@@ -285,13 +219,5 @@ return sim.processCall(args); | ||
["get"]: (_, member, receiver) => { | ||
/* c8 ignore next */ | ||
_core.dogma.expect("_", _); | ||
/* c8 ignore next */ | ||
_core.dogma.expect("member", member); | ||
/* c8 ignore next */ | ||
/* c8 ignore next */_core.dogma.expect("_", _); /* c8 ignore next */ | ||
_core.dogma.expect("member", member); /* c8 ignore next */ | ||
_core.dogma.expect("receiver", receiver); | ||
{ | ||
@@ -298,0 +224,0 @@ return sim.processGet(member); |
"use strict"; | ||
var _core = require("@dogmalang/core"); | ||
const Double = _core.dogma.use(require("../Double")); | ||
const Behavior = _core.dogma.use(require("./behavior/Behavior")); | ||
const Response = _core.dogma.use(require("./behavior/Response")); | ||
const Operation = _core.dogma.use(require("./behavior/Operation")); | ||
const $Simulator = class Simulator extends Double { | ||
@@ -17,6 +12,4 @@ constructor(_) { | ||
/* c8 ignore start */ | ||
if (_ == null) _ = {}; | ||
/* c8 ignore stop */ | ||
Object.defineProperty(this, 'callBehavior', { | ||
@@ -28,6 +21,3 @@ value: (0, _core.coalesce)(_['callBehavior'], null), | ||
/* c8 ignore start */ | ||
if (_['members'] != null) (0, _core.expect)('members', _['members'], _core.map); | ||
/* c8 ignore stop */ | ||
if (_['members'] != null) (0, _core.expect)('members', _['members'], _core.map); /* c8 ignore stop */ | ||
Object.defineProperty(this, 'members', { | ||
@@ -39,18 +29,10 @@ value: (0, _core.coalesce)(_['members'], {}), | ||
/* c8 ignore start */ | ||
if (this._pvt_03d44f9db5eb626e6037e42fcf944e43___init__ instanceof Function) this._pvt_03d44f9db5eb626e6037e42fcf944e43___init__(_); | ||
/* c8 ignore stop */ | ||
if (this._pvt_03d44f9db5eb626e6037e42fcf944e43___init__ instanceof Function) this._pvt_03d44f9db5eb626e6037e42fcf944e43___init__(_); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_03d44f9db5eb626e6037e42fcf944e43___post__ instanceof Function) this._pvt_03d44f9db5eb626e6037e42fcf944e43___post__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_03d44f9db5eb626e6037e42fcf944e43___post__ instanceof Function) this._pvt_03d44f9db5eb626e6037e42fcf944e43___post__(); /* c8 ignore stop */ | ||
/* c8 ignore start */ | ||
if (this._pvt_03d44f9db5eb626e6037e42fcf944e43___validate__ instanceof Function) this._pvt_03d44f9db5eb626e6037e42fcf944e43___validate__(); | ||
/* c8 ignore stop */ | ||
if (this._pvt_03d44f9db5eb626e6037e42fcf944e43___validate__ instanceof Function) this._pvt_03d44f9db5eb626e6037e42fcf944e43___validate__(); /* c8 ignore stop */ | ||
} | ||
}; | ||
}; | ||
const Simulator = new Proxy($Simulator, { | ||
@@ -60,6 +42,4 @@ apply(receiver, self, args) { | ||
} | ||
}); | ||
module.exports = exports = Simulator; | ||
Simulator.prototype.processCall = function (args) { | ||
@@ -71,11 +51,7 @@ const self = this; | ||
} = self; | ||
let result; | ||
/* c8 ignore next */ | ||
let result; /* c8 ignore next */ | ||
_core.dogma.expect("args", args, _core.list); | ||
{ | ||
{ | ||
const resp = callBehavior.getResponse(args); | ||
if (resp) { | ||
@@ -90,3 +66,2 @@ result = this.handleResponse(resp, args); | ||
}; | ||
Simulator.prototype.processGet = function (member) { | ||
@@ -98,7 +73,4 @@ const self = this; | ||
} = self; | ||
let result; | ||
/* c8 ignore next */ | ||
let result; /* c8 ignore next */ | ||
_core.dogma.expect("member", member); | ||
{ | ||
@@ -111,3 +83,2 @@ if (_core.dogma.is(result = _core.dogma.getItem(members, member), Behavior)) { | ||
}; | ||
Simulator.prototype.handleResponse = function (resp, args) { | ||
@@ -119,9 +90,4 @@ const self = this; | ||
} = self; | ||
let result; | ||
/* c8 ignore next */ | ||
_core.dogma.expect("resp", resp, Response); | ||
/* c8 ignore next */ | ||
let result; /* c8 ignore next */ | ||
_core.dogma.expect("resp", resp, Response); /* c8 ignore next */ | ||
if (args != null) _core.dogma.expect("args", args, _core.list); | ||
@@ -131,3 +97,2 @@ { | ||
const _ = resp.operation; | ||
switch (_) { | ||
@@ -137,47 +102,28 @@ case Operation.retur: | ||
result = resp.value; | ||
} | ||
/* c8 ignore start */ | ||
} /* c8 ignore start */ | ||
break; | ||
/* c8 ignore stop */ | ||
case Operation.raise: | ||
{ | ||
_core.dogma.raise(resp.value); | ||
} | ||
/* c8 ignore start */ | ||
} /* c8 ignore start */ | ||
break; | ||
/* c8 ignore stop */ | ||
case Operation.resolve: | ||
{ | ||
result = _core.promise.resolve(resp.value); | ||
} | ||
/* c8 ignore start */ | ||
} /* c8 ignore start */ | ||
break; | ||
/* c8 ignore stop */ | ||
case Operation.reject: | ||
{ | ||
result = _core.promise.reject(resp.value); | ||
} | ||
/* c8 ignore start */ | ||
} /* c8 ignore start */ | ||
break; | ||
/* c8 ignore stop */ | ||
case Operation.call: | ||
{ | ||
result = resp.value(...(args !== null && args !== void 0 ? args : [])); | ||
} | ||
/* c8 ignore start */ | ||
} /* c8 ignore start */ | ||
break; | ||
/* c8 ignore stop */ | ||
@@ -184,0 +130,0 @@ } |
{ | ||
"name": "@akromio/doubles", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Test doubles library.", | ||
@@ -43,3 +43,3 @@ "homepage": "https://akromio.com", | ||
"devDependencies": { | ||
"short-uuid": "^4.2.0" | ||
"short-uuid": "^4.2.2" | ||
}, | ||
@@ -54,3 +54,3 @@ "scripts": { | ||
}, | ||
"gitHead": "94a60d141dde041f3b3594a1d90b2d6931d02df9" | ||
"gitHead": "d9b45098bf543e80f4c938d2e3b7026b53bcd3a6" | ||
} |
68759
1996