├── .github ├── ISSUE_TEMPLATE │ ├── Bug_report.md │ ├── Documentation.md │ └── Feature_request.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .prettierrc ├── .travis.yml ├── .vscode └── settings.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── docs ├── _config.yml ├── index.md └── modules │ ├── fs.ts.md │ ├── index.md │ └── index.ts.md ├── dtslint ├── index.d.ts └── ts3.9 │ ├── index.d.ts │ ├── index.ts │ ├── tsconfig.json │ └── tslint.json ├── fp-ts-node-0.0.1.tgz ├── jest.config.js ├── package-lock.json ├── package.json ├── src ├── fs.ts └── index.ts ├── test └── index.ts ├── tsconfig.build-es6.json ├── tsconfig.build-lib.json ├── tsconfig.json └── tslint.json /.github/ISSUE_TEMPLATE/Bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F41B Bug report" 3 | about: Create a report to help make fp-ts better 4 | --- 5 | 6 | ## 🐛 Bug report 7 | 8 | ### Current Behavior 9 | 10 | 11 | 12 | ### Expected behavior 13 | 14 | 15 | 16 | ### Reproducible example 17 | 18 | ### Suggested solution(s) 19 | 20 | 21 | 22 | ### Additional context 23 | 24 | 25 | 26 | ### Your environment 27 | 28 | Which versions of fp-ts are affected by this issue? Did this work in previous versions of fp-ts? 29 | 30 | 31 | 32 | | Software | Version(s) | 33 | | ---------- | ---------- | 34 | | fp-ts | | 35 | | TypeScript | | 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F41B Documentation" 3 | about: Improvements or suggestions of fp-ts documentation 4 | --- 5 | 6 | ## 📖 Documentation 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F680Feature request" 3 | about: Suggest an idea for fp-ts 4 | --- 5 | 6 | ## 🚀 Feature request 7 | 8 | ### Current Behavior 9 | 10 | 11 | 12 | ### Desired Behavior 13 | 14 | 15 | 16 | ### Suggested Solution 17 | 18 | 19 | 20 | 21 | 22 | ### Who does this impact? Who is this for? 23 | 24 | 25 | 26 | ### Describe alternatives you've considered 27 | 28 | 29 | 30 | ### Additional context 31 | 32 | 33 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Before submitting a pull request,** please make sure the following is done: 2 | 3 | - Fork [the repository](https://github.com/gcanti/) and create your branch from `master`. 4 | - Run `npm install` in the repository root. 5 | - If you've fixed a bug or added code that should be tested, add tests! 6 | - Ensure the test suite passes (`npm test`). 7 | 8 | **Note**. If you find a typo in the **documentation**, make sure to modify the corresponding source (docs are generated). 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | node_modules 3 | dist 4 | dev 5 | coverage 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "printWidth": 120, 5 | "trailingComma": "none" 6 | } 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '12' 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "./node_modules/typescript/lib" 3 | } 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | > **Tags:** 4 | > - [New Feature] 5 | > - [Bug Fix] 6 | > - [Breaking Change] 7 | > - [Documentation] 8 | > - [Internal] 9 | > - [Polish] 10 | > - [Experimental] 11 | 12 | **Note**: Gaps between patch versions are faulty/broken releases. 13 | **Note**: A feature tagged as Experimental is in a high state of flux, you're at risk of it changing without notice. 14 | 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020-present Giulio Canti 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcanti/fp-ts-node/3a380b9e9803e64ee1525ce95b973e30d194d745/README.md -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | remote_theme: pmarsceill/just-the-docs 2 | 3 | # Enable or disable the site search 4 | search_enabled: true 5 | 6 | # Aux links for the upper right navigation 7 | aux_links: 8 | 'boilerplate on GitHub': 9 | - 'https://github.com/gcanti/boilerplate' 10 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Home 3 | nav_order: 1 4 | --- 5 | -------------------------------------------------------------------------------- /docs/modules/fs.ts.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: fs.ts 3 | nav_order: 1 4 | parent: Modules 5 | --- 6 | 7 | ## fs overview 8 | 9 | Added in v0.0.1 10 | 11 | --- 12 | 13 |

Table of contents

