Compare commits

...

5 Commits

Author SHA1 Message Date
26a67d9662 11.0.17 2024-06-06 22:29:06 +02:00
14771fab27 fix(core): update 2024-06-06 22:29:06 +02:00
b0ae383622 update description 2024-05-29 14:13:08 +02:00
921f1cbb66 11.0.16 2024-05-28 12:43:47 +02:00
a9b373f5f8 fix(core): update 2024-05-28 12:43:46 +02:00
5 changed files with 4836 additions and 2810 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "@push.rocks/smartfile", "name": "@push.rocks/smartfile",
"private": false, "private": false,
"version": "11.0.15", "version": "11.0.17",
"description": "Provides comprehensive tools for efficient file management in Node.js using TypeScript, including handling streams, virtual directories, and various file operations.", "description": "Provides comprehensive tools for efficient file management in Node.js using TypeScript, including handling streams, virtual directories, and various file operations.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
@ -13,7 +13,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://gitlab.com/push.rocks/smartfile.git" "url": "https://code.foss.global/push.rocks/smartfile.git"
}, },
"keywords": [ "keywords": [
"file management", "file management",
@ -40,31 +40,31 @@
"bugs": { "bugs": {
"url": "https://gitlab.com/push.rocks/smartfile/issues" "url": "https://gitlab.com/push.rocks/smartfile/issues"
}, },
"homepage": "https://gitlab.com/push.rocks/smartfile#readme", "homepage": "https://code.foss.global/push.rocks/smartfile",
"dependencies": { "dependencies": {
"@push.rocks/lik": "^6.0.14", "@push.rocks/lik": "^6.0.15",
"@push.rocks/smartdelay": "^3.0.5", "@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartfile-interfaces": "^1.0.7", "@push.rocks/smartfile-interfaces": "^1.0.7",
"@push.rocks/smarthash": "^3.0.4", "@push.rocks/smarthash": "^3.0.4",
"@push.rocks/smartjson": "^5.0.16", "@push.rocks/smartjson": "^5.0.20",
"@push.rocks/smartmime": "^1.0.5", "@push.rocks/smartmime": "^2.0.2",
"@push.rocks/smartpath": "^5.0.13", "@push.rocks/smartpath": "^5.0.18",
"@push.rocks/smartpromise": "^4.0.2", "@push.rocks/smartpromise": "^4.0.2",
"@push.rocks/smartrequest": "^2.0.21", "@push.rocks/smartrequest": "^2.0.22",
"@push.rocks/smartstream": "^3.0.34", "@push.rocks/smartstream": "^3.0.38",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/glob": "^8.1.0", "@types/glob": "^8.1.0",
"@types/js-yaml": "^4.0.9", "@types/js-yaml": "^4.0.9",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"glob": "^10.3.12", "glob": "^10.4.1",
"js-yaml": "^4.1.0" "js-yaml": "^4.1.0"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.1.72", "@git.zone/tsbuild": "^2.1.80",
"@git.zone/tsrun": "^1.2.46", "@git.zone/tsrun": "^1.2.46",
"@git.zone/tstest": "^1.0.88", "@git.zone/tstest": "^1.0.90",
"@push.rocks/tapbundle": "^5.0.22", "@push.rocks/tapbundle": "^5.0.23",
"@types/node": "^20.12.7" "@types/node": "^20.12.12"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

7582
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smartfile', name: '@push.rocks/smartfile',
version: '11.0.15', version: '11.0.17',
description: 'Provides comprehensive tools for efficient file management in Node.js using TypeScript, including handling streams, virtual directories, and various file operations.' description: 'Provides comprehensive tools for efficient file management in Node.js using TypeScript, including handling streams, virtual directories, and various file operations.'
} }

View File

@ -10,20 +10,6 @@ type TStreamSource = (streamFile: StreamFile) => Promise<Readable>;
* It allows creating streams from a file path, a URL, or a buffer. * It allows creating streams from a file path, a URL, or a buffer.
*/ */
export class StreamFile { export class StreamFile {
// INSTANCE
relativeFilePath?: string;
private streamSource: TStreamSource;
// enable stream based multi use
private cachedStreamBuffer?: Buffer;
public multiUse: boolean;
public used: boolean = false;
private constructor(streamSource: TStreamSource, relativeFilePath?: string) {
this.streamSource = streamSource;
this.relativeFilePath = relativeFilePath;
}
// STATIC // STATIC
public static async fromPath(filePath: string): Promise<StreamFile> { public static async fromPath(filePath: string): Promise<StreamFile> {
@ -91,6 +77,21 @@ export class StreamFile {
return streamFile; return streamFile;
} }
// INSTANCE
relativeFilePath?: string;
private streamSource: TStreamSource;
// enable stream based multi use
private cachedStreamBuffer?: Buffer;
public multiUse: boolean;
public used: boolean = false;
private constructor(streamSource: TStreamSource, relativeFilePath?: string) {
this.streamSource = streamSource;
this.relativeFilePath = relativeFilePath;
}
// METHODS // METHODS
private checkMultiUse() { private checkMultiUse() {

View File

@ -190,7 +190,8 @@ export const removeManySync = (filePathArrayArg: string[]): void => {
===============================================================*/ ===============================================================*/
/** /**
* * reads a file content to an object
* good for JSON, YAML, TOML, etc.
* @param filePathArg * @param filePathArg
* @param fileTypeArg * @param fileTypeArg
* @returns {any} * @returns {any}
@ -206,7 +207,7 @@ export const toObjectSync = (filePathArg, fileTypeArg?) => {
* reads a file content to a String * reads a file content to a String
*/ */
export const toStringSync = (filePath: string): string => { export const toStringSync = (filePath: string): string => {
const encoding = plugins.smartmime.getEncoding(filePath); const encoding = plugins.smartmime.getEncodingForPathSync(filePath);
let fileString: string | Buffer = plugins.fsExtra.readFileSync(filePath, encoding); let fileString: string | Buffer = plugins.fsExtra.readFileSync(filePath, encoding);
if (Buffer.isBuffer(fileString)) { if (Buffer.isBuffer(fileString)) {
fileString = fileString.toString('binary'); fileString = fileString.toString('binary');