-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switched repos from the old depracated repo: https://github.com/johnsonjo4531/read_lines
- Loading branch information
0 parents
commit cfc0e04
Showing
15 changed files
with
4,698 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
# Matches multiple files with brace expansion notation | ||
# Set default charset | ||
[*.{js,html,css,json,md,vue,scss,ejs,ts,tsx,jsx,graphql}] | ||
charset = utf-8 | ||
indent_style = tab | ||
indent_size = 2 | ||
|
||
[makefile] | ||
indent_style = tab | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
mobydick.txt | ||
test.txt | ||
example.txt | ||
index.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Deno", | ||
"request": "attach", | ||
"type": "pwa-node", | ||
"cwd": "${workspaceFolder}", | ||
"attachSimplePort": 9229 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"deno.import_intellisense_origins": { | ||
"https://deno.land": true | ||
}, | ||
"deno.enable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2019 johnsonjo4531 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(async () => { | ||
const encoder = new TextEncoder(); | ||
const bytes = encoder.encode("a".repeat(10 ** 6)); | ||
for (var i = 0; i < 1000; ++i) { | ||
await Deno.stdout.write(bytes); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const { test } = Deno; | ||
export { | ||
assertEquals, | ||
assertThrowsAsync, | ||
} from "https://deno.land/[email protected]/testing/asserts.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { readDelim, readLines } from "https://deno.land/[email protected]/io/bufio.ts"; | ||
|
||
async function* linesBuffer( | ||
reader: Deno.Reader, | ||
): AsyncIterableIterator<Uint8Array> { yield* readDelim(reader, new TextEncoder().encode('\n')) }; | ||
|
||
async function cat(filenames: string[]): Promise<void> { | ||
const newlinebytes = new TextEncoder().encode("\n"); | ||
for (let filename of filenames) { | ||
const file = await Deno.open(filename); | ||
const buffer = new Deno.Buffer(); | ||
try { | ||
const file_lines: Uint8Array[] = []; | ||
for await (const line of linesBuffer(file)) { | ||
// you could transform the line buffers here | ||
buffer.write(line); | ||
buffer.write(newlinebytes); | ||
} | ||
Deno.copy(buffer, Deno.stdout); | ||
} finally { | ||
file.close(); | ||
} | ||
} | ||
} | ||
cat(Deno.args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { input } from "../input.ts"; | ||
|
||
(async () => { | ||
console.log("-- DENO ADDER --"); | ||
const num1 = await input("Enter a number: "); | ||
const num2 = await input("Enter another number: "); | ||
console.log(`${num1} + ${num2} = ${Number(num1) + Number(num2)}`); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { inputReader } from "../input.ts"; | ||
|
||
async function cat(filenames: string[]): Promise<void> { | ||
const newlinebytes = new TextEncoder().encode("\n"); | ||
for (let filename of filenames) { | ||
const file = await Deno.open(filename); | ||
const input = inputReader(file, undefined, { | ||
nullOnEOF: true, | ||
// these are for added speed... at expense of convenience | ||
bufferedRead: true, | ||
bufferedWrite: true | ||
}); | ||
const newLine = new TextEncoder().encode("\n") | ||
// const decoder = new TextDecoder(); | ||
try { | ||
let line = await input(); | ||
while (line !== null) { | ||
line = await input(line, newLine); | ||
} | ||
} finally { | ||
file.close(); | ||
} | ||
} | ||
} | ||
await cat( | ||
Deno.args | ||
); |
Oops, something went wrong.