14 | 15 | - [utils](#utils) 16 | - [copy](#copy) 17 | - [exists](#exists) 18 | - [move](#move) 19 | - [readFile](#readfile) 20 | - [remove](#remove) 21 | - [writeFile](#writefile) 22 | 23 | --- 24 | 25 | # utils 26 | 27 | ## copy 28 | 29 | Copy a file or directory. The directory can have contents. Will overwrite existing file or directory. 30 | 31 | **Signature** 32 | 33 | ```ts 34 | export declare const copy: (src: string, dest: string) => TE.TaskEither 35 | ``` 36 | 37 | Added in v0.0.1 38 | 39 | ## exists 40 | 41 | Test whether or not the given path exists by checking with the file system. 42 | 43 | **Signature** 44 | 45 | ```ts 46 | export declare const exists: (path: string) => TE.TaskEither 47 | ``` 48 | 49 | Added in v0.0.1 50 | 51 | ## move 52 | 53 | Moves a file or directory, even across devices. By default it won't overwrite existing file or directory. 54 | 55 | **Signature** 56 | 57 | ```ts 58 | export declare const move: (src: string, dest: string, options: fs.MoveOptions) => TE.TaskEither 59 | ``` 60 | 61 | Added in v0.0.1 62 | 63 | ## readFile 64 | 65 | Reads a file. 66 | 67 | **Signature** 68 | 69 | ```ts 70 | export declare const readFile: (path: string, encoding: string) => TE.TaskEither 71 | ``` 72 | 73 | Added in v0.0.1 74 | 75 | ## remove 76 | 77 | Removes a file or directory. The directory can have contents. If the path does not exist, silently does nothing. 78 | 79 | **Signature** 80 | 81 | ```ts 82 | export declare const remove: (path: string) => TE.TaskEither 83 | ``` 84 | 85 | Added in v0.0.1 86 | 87 | ## writeFile 88 | 89 | Almost the same as `writeFile` (i.e. it overwrites), except that if the parent directory does not exist, it's created. 90 | 91 | **Signature** 92 | 93 | ```ts 94 | export declare const writeFile: (path: string, data: string, options: fs.WriteFileOptions) => TE.TaskEither 95 | ``` 96 | 97 | Added in v0.0.1 98 | -------------------------------------------------------------------------------- /docs/modules/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Modules 3 | has_children: true 4 | permalink: /docs/modules 5 | nav_order: 2 6 | --- 7 | -------------------------------------------------------------------------------- /docs/modules/index.ts.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: index.ts 3 | nav_order: 2 4 | parent: Modules 5 | --- 6 | 7 | ## index overview 8 | 9 | Added in v0.0.1 10 | 11 | --- 12 | 13 |

Table of contents

14 | 15 | - [utils](#utils) 16 | - [fs](#fs) 17 | 18 | --- 19 | 20 | # utils 21 | 22 | ## fs 23 | 24 | **Signature** 25 | 26 | ```ts 27 | export declare const fs: typeof fs 28 | ``` 29 | 30 | Added in v0.0.1 31 | -------------------------------------------------------------------------------- /dtslint/index.d.ts: -------------------------------------------------------------------------------- 1 | // TypeScript Version: 3.9 2 | -------------------------------------------------------------------------------- /dtslint/ts3.9/index.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcanti/fp-ts-node/3a380b9e9803e64ee1525ce95b973e30d194d745/dtslint/ts3.9/index.d.ts -------------------------------------------------------------------------------- /dtslint/ts3.9/index.ts: -------------------------------------------------------------------------------- 1 | import * as fs from '../../src/fs' 2 | 3 | // $ExpectType TaskEither 4 | fs.readFile('path', 'utf8') 5 | -------------------------------------------------------------------------------- /dtslint/ts3.9/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noEmit": true, 4 | "strict": true, 5 | "noImplicitAny": true, 6 | "noImplicitThis": true, 7 | "strictNullChecks": true, 8 | "strictFunctionTypes": true, 9 | "noImplicitReturns": false, 10 | "noUnusedLocals": false, 11 | "noUnusedParameters": false, 12 | "noFallthroughCasesInSwitch": true, 13 | "target": "es5", 14 | "lib": ["es2015"] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /dtslint/ts3.9/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "array-type": false, 6 | "no-unnecessary-generics": false, 7 | "member-access": false, 8 | "no-empty-interface": false, 9 | "no-arg": false, 10 | "no-object-literal-type-assertion": false, 11 | "no-unnecessary-class": false, 12 | "radix": false, 13 | "no-angle-bracket-type-assertion": false, 14 | "object-literal-shorthand": false, 15 | "prefer-object-spread": false, 16 | "whitespace": false, 17 | "use-default-type-parameter": false, 18 | "no-relative-import-in-test": false, 19 | "no-null-undefined-union": false, 20 | "invalid-void": false, 21 | "prefer-const": false, 22 | "no-for-in": false 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /fp-ts-node-0.0.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gcanti/fp-ts-node/3a380b9e9803e64ee1525ce95b973e30d194d745/fp-ts-node-0.0.1.tgz -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | testEnvironment: 'node', 4 | collectCoverage: true, 5 | collectCoverageFrom: ['src/**/*.ts'], 6 | transform: { 7 | '^.+\\.tsx?$': 'ts-jest' 8 | }, 9 | testRegex: 'test', 10 | moduleFileExtensions: ['ts', 'js'], 11 | // coverageThreshold: { 12 | // global: { 13 | // branches: 100, 14 | // functions: 100, 15 | // lines: 100, 16 | // statements: 100, 17 | // }, 18 | // }, 19 | modulePathIgnorePatterns: [] 20 | } 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fp-ts-node", 3 | "version": "0.0.1", 4 | "description": "fp-ts bindings for node.js", 5 | "files": [ 6 | "lib", 7 | "es6" 8 | ], 9 | "main": "dist/lib/index.js", 10 | "module": "dist/es6/index.js", 11 | "typings": "dist/lib/index.d.ts", 12 | "sideEffects": false, 13 | "scripts": { 14 | "lint": "tslint -p .", 15 | "jest": "jest", 16 | "prettier": "prettier --list-different \"./{src,test}/**/*.ts\"", 17 | "pretest": "npm run lint && npm run prettier && npm run dtslint", 18 | "test": "npm run jest", 19 | "posttest": "npm run docs", 20 | "clean": "rimraf dist/lib/* dist/es6/*", 21 | "prebuild": "npm run clean", 22 | "build": "tsc -p ./tsconfig.build-lib.json && tsc -p ./tsconfig.build-es6.json", 23 | "postbuild": "import-path-rewrite && prettier --write \"./dist/{lib,es6}/**/*.ts\"", 24 | "prepublish": "npm run build", 25 | "dtslint": "dtslint dtslint", 26 | "mocha": "mocha -r ts-node/register test/*.ts", 27 | "docs": "docs-ts" 28 | }, 29 | "repository": { 30 | "type": "git", 31 | "url": "https://github.com/gcanti/fp-ts-node.git" 32 | }, 33 | "author": "Giulio Canti ", 34 | "license": "MIT", 35 | "bugs": { 36 | "url": "https://github.com/gcanti/fp-ts-node/issues" 37 | }, 38 | "homepage": "https://github.com/gcanti/fp-ts-node", 39 | "peerDependencies": { 40 | "fp-ts": "^2.7.1", 41 | "fs-extra": "^9.0.1" 42 | }, 43 | "devDependencies": { 44 | "@types/fs-extra": "^9.0.1", 45 | "@types/jest": "^22.2.2", 46 | "@types/node": "^14.0.26", 47 | "docs-ts": "^0.5.1", 48 | "dtslint": "github:gcanti/dtslint", 49 | "fp-ts": "^2.7.1", 50 | "fs-extra": "^9.0.1", 51 | "import-path-rewrite": "github:gcanti/import-path-rewrite", 52 | "jest": "^24.8.0", 53 | "mocha": "^5.2.0", 54 | "prettier": "^2.0.2", 55 | "rimraf": "^2.6.2", 56 | "ts-jest": "^24.0.2", 57 | "ts-node": "^8.0.2", 58 | "tslint": "^5.11.0", 59 | "tslint-config-standard": "^8.0.1", 60 | "tslint-immutable": "^6.0.1", 61 | "typescript": "^3.9.7" 62 | }, 63 | "tags": [], 64 | "keywords": [] 65 | } 66 | -------------------------------------------------------------------------------- /src/fs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 0.0.1 3 | */ 4 | import * as fs from 'fs-extra' 5 | import * as TE from 'fp-ts/lib/TaskEither' 6 | 7 | /** 8 | * Reads a file. 9 | * 10 | * @since 0.0.1 11 | */ 12 | export const readFile: (path: string, encoding: string) => TE.TaskEither = TE.taskify< 13 | string, 14 | string, 15 | Error, 16 | string 17 | >(fs.readFile) 18 | 19 | /** 20 | * Almost the same as `writeFile` (i.e. it overwrites), except that if the parent directory does not exist, it's created. 21 | * 22 | * @since 0.0.1 23 | */ 24 | export const writeFile: ( 25 | path: string, 26 | data: string, 27 | options: { 28 | readonly encoding?: string | null 29 | readonly flag?: string 30 | readonly mode?: number 31 | } 32 | ) => TE.TaskEither = TE.taskify(fs.outputFile) 33 | 34 | /** 35 | * Copy a file or directory. The directory can have contents. Will overwrite existing file or directory. 36 | * 37 | * @since 0.0.1 38 | */ 39 | export const copy: (src: string, dest: string) => TE.TaskEither = TE.taskify( 40 | fs.copy 41 | ) 42 | 43 | /** 44 | * Removes a file or directory. The directory can have contents. If the path does not exist, silently does nothing. 45 | * 46 | * @since 0.0.1 47 | */ 48 | export const remove: (path: string) => TE.TaskEither = TE.taskify(fs.remove) 49 | 50 | /** 51 | * Test whether or not the given path exists by checking with the file system. 52 | * 53 | * @since 0.0.1 54 | */ 55 | export const exists: (path: string) => TE.TaskEither = TE.taskify(fs.pathExists) 56 | 57 | /** 58 | * Moves a file or directory, even across devices. By default it won't overwrite existing file or directory. 59 | * 60 | * @since 0.0.1 61 | */ 62 | export const move: (src: string, dest: string, options: fs.MoveOptions) => TE.TaskEither = TE.taskify< 63 | string, 64 | string, 65 | fs.MoveOptions, 66 | Error, 67 | void 68 | >(fs.move) 69 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since 0.0.1 3 | */ 4 | 5 | import * as fs from './fs' 6 | 7 | export { 8 | /** 9 | * @since 0.0.1 10 | */ 11 | fs 12 | } 13 | -------------------------------------------------------------------------------- /test/index.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'assert' 2 | 3 | describe('placeholder', () => { 4 | it('placeholder', () => { 5 | assert.strictEqual(2 + 2, 4) 6 | }) 7 | }) 8 | -------------------------------------------------------------------------------- /tsconfig.build-es6.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": false, 5 | "outDir": "./dist/es6", 6 | "module": "es6" 7 | }, 8 | "include": ["./src"] 9 | } 10 | -------------------------------------------------------------------------------- /tsconfig.build-lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": false, 5 | "outDir": "./dist/lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noEmit": true, 4 | "target": "es5", 5 | "module": "commonjs", 6 | "moduleResolution": "node", 7 | "lib": ["es6"], 8 | "sourceMap": false, 9 | "declaration": true, 10 | "strict": true, 11 | "noImplicitReturns": true, 12 | "noUnusedLocals": true, 13 | "noUnusedParameters": true, 14 | "noFallthroughCasesInSwitch": true, 15 | "forceConsistentCasingInFileNames": true, 16 | "stripInternal": true 17 | }, 18 | "include": ["./src", "./test"] 19 | } 20 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["tslint-config-standard", "tslint-immutable"], 3 | "rules": { 4 | "space-before-function-paren": false, 5 | "no-use-before-declare": false, 6 | "variable-name": false, 7 | "quotemark": [true, "single", "jsx-double"], 8 | "ter-indent": false, 9 | "strict-boolean-expressions": true, 10 | "forin": true, 11 | "no-console": true, 12 | "array-type": [true, "generic"], 13 | "readonly-keyword": true, 14 | "readonly-array": true 15 | } 16 | } 17 | --------------------------------------------------------------------------------