@lppedd/kotlinx-charset 0.2.1 → 0.3.0

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.
@@ -25,8 +25,14 @@ export declare interface XCharsetEncoder {
25
25
  readonly "com.lppedd.kotlinx.charset.exported.XCharsetEncoder": unique symbol;
26
26
  };
27
27
  }
28
+ export declare interface DecodeOptions {
29
+ readonly replacement?: Nullable<string>;
30
+ }
31
+ export declare interface EncodeOptions {
32
+ readonly replacement?: Nullable<Uint8Array>;
33
+ }
28
34
  export declare function getCharsetOrNull(charsetName: string): Nullable<XCharset>;
29
35
  export declare function getCharset(charsetName: string): XCharset;
30
36
  export declare function getCharsets(): Array<XCharset>;
31
- export declare function decode(charsetName: string, bytes: Uint8Array): string;
32
- export declare function encode(charsetName: string, value: string): Uint8Array;
37
+ export declare function decode(charsetName: string, bytes: Uint8Array, options?: Nullable<DecodeOptions>): string;
38
+ export declare function encode(charsetName: string, value: string, options?: Nullable<EncodeOptions>): Uint8Array;
@@ -6890,15 +6890,24 @@ function getCharsets() {
6890
6890
  }
6891
6891
  return tmp_1;
6892
6892
  }
6893
- function decode(charsetName, bytes) {
6893
+ function decode(charsetName, bytes, options) {
6894
+ options = options === VOID ? null : options;
6894
6895
  var charset = registrar.ib(charsetName);
6895
6896
  var decoder = charset.yb();
6897
+ if (!(options == null) && isNotUndefined(options, 'replacement')) {
6898
+ decoder.zf(options.replacement);
6899
+ }
6896
6900
  var byteArray = toByteArray(bytes);
6897
6901
  return decoder.xf(byteArray);
6898
6902
  }
6899
- function encode_0(charsetName, value) {
6903
+ function encode_0(charsetName, value, options) {
6904
+ options = options === VOID ? null : options;
6900
6905
  var charset = registrar.ib(charsetName);
6901
6906
  var encoder = charset.zb();
6907
+ if (!(options == null) && isNotUndefined(options, 'replacement')) {
6908
+ var tmp0_safe_receiver = options.replacement;
6909
+ encoder.fg(tmp0_safe_receiver == null ? null : toByteArray(tmp0_safe_receiver));
6910
+ }
6902
6911
  var byteArray = encoder.eg(value);
6903
6912
  return toUint8Array(byteArray);
6904
6913
  }
@@ -6907,6 +6916,9 @@ function initCharsetRegistrar() {
6907
6916
  provideCharsets(registrar);
6908
6917
  return registrar;
6909
6918
  }
6919
+ function isNotUndefined(value, prop) {
6920
+ return typeof value[prop] !== 'undefined';
6921
+ }
6910
6922
  //region block: post-declaration
6911
6923
  initMetadataForInterface(CharSequence, 'CharSequence');
6912
6924
  initMetadataForInterface(Comparable, 'Comparable');