diff --git a/api/README.md b/api/README.md index fb94ea50df..3ce81385a5 100644 --- a/api/README.md +++ b/api/README.md @@ -1213,7 +1213,22 @@ Unlinks (removes) file at `path`. | options.signal | AbortSignal? | | true | | | callback | function(Error?) | | false | | -## [`watch(, options, callback)`](https://github.com/socketsupply/socket/blob/master/api/fs/index.js#L1262) +## [`writeFileSync(path, data, options)`](https://github.com/socketsupply/socket/blob/master/api/fs/index.js#L1265) + +External docs: https://nodejs.org/api/fs.html#fswritefilesyncfile-data-options +Writes data to a file synchronously. + +| Argument | Type | Default | Optional | Description | +| :--- | :--- | :---: | :---: | :--- | +| path | string \| Buffer \| URL \| number | | false | filename or file descriptor | +| data | string \| Buffer \| TypedArray \| DataView \| object | | false | | +| options | object? | | false | | +| options.encoding ? utf8 | string? | | true | | +| options.mode ? 0o666 | string? | | true | | +| options.flag ? w | string? | | true | | +| options.signal | AbortSignal? | | true | | + +## [`watch(, options, callback)`](https://github.com/socketsupply/socket/blob/master/api/fs/index.js#L1300) Watch for changes at `path` calling `callback` @@ -1594,7 +1609,7 @@ Watch for changes at `path` calling `callback` This is a `FunctionDeclaration` named `maybeMakeError` in `api/ipc.js`, it's exported but undocumented. -## [`emit(name, value, target, options)`](https://github.com/socketsupply/socket/blob/master/api/ipc.js#L1135) +## [`emit(name, value, target, options)`](https://github.com/socketsupply/socket/blob/master/api/ipc.js#L1141) Emit event to be dispatched on `window` object. @@ -1605,7 +1620,7 @@ Emit event to be dispatched on `window` object. | target | EventTarget | window | true | | | options | Object | | true | | -## [`send(command, value, options)`](https://github.com/socketsupply/socket/blob/master/api/ipc.js#L1194) +## [`send(command, value, options)`](https://github.com/socketsupply/socket/blob/master/api/ipc.js#L1200) Sends an async IPC command request with parameters. @@ -2003,12 +2018,12 @@ Converts this `Path` instance to a string. This is a `ClassDeclaration` named ``ProcessEnvironmentEvent` (extends `Event`)` in `api/process.js`, it's exported but undocumented. -## [env](https://github.com/socketsupply/socket/blob/master/api/process.js#L26) +## [env](https://github.com/socketsupply/socket/blob/master/api/process.js#L29) This is a `VariableDeclaration` named `env` in `api/process.js`, it's exported but undocumented. -## [`nextTick(callback)`](https://github.com/socketsupply/socket/blob/master/api/process.js#L170) +## [`nextTick(callback)`](https://github.com/socketsupply/socket/blob/master/api/process.js#L190) Adds callback to the 'nextTick' queue. @@ -2016,7 +2031,7 @@ Adds callback to the 'nextTick' queue. | :--- | :--- | :---: | :---: | :--- | | callback | Function | | false | | -## [`hrtime(time)`](https://github.com/socketsupply/socket/blob/master/api/process.js#L201) +## [`hrtime(time)`](https://github.com/socketsupply/socket/blob/master/api/process.js#L221) Computed high resolution time as a `BigInt`. @@ -2028,7 +2043,7 @@ Computed high resolution time as a `BigInt`. | :--- | :--- | :--- | | Not specified | bigint | | -## [`exit(code)`](https://github.com/socketsupply/socket/blob/master/api/process.js#L227) +## [`exit(code)`](https://github.com/socketsupply/socket/blob/master/api/process.js#L247) @@ -2036,7 +2051,7 @@ Computed high resolution time as a `BigInt`. | :--- | :--- | :---: | :---: | :--- | | code | number | 0 | true | The exit code. Default: 0. | -## [`memoryUsage()`](https://github.com/socketsupply/socket/blob/master/api/process.js#L239) +## [`memoryUsage()`](https://github.com/socketsupply/socket/blob/master/api/process.js#L259) Returns an object describing the memory usage of the Node.js process measured in bytes. diff --git a/api/index.d.ts b/api/index.d.ts index 77456b16c7..0b435b45a8 100644 --- a/api/index.d.ts +++ b/api/index.d.ts @@ -1687,6 +1687,11 @@ declare module "socket:path/well-known" { * @type {?string} */ export const LOG: string | null; + /** + * Well known path to the application's "tmp" folder. + * @type {?string} + */ + export const TMP: string | null; /** * Well known path to the application's "home" folder. * This may be the user's HOME directory or the application container sandbox. @@ -1705,6 +1710,7 @@ declare module "socket:path/well-known" { export { HOME }; export { DATA }; export { LOG }; + export { TMP }; } export default _default; } @@ -2769,9 +2775,10 @@ declare module "socket:path/win32" { import { HOME } from "socket:path/well-known"; import { DATA } from "socket:path/well-known"; import { LOG } from "socket:path/well-known"; + import { TMP } from "socket:path/well-known"; import * as exports from "socket:path/win32"; - export { mounts, posix, Path, DOWNLOADS, DOCUMENTS, RESOURCES, PICTURES, DESKTOP, VIDEOS, CONFIG, MUSIC, HOME, DATA, LOG }; + export { mounts, posix, Path, DOWNLOADS, DOCUMENTS, RESOURCES, PICTURES, DESKTOP, VIDEOS, CONFIG, MUSIC, HOME, DATA, LOG, TMP }; } declare module "socket:path/posix" { @@ -2863,9 +2870,10 @@ declare module "socket:path/posix" { import { HOME } from "socket:path/well-known"; import { DATA } from "socket:path/well-known"; import { LOG } from "socket:path/well-known"; + import { TMP } from "socket:path/well-known"; import * as exports from "socket:path/posix"; - export { mounts, win32, Path, DOWNLOADS, DOCUMENTS, RESOURCES, PICTURES, DESKTOP, VIDEOS, CONFIG, MUSIC, HOME, DATA, LOG }; + export { mounts, win32, Path, DOWNLOADS, DOCUMENTS, RESOURCES, PICTURES, DESKTOP, VIDEOS, CONFIG, MUSIC, HOME, DATA, LOG, TMP }; } declare module "socket:path/index" { @@ -2885,9 +2893,10 @@ declare module "socket:path/index" { import { HOME } from "socket:path/well-known"; import { DATA } from "socket:path/well-known"; import { LOG } from "socket:path/well-known"; + import { TMP } from "socket:path/well-known"; import * as exports from "socket:path/index"; - export { mounts, posix, win32, Path, DOWNLOADS, DOCUMENTS, RESOURCES, PICTURES, DESKTOP, VIDEOS, CONFIG, MUSIC, HOME, DATA, LOG }; + export { mounts, posix, win32, Path, DOWNLOADS, DOCUMENTS, RESOURCES, PICTURES, DESKTOP, VIDEOS, CONFIG, MUSIC, HOME, DATA, LOG, TMP }; } declare module "socket:path" { @@ -2921,7 +2930,8 @@ declare module "socket:path" { import { HOME } from "socket:path/index"; import { DATA } from "socket:path/index"; import { LOG } from "socket:path/index"; - export { Path, posix, win32, mounts, DOWNLOADS, DOCUMENTS, RESOURCES, PICTURES, DESKTOP, VIDEOS, CONFIG, MUSIC, HOME, DATA, LOG }; + import { TMP } from "socket:path/index"; + export { Path, posix, win32, mounts, DOWNLOADS, DOCUMENTS, RESOURCES, PICTURES, DESKTOP, VIDEOS, CONFIG, MUSIC, HOME, DATA, LOG, TMP }; } declare module "socket:fs/stream" { @@ -4462,6 +4472,18 @@ declare module "socket:fs/index" { * @param {function(Error?)} callback */ export function writeFile(path: string | Buffer | URL | number, data: string | Buffer | TypedArray | DataView | object, options: object | null, callback: (arg0: Error | null) => any): void; + /** + * Writes data to a file synchronously. + * @param {string | Buffer | URL | number } path - filename or file descriptor + * @param {string | Buffer | TypedArray | DataView | object } data + * @param {object?} options + * @param {string?} [options.encoding ? 'utf8'] + * @param {string?} [options.mode ? 0o666] + * @param {string?} [options.flag ? 'w'] + * @param {AbortSignal?} [options.signal] + * @see {@link https://nodejs.org/api/fs.html#fswritefilesyncfile-data-options} + */ + export function writeFileSync(path: string | Buffer | URL | number, data: string | Buffer | TypedArray | DataView | object, options: object | null): void; /** * Watch for changes at `path` calling `callback` * @param {string} @@ -4620,7 +4642,7 @@ declare module "socket:ipc" { * @return {Result} * @ignore */ - export function sendSync(command: string, value?: any | null, options?: object | null): Result; + export function sendSync(command: string, value?: any | null, options?: object | null, buffer: any): Result; /** * Emit event to be dispatched on `window` object. * @param {string} name