Skip to content

Commit

Permalink
feat(node-fs): base package
Browse files Browse the repository at this point in the history
  • Loading branch information
njfamirm committed Jan 6, 2024
1 parent 41421b4 commit 5a1100d
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ Here is a brief overview of the included libraries:
11. [`exit-hook`](./packages/exit-hook/README.md): A utility for registering exit handlers in Node.js.
12. [`flatomise`](./packages/flatomise/README.md): A utility for creating promises that can be externally resolved or rejected.
13. [`async-queue`](./packages/async-queue/README.md): A queue that executes async tasks in order like mutex and semaphore methodology for javascript and typescript.
14. [`node-fs`](./packages/node-fs/README.md): Enhanced file system operations in Node.js, including reading, writing, and handling JSON files, with both synchronous and asynchronous options.

For more detailed information and guidelines on how to use each package, please refer to to each package's README.
17 changes: 17 additions & 0 deletions packages/node-fs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Node FS

Enhanced file system operations in Node.js, including reading, writing, and handling JSON files, with both synchronous and asynchronous options.

## Installation

```bash
yarn add @alwatr/node-fs
```

## Usage

```typescript
import {writeJsonFile, WriteFileMode} from '@alwatr/node-fs';

await writeJsonFile('./file.json', {a: 1, b: 2, c: 3}, WriteFileMode.Replace);
```
82 changes: 82 additions & 0 deletions packages/node-fs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"name": "@alwatr/node-fs",
"version": "0.0.0",
"description": "Enhanced file system operations in Node.js, including reading, writing, and handling JSON files, with both synchronous and asynchronous options.",
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
"keywords": [
"node-fs",
"fs",
"file",
"file-system",
"cross-platform",
"ECMAScript",
"typescript",
"javascript",
"node",
"nodejs",
"esm",
"module",
"utility",
"util",
"utils",
"nanolib",
"alwatr"
],
"type": "module",
"main": "./dist/main.cjs",
"module": "./dist/main.mjs",
"types": "./dist/main.d.ts",
"exports": {
".": {
"import": "./dist/main.mjs",
"require": "./dist/main.cjs",
"types": "./dist/main.d.ts"
}
},
"license": "MIT",
"files": [
"**/*.{js,mjs,cjs,map,d.ts,html,md}",
"!demo/**/*"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/Alwatr/nanolib",
"directory": "packages/node-fs"
},
"homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/node-fs#readme",
"bugs": {
"url": "https://github.com/Alwatr/nanolib/issues"
},
"prettier": "@alwatr/prettier-config",
"scripts": {
"b": "yarn run build",
"w": "yarn run watch",
"c": "yarn run clean",
"cb": "yarn run clean && yarn run build",
"d": "yarn run build:es && yarn node --enable-source-maps --trace-warnings",
"build": "yarn run build:ts & yarn run build:es",
"build:es": "nano-build --preset=module",
"build:ts": "tsc --build",
"watch": "yarn run watch:ts & yarn run watch:es",
"watch:es": "yarn run build:es --watch",
"watch:ts": "yarn run build:ts --watch --preserveWatchOutput",
"clean": "rm -rfv dist *.tsbuildinfo"
},
"dependencies": {
"@alwatr/async-queue": "workspace:^",
"@alwatr/dedupe": "workspace:^",
"@alwatr/flat-string": "workspace:^",
"@alwatr/logger": "workspace:^"
},
"devDependencies": {
"@alwatr/nano-build": "workspace:^",
"@alwatr/prettier-config": "workspace:^",
"@alwatr/tsconfig-base": "workspace:^",
"@alwatr/type-helper": "workspace:^",
"@types/node": "^20.10.6",
"typescript": "^5.3.3"
}
}
11 changes: 11 additions & 0 deletions packages/node-fs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "@alwatr/tsconfig-base/tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"emitDeclarationOnly": true,
"composite": true,
},
"include": ["src/**/*.ts"],
"references": []
}
23 changes: 20 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ __metadata:
languageName: node
linkType: hard

"@alwatr/async-queue@workspace:packages/async-queue":
"@alwatr/async-queue@workspace:^, @alwatr/async-queue@workspace:packages/async-queue":
version: 0.0.0-use.local
resolution: "@alwatr/async-queue@workspace:packages/async-queue"
dependencies:
Expand Down Expand Up @@ -84,7 +84,7 @@ __metadata:
languageName: unknown
linkType: soft

"@alwatr/flat-string@workspace:packages/flat-string":
"@alwatr/flat-string@workspace:^, @alwatr/flat-string@workspace:packages/flat-string":
version: 0.0.0-use.local
resolution: "@alwatr/flat-string@workspace:packages/flat-string"
dependencies:
Expand Down Expand Up @@ -119,7 +119,7 @@ __metadata:
languageName: unknown
linkType: soft

"@alwatr/logger@workspace:packages/logger":
"@alwatr/logger@workspace:^, @alwatr/logger@workspace:packages/logger":
version: 0.0.0-use.local
resolution: "@alwatr/logger@workspace:packages/logger"
dependencies:
Expand All @@ -146,6 +146,23 @@ __metadata:
languageName: unknown
linkType: soft

"@alwatr/node-fs@workspace:packages/node-fs":
version: 0.0.0-use.local
resolution: "@alwatr/node-fs@workspace:packages/node-fs"
dependencies:
"@alwatr/async-queue": "workspace:^"
"@alwatr/dedupe": "workspace:^"
"@alwatr/flat-string": "workspace:^"
"@alwatr/logger": "workspace:^"
"@alwatr/nano-build": "workspace:^"
"@alwatr/prettier-config": "workspace:^"
"@alwatr/tsconfig-base": "workspace:^"
"@alwatr/type-helper": "workspace:^"
"@types/node": "npm:^20.10.6"
typescript: "npm:^5.3.3"
languageName: unknown
linkType: soft

"@alwatr/platform-info@workspace:^, @alwatr/platform-info@workspace:packages/platform-info":
version: 0.0.0-use.local
resolution: "@alwatr/platform-info@workspace:packages/platform-info"
Expand Down

0 comments on commit 5a1100d

Please sign in to comment.