hyoo_sync_client 0.0.352 → 0.0.353

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/node.mjs CHANGED
@@ -996,28 +996,11 @@ var $;
996
996
  var $;
997
997
  (function ($) {
998
998
  class $mol_error_mix extends AggregateError {
999
- name = $$.$mol_func_name(this.constructor);
1000
- constructor(message, ...errors) {
1001
- super(errors, [message, ...errors.map(e => e.message.replace(/^/gm, ' '))].join('\n'));
1002
- }
1003
- get cause() {
1004
- return [].concat(...this.errors.map(e => e.cause).filter(Boolean));
1005
- }
1006
- toJSON() {
1007
- return this.errors.map(e => e.message);
1008
- }
1009
- pick(Class) {
1010
- if (this instanceof Class)
1011
- return this;
1012
- for (const e of this.errors) {
1013
- if (e instanceof Class)
1014
- return e;
1015
- }
1016
- for (const e of this.cause) {
1017
- if (e && e instanceof Class)
1018
- return e;
1019
- }
1020
- return null;
999
+ cause;
1000
+ name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
1001
+ constructor(message, cause, ...errors) {
1002
+ super(errors, message, { cause });
1003
+ this.cause = cause;
1021
1004
  }
1022
1005
  }
1023
1006
  $.$mol_error_mix = $mol_error_mix;
@@ -1028,7 +1011,6 @@ var $;
1028
1011
  var $;
1029
1012
  (function ($) {
1030
1013
  class $mol_data_error extends $mol_error_mix {
1031
- name = '$mol_data_error';
1032
1014
  }
1033
1015
  $.$mol_data_error = $mol_data_error;
1034
1016
  })($ || ($ = {}));
package/node.test.js CHANGED
@@ -987,28 +987,11 @@ var $;
987
987
  var $;
988
988
  (function ($) {
989
989
  class $mol_error_mix extends AggregateError {
990
- name = $$.$mol_func_name(this.constructor);
991
- constructor(message, ...errors) {
992
- super(errors, [message, ...errors.map(e => e.message.replace(/^/gm, ' '))].join('\n'));
993
- }
994
- get cause() {
995
- return [].concat(...this.errors.map(e => e.cause).filter(Boolean));
996
- }
997
- toJSON() {
998
- return this.errors.map(e => e.message);
999
- }
1000
- pick(Class) {
1001
- if (this instanceof Class)
1002
- return this;
1003
- for (const e of this.errors) {
1004
- if (e instanceof Class)
1005
- return e;
1006
- }
1007
- for (const e of this.cause) {
1008
- if (e && e instanceof Class)
1009
- return e;
1010
- }
1011
- return null;
990
+ cause;
991
+ name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
992
+ constructor(message, cause, ...errors) {
993
+ super(errors, message, { cause });
994
+ this.cause = cause;
1012
995
  }
1013
996
  }
1014
997
  $.$mol_error_mix = $mol_error_mix;
@@ -1019,7 +1002,6 @@ var $;
1019
1002
  var $;
1020
1003
  (function ($) {
1021
1004
  class $mol_data_error extends $mol_error_mix {
1022
- name = '$mol_data_error';
1023
1005
  }
1024
1006
  $.$mol_data_error = $mol_data_error;
1025
1007
  })($ || ($ = {}));
@@ -5664,39 +5646,29 @@ var $;
5664
5646
  (function ($) {
5665
5647
  $mol_test({
5666
5648
  'auto name'() {
5667
- class TestError extends $mol_error_mix {
5649
+ class Invalid extends $mol_error_mix {
5668
5650
  }
5669
- const mix = new TestError('foo');
5670
- $mol_assert_equal(mix.name, 'TestError');
5651
+ const mix = new Invalid('foo');
5652
+ $mol_assert_equal(mix.name, 'Invalid_Error');
5671
5653
  },
5672
- 'empty mix'() {
5673
- const mix = new $mol_error_mix('foo');
5654
+ 'simpe mix'() {
5655
+ const mix = new $mol_error_mix('foo', null, new Error('bar'), new Error('lol'));
5674
5656
  $mol_assert_equal(mix.message, 'foo');
5675
- $mol_assert_equal(mix.cause, []);
5657
+ $mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
5676
5658
  },
5677
- 'simpe mix'() {
5678
- const mix = new $mol_error_mix('foo', new Error('bar', { cause: 'xxx' }), new Error('lol', { cause: 'yyy' }));
5679
- $mol_assert_equal(mix.message, 'foo\n bar\n lol');
5680
- $mol_assert_equal(mix.cause, ['xxx', 'yyy']);
5681
- },
5682
- 'mix of mixes'() {
5683
- const mix = new $mol_error_mix('mix', new $mol_error_mix('foo1', new Error('bar1', { cause: 'xxx1' }), new Error('lol1', { cause: 'yyy1' })), new $mol_error_mix('foo2', new Error('bar2', { cause: 'xxx2' }), new Error('lol2', { cause: 'yyy2' })));
5684
- $mol_assert_equal(mix.message, 'mix\n foo1\n bar1\n lol1\n foo2\n bar2\n lol2');
5685
- $mol_assert_equal(mix.cause, ['xxx1', 'yyy1', 'xxx2', 'yyy2']);
5686
- },
5687
- 'pick by class'() {
5688
- const mix = new $mol_error_mix('foo', new RangeError('bar', {
5689
- cause: [
5690
- new SyntaxError('xxx1'),
5691
- new SyntaxError('xxx2'),
5692
- new TypeError('lol0'),
5693
- ],
5694
- }), new TypeError('lol1', {
5695
- cause: new TypeError('xxx3'),
5696
- }), new TypeError('lol2'));
5697
- $mol_assert_equal(mix.pick(RangeError).message, 'bar');
5698
- $mol_assert_equal(mix.pick(SyntaxError).message, 'xxx1');
5699
- $mol_assert_equal(mix.pick(TypeError).message, 'lol1');
5659
+ 'provide additional info'() {
5660
+ class Invalid extends $mol_error_mix {
5661
+ }
5662
+ const mix = new $mol_error_mix('Wrong password', null, new Invalid('Too short', { value: 'p@ssw0rd', hint: '> 8 letters' }), new Invalid('Too simple', { value: 'p@ssw0rd', hint: 'need capital letter' }));
5663
+ const hints = [];
5664
+ if (mix instanceof $mol_error_mix) {
5665
+ for (const er of mix.errors) {
5666
+ if (er instanceof Invalid) {
5667
+ hints.push(er.cause?.hint ?? '');
5668
+ }
5669
+ }
5670
+ }
5671
+ $mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
5700
5672
  },
5701
5673
  });
5702
5674
  })($ || ($ = {}));