Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: file/file.ts -- ergonomics for interacting with files #195

Closed
lucascaro opened this issue Feb 16, 2019 · 1 comment
Closed

Idea: file/file.ts -- ergonomics for interacting with files #195

lucascaro opened this issue Feb 16, 2019 · 1 comment

Comments

@lucascaro
Copy link
Contributor

Extending the core with more ergonomic file functions:

example:

export function fileExists(filename: string): boolean {
  return readDirSync(".").filter((f) => f.name === filename).length > 0;
}

export function writeStringSync(filename: string, data: string) {
  const encoder = new TextEncoder();
  writeFileSync(filename, encoder.encode(data));
}

export function readStringSync(filename: string, encoding: string) {
  const decoder = new TextDecoder(encoding);
  return decoder.decode(readFileSync(filename));
}

etc.

If this seems useful and in line with deno_std then I can propose a more complete API.

@lucascaro lucascaro changed the title Idea: file.ts -- ergonomics for interacting with files Idea: file/file.ts -- ergonomics for interacting with files Feb 16, 2019
@dsseng
Copy link
Contributor

dsseng commented Sep 22, 2019

String functions seem good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants