@dan-uni/dan-any 0.2.3 → 0.2.4

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/dist/index.js CHANGED
@@ -5803,7 +5803,7 @@ class UniPool {
5803
5803
  minify() {
5804
5804
  return this.dans.map((d)=>d.minify());
5805
5805
  }
5806
- convert2(format) {
5806
+ convert2(format, continue_on_error = false) {
5807
5807
  switch(format){
5808
5808
  case 'danuni.json':
5809
5809
  return JSON.stringify(this.dans);
@@ -5818,7 +5818,11 @@ class UniPool {
5818
5818
  case 'common.ass':
5819
5819
  return this.toASS();
5820
5820
  default:
5821
- throw new Error('unknown format or unsupported now!');
5821
+ {
5822
+ const message = 'unknown format or unsupported now!';
5823
+ if (continue_on_error) return message;
5824
+ throw new Error(message);
5825
+ }
5822
5826
  }
5823
5827
  }
5824
5828
  static fromPb(bin) {
@@ -19796,7 +19796,7 @@
19796
19796
  minify() {
19797
19797
  return this.dans.map((d)=>d.minify());
19798
19798
  }
19799
- convert2(format) {
19799
+ convert2(format, continue_on_error = false) {
19800
19800
  switch(format){
19801
19801
  case 'danuni.json':
19802
19802
  return JSON.stringify(this.dans);
@@ -19811,7 +19811,11 @@
19811
19811
  case 'common.ass':
19812
19812
  return this.toASS();
19813
19813
  default:
19814
- throw new Error('unknown format or unsupported now!');
19814
+ {
19815
+ const message = 'unknown format or unsupported now!';
19816
+ if (continue_on_error) return message;
19817
+ throw new Error(message);
19818
+ }
19815
19819
  }
19816
19820
  }
19817
19821
  static fromPb(bin) {
@@ -63,7 +63,7 @@ export declare class UniPool {
63
63
  */
64
64
  merge(lifetime?: number): UniPool;
65
65
  minify(): (Partial<UniDMTools.UniDMObj> & Pick<UniDMTools.UniDMObj, "FCID">)[];
66
- convert2(format: DM_format): string | Uint8Array<ArrayBufferLike> | DM_JSON_Dplayer | DM_JSON_DDPlay | DM_JSON_Artplayer[];
66
+ convert2(format: DM_format, continue_on_error?: boolean): string | Uint8Array<ArrayBufferLike> | DM_JSON_Dplayer | DM_JSON_DDPlay | DM_JSON_Artplayer[];
67
67
  static fromPb(bin: Uint8Array | ArrayBuffer): UniPool;
68
68
  /**
69
69
  * 转为 protobuf 二进制
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dan-uni/dan-any",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "A danmaku transformer lib, supporting danmaku from different platforms.",
5
5
  "keywords": [
6
6
  "bangumi",
package/src/index.ts CHANGED
@@ -219,7 +219,7 @@ export class UniPool {
219
219
  minify() {
220
220
  return this.dans.map((d) => d.minify())
221
221
  }
222
- convert2(format: DM_format) {
222
+ convert2(format: DM_format, continue_on_error = false) {
223
223
  switch (format) {
224
224
  case 'danuni.json':
225
225
  return JSON.stringify(this.dans)
@@ -239,8 +239,11 @@ export class UniPool {
239
239
  return this.toDDplay()
240
240
  case 'common.ass':
241
241
  return this.toASS()
242
- default:
243
- throw new Error('unknown format or unsupported now!')
242
+ default: {
243
+ const message = 'unknown format or unsupported now!'
244
+ if (continue_on_error) return message
245
+ else throw new Error(message)
246
+ }
244
247
  }
245
248
  }
246
249
  static fromPb(bin: Uint8Array | ArrayBuffer) {