fp-ts-node
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
*/ | ||
import { readerTaskEither as RTE } from "fp-ts"; | ||
import { option as O, readerTaskEither as RTE } from "fp-ts"; | ||
import * as fs from "fs"; | ||
@@ -66,1 +66,35 @@ /** | ||
export declare const close: PathTaskEither<number, void>; | ||
/** | ||
* Asynchronously copies src to dest. By default, dest is overwritten if it already exists. | ||
* No arguments other than a possible exception are given to the callback function. | ||
* Node.js makes no guarantees about the atomicity of the copy operation. | ||
* If an error occurs after the destination file has been opened for writing, Node.js will attempt | ||
* to remove the destination. | ||
* @param src A path to the source file. | ||
* @param dest A path to the destination file. | ||
* @param flags An integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists. | ||
* | ||
* Specifying `src` or `dest` as the property will cause the | ||
* `path` dependency in the Reader to be `dest` or `src` respectively. | ||
* | ||
* @category Constructors | ||
* @since 2.2.0 | ||
*/ | ||
export declare function copyFile(path_1: { | ||
src: fs.PathLike; | ||
} | { | ||
dest: fs.PathLike; | ||
}, flags: number): PathTaskEither<fs.PathLike, void>; | ||
/** | ||
* Asynchronous mkdir(2) - create a directory. | ||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. | ||
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders | ||
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. | ||
* | ||
* If `options.recursive == true`, the return value will be `Some<string>`, | ||
* where the first created folder will be returned. | ||
* | ||
* @category Constructors | ||
* @since 2.2.0 | ||
*/ | ||
export declare function mkdir(options?: fs.Mode | fs.MakeDirectoryOptions): PathTaskEither<fs.PathLike, O.Option<string>>; |
@@ -22,3 +22,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.close = exports.chown = exports.chmod = exports.appendFile = exports.access = void 0; | ||
exports.mkdir = exports.copyFile = exports.close = exports.chown = exports.chmod = exports.appendFile = exports.access = void 0; | ||
/** | ||
@@ -28,2 +28,3 @@ * @since 2.0.0 | ||
var fp_ts_1 = require("fp-ts"); | ||
var function_1 = require("fp-ts/lib/function"); | ||
var fs = __importStar(require("fs")); | ||
@@ -103,1 +104,41 @@ /** | ||
exports.close = fp_ts_1.taskEither.taskify(fs.close); | ||
/** | ||
* Asynchronously copies src to dest. By default, dest is overwritten if it already exists. | ||
* No arguments other than a possible exception are given to the callback function. | ||
* Node.js makes no guarantees about the atomicity of the copy operation. | ||
* If an error occurs after the destination file has been opened for writing, Node.js will attempt | ||
* to remove the destination. | ||
* @param src A path to the source file. | ||
* @param dest A path to the destination file. | ||
* @param flags An integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists. | ||
* | ||
* Specifying `src` or `dest` as the property will cause the | ||
* `path` dependency in the Reader to be `dest` or `src` respectively. | ||
* | ||
* @category Constructors | ||
* @since 2.2.0 | ||
*/ | ||
function copyFile(path_1, flags) { | ||
return function (path_2) { | ||
return fp_ts_1.taskEither.taskify(fs.copyFile)("src" in path_1 ? path_1.src : path_2, "dest" in path_1 ? path_1.dest : path_2, flags); | ||
}; | ||
} | ||
exports.copyFile = copyFile; | ||
/** | ||
* Asynchronous mkdir(2) - create a directory. | ||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. | ||
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders | ||
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. | ||
* | ||
* If `options.recursive == true`, the return value will be `Some<string>`, | ||
* where the first created folder will be returned. | ||
* | ||
* @category Constructors | ||
* @since 2.2.0 | ||
*/ | ||
function mkdir(options) { | ||
return function (path) { | ||
return (0, function_1.pipe)(fp_ts_1.taskEither.taskify(fs.mkdir)(path, options), fp_ts_1.taskEither.map(fp_ts_1.option.fromNullable)); | ||
}; | ||
} | ||
exports.mkdir = mkdir; |
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
*/ | ||
import { readerTaskEither as RTE } from "fp-ts"; | ||
import { option as O, readerTaskEither as RTE } from "fp-ts"; | ||
import * as fs from "fs"; | ||
@@ -66,1 +66,35 @@ /** | ||
export declare const close: PathTaskEither<number, void>; | ||
/** | ||
* Asynchronously copies src to dest. By default, dest is overwritten if it already exists. | ||
* No arguments other than a possible exception are given to the callback function. | ||
* Node.js makes no guarantees about the atomicity of the copy operation. | ||
* If an error occurs after the destination file has been opened for writing, Node.js will attempt | ||
* to remove the destination. | ||
* @param src A path to the source file. | ||
* @param dest A path to the destination file. | ||
* @param flags An integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists. | ||
* | ||
* Specifying `src` or `dest` as the property will cause the | ||
* `path` dependency in the Reader to be `dest` or `src` respectively. | ||
* | ||
* @category Constructors | ||
* @since 2.2.0 | ||
*/ | ||
export declare function copyFile(path_1: { | ||
src: fs.PathLike; | ||
} | { | ||
dest: fs.PathLike; | ||
}, flags: number): PathTaskEither<fs.PathLike, void>; | ||
/** | ||
* Asynchronous mkdir(2) - create a directory. | ||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. | ||
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders | ||
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. | ||
* | ||
* If `options.recursive == true`, the return value will be `Some<string>`, | ||
* where the first created folder will be returned. | ||
* | ||
* @category Constructors | ||
* @since 2.2.0 | ||
*/ | ||
export declare function mkdir(options?: fs.Mode | fs.MakeDirectoryOptions): PathTaskEither<fs.PathLike, O.Option<string>>; |
/** | ||
* @since 2.0.0 | ||
*/ | ||
import { taskEither as TE } from "fp-ts"; | ||
import { option as O, taskEither as TE } from "fp-ts"; | ||
import { pipe } from "fp-ts/lib/function"; | ||
import * as fs from "fs"; | ||
@@ -64,1 +65,35 @@ /** | ||
export const close = TE.taskify(fs.close); | ||
/** | ||
* Asynchronously copies src to dest. By default, dest is overwritten if it already exists. | ||
* No arguments other than a possible exception are given to the callback function. | ||
* Node.js makes no guarantees about the atomicity of the copy operation. | ||
* If an error occurs after the destination file has been opened for writing, Node.js will attempt | ||
* to remove the destination. | ||
* @param src A path to the source file. | ||
* @param dest A path to the destination file. | ||
* @param flags An integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists. | ||
* | ||
* Specifying `src` or `dest` as the property will cause the | ||
* `path` dependency in the Reader to be `dest` or `src` respectively. | ||
* | ||
* @category Constructors | ||
* @since 2.2.0 | ||
*/ | ||
export function copyFile(path_1, flags) { | ||
return (path_2) => TE.taskify(fs.copyFile)("src" in path_1 ? path_1.src : path_2, "dest" in path_1 ? path_1.dest : path_2, flags); | ||
} | ||
/** | ||
* Asynchronous mkdir(2) - create a directory. | ||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. | ||
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders | ||
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. | ||
* | ||
* If `options.recursive == true`, the return value will be `Some<string>`, | ||
* where the first created folder will be returned. | ||
* | ||
* @category Constructors | ||
* @since 2.2.0 | ||
*/ | ||
export function mkdir(options) { | ||
return (path) => pipe(TE.taskify(fs.mkdir)(path, options), TE.map(O.fromNullable)); | ||
} |
{ | ||
"name": "fp-ts-node", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"files": [ | ||
@@ -22,3 +22,3 @@ "dist" | ||
"build:es6": "tsc -p tsconfig.es6.json", | ||
"prepublish": "yarn build" | ||
"prepublishOnly": "yarn build" | ||
}, | ||
@@ -25,0 +25,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35583
657