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

Path API #94

Closed
dsherret opened this issue Jan 15, 2023 · 0 comments · Fixed by #97
Closed

Path API #94

dsherret opened this issue Jan 15, 2023 · 0 comments · Fixed by #97
Labels
enhancement New feature or request

Comments

@dsherret
Copy link
Owner

dsherret commented Jan 15, 2023

It would be nice if instead of writing stuff like this:

try {
  return JSON.parse(Deno.readTextFileSync(this.#filePath)) as { ip: string };
} catch (err) {
  if (err instanceof Deno.errors.NotFound) {
    return undefined;
  } else {
    throw err;
  }
}

...if I could instead do:

const maybeData = $.path(this.#filePath).maybeJsonSync<{ name: string }>();
const data = $.path(this.#filePath).jsonSync<{ name: string }>();

I will work on this probably this week.

@dsherret dsherret added the enhancement New feature or request label Jan 15, 2023
@dsherret dsherret changed the title File system API Path API Jan 23, 2023
@dsherret dsherret mentioned this issue Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant