@akromio/dataset
Advanced tools
Comparing version 0.20.1 to 0.21.0
@@ -9,2 +9,45 @@ "use strict"; | ||
{ | ||
suite("post", () => { | ||
{ | ||
test("when merge, this must be merged to the value", () => { | ||
{ | ||
const out = ConstDatum({ | ||
'name': "c", | ||
'merge': { | ||
["y"]: 2 | ||
}, | ||
'value': { | ||
["x"]: 1, | ||
["z"]: 3 | ||
} | ||
}); | ||
expected(out.getValue()).equalTo({ | ||
'x': 1, | ||
'y': 2, | ||
'z': 3 | ||
}); | ||
} | ||
}); | ||
test("when append, this must be concatenated to the value", () => { | ||
{ | ||
const out = ConstDatum({ | ||
'name': "c", | ||
'append': [3, 4], | ||
'value': [1, 2] | ||
}); | ||
expected(out.getValue([1, 2, 3, 4])); | ||
} | ||
}); | ||
test("when prepend, value must be concatenated to this", () => { | ||
{ | ||
const out = ConstDatum({ | ||
'name': "c", | ||
'prepend': [3, 4], | ||
'value': [1, 2] | ||
}); | ||
expected(out.getValue([3, 4, 1, 2])); | ||
} | ||
}); | ||
} | ||
}); | ||
suite("setValue()", () => { | ||
@@ -21,3 +64,3 @@ { | ||
}); | ||
expected(out).it(0).equalTo(false).it(1).toBe(DatumError).like("The datum 'c' is not updatable."); | ||
expected(out).it(0).equalTo(false).it(1).toBe(DatumError).like("Datum 'c' is not updatable."); | ||
} | ||
@@ -24,0 +67,0 @@ }); |
@@ -84,3 +84,3 @@ "use strict"; | ||
if (!this.isUpdatable()) { | ||
_core.dogma.raise(DatumError(`The datum '${self.name}' is not updatable.`)); | ||
_core.dogma.raise(DatumError(`Datum '${self.name}' is not updatable.`)); | ||
} | ||
@@ -87,0 +87,0 @@ this.setValueWithoutUpdatableCheck(value); |
@@ -11,2 +11,23 @@ "use strict"; | ||
/* c8 ignore stop */ /* c8 ignore start */ | ||
if (_['prepend'] != null) (0, _core.expect)('prepend', _['prepend'], _core.list); /* c8 ignore stop */ | ||
Object.defineProperty(this, 'prepend', { | ||
value: (0, _core.coalesce)(_['prepend'], null), | ||
writable: false, | ||
enumerable: false | ||
}); | ||
/* c8 ignore start */ | ||
if (_['append'] != null) (0, _core.expect)('append', _['append'], _core.list); /* c8 ignore stop */ | ||
Object.defineProperty(this, 'append', { | ||
value: (0, _core.coalesce)(_['append'], null), | ||
writable: false, | ||
enumerable: false | ||
}); | ||
/* c8 ignore start */ | ||
if (_['merge'] != null) (0, _core.expect)('merge', _['merge'], _core.map); /* c8 ignore stop */ | ||
Object.defineProperty(this, 'merge', { | ||
value: (0, _core.coalesce)(_['merge'], null), | ||
writable: false, | ||
enumerable: false | ||
}); | ||
/* c8 ignore start */ | ||
if (this._pvt_7d9434ddf072357483ef0e4e8237feb3___init__ instanceof Function) this._pvt_7d9434ddf072357483ef0e4e8237feb3___init__(_); /* c8 ignore stop */ | ||
@@ -26,2 +47,40 @@ /* c8 ignore start */ | ||
module.exports = exports = DatumContainer; | ||
DatumContainer.prototype._pvt_7d9434ddf072357483ef0e4e8237feb3_post = function () { | ||
const self = this; | ||
{ | ||
let { | ||
value | ||
} = this; | ||
{ | ||
const _ = value; | ||
if (_core.dogma.is(_, _core.list)) { | ||
{ | ||
{ | ||
const prepend = this.prepend; | ||
if (prepend) { | ||
value = prepend.concat(value); | ||
} | ||
} | ||
{ | ||
const append = this.append; | ||
if (append) { | ||
value = value.concat(append); | ||
} | ||
} | ||
this.value = value; | ||
} | ||
} else if (_core.dogma.is(_, _core.map)) { | ||
{ | ||
{ | ||
const merge = this.merge; | ||
if (merge) { | ||
this.value = _core.dogma.clone(value, {}, {}, [], [merge]); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
DatumContainer.prototype._pvt_7d9434ddf072357483ef0e4e8237feb3___post__ = DatumContainer.prototype._pvt_7d9434ddf072357483ef0e4e8237feb3_post; | ||
DatumContainer.prototype.getValue = function () { | ||
@@ -28,0 +87,0 @@ const self = this; |
@@ -42,3 +42,3 @@ "use strict"; | ||
}); | ||
expected(out).it(0).equalTo(false).it(1).toBe(DatumError).like("The datum 'f' is not updatable."); | ||
expected(out).it(0).equalTo(false).it(1).toBe(DatumError).like("Datum 'f' is not updatable."); | ||
} | ||
@@ -45,0 +45,0 @@ }); |
{ | ||
"name": "@akromio/dataset", | ||
"version": "0.20.1", | ||
"version": "0.21.0", | ||
"description": "Dataset library for Akromio.", | ||
@@ -43,3 +43,3 @@ "author": { | ||
}, | ||
"gitHead": "376da3d8a15951b107fc0f1539bd6d71397f5664" | ||
"gitHead": "b4cd0518b4f20e5c2eeb31effd0ddd5c7a2e367f" | ||
} |
81647
2320