null.js 541 B

123456789101112131415161718192021222324
  1. import { Coder } from "./abstract-coder.js";
  2. const Empty = new Uint8Array([]);
  3. /**
  4. * @_ignore
  5. */
  6. export class NullCoder extends Coder {
  7. constructor(localName) {
  8. super("null", "", localName, false);
  9. }
  10. defaultValue() {
  11. return null;
  12. }
  13. encode(writer, value) {
  14. if (value != null) {
  15. this._throwError("not null", value);
  16. }
  17. return writer.writeBytes(Empty);
  18. }
  19. decode(reader) {
  20. reader.readBytes(0);
  21. return null;
  22. }
  23. }
  24. //# sourceMappingURL=null.js.map