This repository has been archived by the owner on Feb 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfs.mjs
55 lines (47 loc) · 1.54 KB
/
fs.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* notion-enhancer: api
* (c) 2021 dragonwocky <[email protected]> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
'use strict';
/**
* environment-specific file reading
* @namespace fs
*/
import * as fs from '../env/fs.mjs';
/**
* get an absolute path to files within notion
* @param {string} path - relative to the root notion/resources/app/ e.g. renderer/search.js
* @process electron
*/
export const notionPath = fs.notionPath;
/**
* transform a path relative to the enhancer root directory into an absolute path
* @type {function}
* @param {string} path - a url or within-the-enhancer filepath
* @returns {string} an absolute filepath
*/
export const localPath = fs.localPath;
/**
* fetch and parse a json file's contents
* @type {function}
* @param {string} path - a url or within-the-enhancer filepath
* @param {FetchOptions=} opts - the second argument of a fetch() request
* @returns {unknown} the json value of the requested file as a js object
*/
export const getJSON = fs.getJSON;
/**
* fetch a text file's contents
* @type {function}
* @param {string} path - a url or within-the-enhancer filepath
* @param {FetchOptions=} opts - the second argument of a fetch() request
* @returns {string} the text content of the requested file
*/
export const getText = fs.getText;
/**
* check if a file exists
* @type {function}
* @param {string} path - a url or within-the-enhancer filepath
* @returns {boolean} whether or not the file exists
*/
export const isFile = fs.isFile;