Skip to content

Commit

Permalink
Support Deno2
Browse files Browse the repository at this point in the history
  • Loading branch information
masataka committed Oct 18, 2024
1 parent 3a2c82f commit d215ffa
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"type": "node",
"request": "launch",
"name": "Test Deno",
"cwd": "${workspaceFolder}",
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"deno.enable": true,
"deno.unstable": true,
"deno.lint": true,
"files.trimTrailingWhitespace": true
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2020 Masataka Kurihara
Copyright (c) 2020, 2024 Masataka Kurihara

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 2 additions & 4 deletions dev_deps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Copyright 2020 Masataka Kurihara. All rights reserved. MIT license.
// Copyright 2020, 2024 Masataka Kurihara. All rights reserved. MIT license.

export { assert } from 'https://deno.land/std@0.204.0/assert/assert.ts'
export { assertEquals } from 'https://deno.land/std@0.204.0/assert/assert_equals.ts'
export { assertThrows } from 'https://deno.land/std@0.204.0/assert/assert_throws.ts';
export { assert, assertEquals, assertThrows } from 'jsr:@std/assert';
23 changes: 1 addition & 22 deletions parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Masataka Kurihara. All rights reserved. MIT license.
// Copyright 2020, 2024 Masataka Kurihara. All rights reserved. MIT license.

import {
XMLParseHandler,
Expand Down Expand Up @@ -215,27 +215,6 @@ export class SAXParser extends ParserBase implements UnderlyingSink<Uint8Array>
}
}

/**
* Convenient function.
*/
getStream(): WritableStream<Uint8Array> {
return new WritableStream<Uint8Array>(this);
}

/**
* Convenient function. {@code SAXParser#getStream} is used internally.
*/
getWriter(): Deno.Writer {
const streamWriter = this.getStream().getWriter();
return {
async write(p: Uint8Array): Promise<number> {
await streamWriter.ready;
await streamWriter.write(p);
return p.length;
}
};
}

/**
* Execute XML pull parsing.
* @param source Target XML.
Expand Down
10 changes: 5 additions & 5 deletions parser_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Masataka Kurihara. All rights reserved. MIT license.
// Copyright 2020, 2024 Masataka Kurihara. All rights reserved. MIT license.

import {
assert,
Expand All @@ -23,15 +23,15 @@ import {
Deno.test('ParserBase chunk & hasNext & readNext & position', () => {
// protected -> public visiblity
class TestParser extends ParserBase {
set chunk(chunk: string) {
override set chunk(chunk: string) {
super.chunk = chunk;
}

readNext(): string {
override readNext(): string {
return super.readNext();
}

hasNext(): boolean {
override hasNext(): boolean {
return super.hasNext();
}
}
Expand Down Expand Up @@ -108,7 +108,7 @@ Deno.test('SAXParser self-closing end_document', () => {

Deno.test('marshallEvent', () => {
class TestParser extends PullParser {
marshallEvent(event: XMLParseEvent): PullResult {
override marshallEvent(event: XMLParseEvent): PullResult {
return super.marshallEvent(event);
}
}
Expand Down

0 comments on commit d215ffa

Please sign in to comment.