react-native-blob-util 0.24.10 → 0.24.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -625,7 +625,7 @@ export interface AndroidApi {
625
625
  getSDCardApplicationDir(): Promise<string>;
626
626
  }
627
627
 
628
- type Methods = "POST" | "GET" | "DELETE" | "PUT" | "PATCH" | "post" | "get" | "delete" | "put" | "patch";
628
+ type Methods = "POST" | "GET" | "DELETE" | "PUT" | "PATCH" | "HEAD" | "post" | "get" | "delete" | "put" | "patch" | "head";
629
629
 
630
630
  /**
631
631
  * A declare class inherits Promise, it has extra method like progress, uploadProgress,
@@ -640,7 +640,7 @@ export interface StatefulPromise<T> extends Promise<T> {
640
640
  /**
641
641
  * Add an event listener which triggers when data receiving from server.
642
642
  */
643
- progress(callback: (received: string, total: string) => void): StatefulPromise<FetchBlobResponse>;
643
+ progress(callback: (received: number, total: number) => void): StatefulPromise<FetchBlobResponse>;
644
644
 
645
645
  /**
646
646
  * Add an event listener with custom configuration
package/index.js.flow CHANGED
@@ -1,192 +1,192 @@
1
- // @flow strict
2
-
3
- declare class AndroidApi {
4
- actionViewIntent(path: string, mime?: string): Promise<void>;
5
- addCompleteDownload(options: AndroidDownloadOption): Promise<void>;
6
- getContentIntent(mime: string): Promise<string>;
7
- getSDCardApplicationDir(): Promise<string>;
8
- getSDCardDir(): Promise<string>;
9
- }
10
-
11
- declare class FetchBlobResponse {
12
- data: string;
13
- respInfo: ReactNativeBlobUtilResponseInfo;
14
- taskId: string;
15
- type: "utf8" | "base64" | "path";
16
- array(): Promise<number[]>;
17
- base64(): string | Promise<string>;
18
- blob(): Promise<Blob>;
19
- flush(): Promise<void>;
20
- info(): ReactNativeBlobUtilResponseInfo;
21
- // $FlowExpectedError Not possible to specify in strict mode.
22
- json(): any;
23
- path(): string;
24
- readFile(encoding: Encoding): ?Promise<number[] | string>;
25
- readStream(encoding: Encoding): ?Promise<ReactNativeBlobUtilReadStream>;
26
- session(name: string): ?ReactNativeBlobUtilSession;
27
- text(): string | Promise<string>;
28
- }
29
-
30
- declare class FsApi {
31
- ReactNativeBlobUtilSession: ReactNativeBlobUtilSession;
32
- dirs: Dirs;
33
- appendFile(path: string, data: string | number[], encoding?: Encoding | "uri"): Promise<number>;
34
- asset(path: string): string;
35
- cp(path: string, dest: string): Promise<boolean>;
36
- createFile(path: string, data: string, encoding: Encoding | "uri"): Promise<string>;
37
- df(): Promise<AndroidFsStat | IosFsStat>;
38
- exists(path: string): Promise<boolean>;
39
- hash(path: string, algorithm: HashAlgorithm): Promise<string>;
40
- isDir(path: string): Promise<boolean>;
41
- ls(path: string): Promise<string[]>;
42
- lstat(path: string): Promise<ReactNativeBlobUtilStat[]>;
43
- mkdir(path: string): Promise<boolean>;
44
- mv(path: string, dest: string): Promise<boolean>;
45
- pathForAppGroup(groupName: string): Promise<string>;
46
- readFile(path: string, encoding: Encoding, bufferSize?: number): Promise<number[] | string>;
47
- readStream(path: string, encoding: Encoding, bufferSize?: number, tick?: number): Promise<ReactNativeBlobUtilReadStream>;
48
- scanFile(pairs: { mime: string, path: string }[]): Promise<void>;
49
- session(name: string): ReactNativeBlobUtilSession;
50
- slice(src: string, dest: string, start: number, end: number): Promise<string>;
51
- stat(path: string): Promise<ReactNativeBlobUtilStat>;
52
- unlink(path: string): Promise<void>;
53
- writeFile(path: string, data: string | number[], encoding?: Encoding | "uri"): Promise<number>;
54
- writeStream(path: string, encoding: Encoding, append?: boolean): Promise<ReactNativeBlobUtilWriteStream>;
55
- }
56
-
57
- declare class IosApi {
58
- excludeFromBackupKey(path: string): Promise<void>;
59
- openDocument(path: string, scheme?: string): Promise<void>;
60
- previewDocument(path: string, scheme?: string): Promise<void>;
61
- }
62
-
63
- declare class ReactNativeBlobUtilReadStream {
64
- bufferSize?: number;
65
- closed: boolean;
66
- encoding: Encoding;
67
- path: string;
68
- tick: number;
69
- onData(fn: (chunk: string) => void): void;
70
- onEnd(fn: () => void): void;
71
- onError(fn: (err: Error) => void): void;
72
- open(): void;
73
- }
74
-
75
- declare class ReactNativeBlobUtilSession {
76
- static getSession(name: string): ReactNativeBlobUtilSession;
77
- static removeSession(name: string): void;
78
- static setSession(name: string, val: ReactNativeBlobUtilSession): void;
79
-
80
- name: string;
81
- add(path: string): ReactNativeBlobUtilSession;
82
- constructor(name: string, list: string[]): ReactNativeBlobUtilSession;
83
- dispose(): Promise<void>;
84
- list(): string[];
85
- remove(path: string): ReactNativeBlobUtilSession;
86
- }
87
-
88
- declare class ReactNativeBlobUtilWriteStream {
89
- append: boolean;
90
- encoding: string;
91
- id: string;
92
- close(): void;
93
- write(data: string): Promise<void>;
94
- }
95
-
96
- declare class ReactNativeBlobUtil {
97
- android: AndroidApi;
98
- base64: { +decode: (input: string) => string, +encode: (input: string) => string };
99
- fs: FsApi;
100
- ios: IosApi;
101
- config(options: ReactNativeBlobUtilConfig): { fetch: (method: Methods, url: string, headers?: { [key: string]: string }, body?: string | FormField[]) => StatefulPromise<FetchBlobResponse> };
102
- fetch(method: Methods, url: string, headers?: { [key: string]: string }, body?: string | FormField[]): StatefulPromise<FetchBlobResponse>;
103
- session(name: string): ReactNativeBlobUtilSession;
104
- wrap(path: string): string;
105
- }
106
-
107
- declare class StatefulPromise<T> extends Promise<T> {
108
- cancel(callback?: (error: ?string, taskId: ?string) => void): void;
109
- expire(callback: () => void): StatefulPromise<void>;
110
- progress(config: { count?: number, interval?: number } | ProgressCallback, callback?: ProgressCallback): StatefulPromise<T>;
111
- stateChange(callback: (state: ReactNativeBlobUtilResponseInfo) => void): StatefulPromise<T>;
112
- uploadProgress(config: { count?: number, interval?: number } | UploadProgressCallback, callback?: UploadProgressCallback): StatefulPromise<T>;
113
- }
114
-
115
- export type AddAndroidDownloads = {
116
- description?: string,
117
- mediaScannable?: boolean,
118
- mime?: string,
119
- notification?: boolean,
120
- path?: string,
121
- title?: string,
122
- useDownloadManager?: boolean,
123
- storeLocal: boolean
124
- };
125
- export type AndroidDownloadOption = {
126
- description?: string,
127
- mime?: string,
128
- path: string,
129
- showNotification?: boolean,
130
- title?: string
131
- };
132
- export type AndroidFsStat = {
133
- external_free: number,
134
- external_total: number,
135
- internal_free: number,
136
- internal_total: number
137
- };
138
- export type Dirs = {
139
- CacheDir: string,
140
- DCIMDir: string,
141
- DocumentDir: string,
142
- DownloadDir: string,
143
- LibraryDir: string,
144
- MainBundleDir: string,
145
- MovieDir: string,
146
- MusicDir: string,
147
- PictureDir: string,
148
- SDCardApplicationDir: string,
149
- SDCardDir: string
150
- };
151
- export type Encoding = "utf8" | "ascii" | "base64";
152
- export type FormField = { data: string, filename?: string, name: string, type?: string };
153
- export type HashAlgorithm = "md5" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512";
154
- export type IosFsStat = { free: number, total: number };
155
- export type Methods = "POST" | "GET" | "DELETE" | "PUT" | "post" | "get" | "delete" | "put";
156
- export type ProgressCallback = (received: number, total: number) => void;
157
- export type ReactNativeBlobUtilConfig = {
158
- Progress?: { count?: number, interval?: number },
159
- UploadProgress?: { count?: number, interval?: number },
160
- IOSBackgroundTask?: boolean,
161
- addAndroidDownloads?: AddAndroidDownloads,
162
- appendExt?: string,
163
- fileCache?: boolean,
164
- indicator?: boolean,
165
- overwrite?: boolean,
166
- path?: string,
167
- session?: string,
168
- timeout?: number,
169
- trusty?: boolean,
170
- wifiOnly?: boolean,
171
- followRedirect?: boolean
172
- };
173
- export type ReactNativeBlobUtilResponseInfo = {
174
- headers: { [fieldName: string]: string },
175
- redirects: string[],
176
- respType: "text" | "blob" | "" | "json",
177
- rnfbEncode: "path" | Encoding,
178
- state: string,
179
- status: number,
180
- taskId: string,
181
- timeout: boolean
182
- };
183
- export type ReactNativeBlobUtilStat = {
184
- filename: string,
185
- lastModified: number,
186
- path: string,
187
- size: number,
188
- type: "directory" | "file" | "asset"
189
- };
190
- export type UploadProgressCallback = (sent: number, total: number) => void;
191
-
192
- declare export default ReactNativeBlobUtil;
1
+ // @flow strict
2
+
3
+ declare class AndroidApi {
4
+ actionViewIntent(path: string, mime?: string): Promise<void>;
5
+ addCompleteDownload(options: AndroidDownloadOption): Promise<void>;
6
+ getContentIntent(mime: string): Promise<string>;
7
+ getSDCardApplicationDir(): Promise<string>;
8
+ getSDCardDir(): Promise<string>;
9
+ }
10
+
11
+ declare class FetchBlobResponse {
12
+ data: string;
13
+ respInfo: ReactNativeBlobUtilResponseInfo;
14
+ taskId: string;
15
+ type: "utf8" | "base64" | "path";
16
+ array(): Promise<number[]>;
17
+ base64(): string | Promise<string>;
18
+ blob(): Promise<Blob>;
19
+ flush(): Promise<void>;
20
+ info(): ReactNativeBlobUtilResponseInfo;
21
+ // $FlowExpectedError Not possible to specify in strict mode.
22
+ json(): any;
23
+ path(): string;
24
+ readFile(encoding: Encoding): ?Promise<number[] | string>;
25
+ readStream(encoding: Encoding): ?Promise<ReactNativeBlobUtilReadStream>;
26
+ session(name: string): ?ReactNativeBlobUtilSession;
27
+ text(): string | Promise<string>;
28
+ }
29
+
30
+ declare class FsApi {
31
+ ReactNativeBlobUtilSession: ReactNativeBlobUtilSession;
32
+ dirs: Dirs;
33
+ appendFile(path: string, data: string | number[], encoding?: Encoding | "uri"): Promise<number>;
34
+ asset(path: string): string;
35
+ cp(path: string, dest: string): Promise<boolean>;
36
+ createFile(path: string, data: string, encoding: Encoding | "uri"): Promise<string>;
37
+ df(): Promise<AndroidFsStat | IosFsStat>;
38
+ exists(path: string): Promise<boolean>;
39
+ hash(path: string, algorithm: HashAlgorithm): Promise<string>;
40
+ isDir(path: string): Promise<boolean>;
41
+ ls(path: string): Promise<string[]>;
42
+ lstat(path: string): Promise<ReactNativeBlobUtilStat[]>;
43
+ mkdir(path: string): Promise<boolean>;
44
+ mv(path: string, dest: string): Promise<boolean>;
45
+ pathForAppGroup(groupName: string): Promise<string>;
46
+ readFile(path: string, encoding: Encoding, bufferSize?: number): Promise<number[] | string>;
47
+ readStream(path: string, encoding: Encoding, bufferSize?: number, tick?: number): Promise<ReactNativeBlobUtilReadStream>;
48
+ scanFile(pairs: { mime: string, path: string }[]): Promise<void>;
49
+ session(name: string): ReactNativeBlobUtilSession;
50
+ slice(src: string, dest: string, start: number, end: number): Promise<string>;
51
+ stat(path: string): Promise<ReactNativeBlobUtilStat>;
52
+ unlink(path: string): Promise<void>;
53
+ writeFile(path: string, data: string | number[], encoding?: Encoding | "uri"): Promise<number>;
54
+ writeStream(path: string, encoding: Encoding, append?: boolean): Promise<ReactNativeBlobUtilWriteStream>;
55
+ }
56
+
57
+ declare class IosApi {
58
+ excludeFromBackupKey(path: string): Promise<void>;
59
+ openDocument(path: string, scheme?: string): Promise<void>;
60
+ previewDocument(path: string, scheme?: string): Promise<void>;
61
+ }
62
+
63
+ declare class ReactNativeBlobUtilReadStream {
64
+ bufferSize?: number;
65
+ closed: boolean;
66
+ encoding: Encoding;
67
+ path: string;
68
+ tick: number;
69
+ onData(fn: (chunk: string) => void): void;
70
+ onEnd(fn: () => void): void;
71
+ onError(fn: (err: Error) => void): void;
72
+ open(): void;
73
+ }
74
+
75
+ declare class ReactNativeBlobUtilSession {
76
+ static getSession(name: string): ReactNativeBlobUtilSession;
77
+ static removeSession(name: string): void;
78
+ static setSession(name: string, val: ReactNativeBlobUtilSession): void;
79
+
80
+ name: string;
81
+ add(path: string): ReactNativeBlobUtilSession;
82
+ constructor(name: string, list: string[]): ReactNativeBlobUtilSession;
83
+ dispose(): Promise<void>;
84
+ list(): string[];
85
+ remove(path: string): ReactNativeBlobUtilSession;
86
+ }
87
+
88
+ declare class ReactNativeBlobUtilWriteStream {
89
+ append: boolean;
90
+ encoding: string;
91
+ id: string;
92
+ close(): void;
93
+ write(data: string): Promise<void>;
94
+ }
95
+
96
+ declare class ReactNativeBlobUtil {
97
+ android: AndroidApi;
98
+ base64: { +decode: (input: string) => string, +encode: (input: string) => string };
99
+ fs: FsApi;
100
+ ios: IosApi;
101
+ config(options: ReactNativeBlobUtilConfig): { fetch: (method: Methods, url: string, headers?: { [key: string]: string }, body?: string | FormField[]) => StatefulPromise<FetchBlobResponse> };
102
+ fetch(method: Methods, url: string, headers?: { [key: string]: string }, body?: string | FormField[]): StatefulPromise<FetchBlobResponse>;
103
+ session(name: string): ReactNativeBlobUtilSession;
104
+ wrap(path: string): string;
105
+ }
106
+
107
+ declare class StatefulPromise<T> extends Promise<T> {
108
+ cancel(callback?: (error: ?string, taskId: ?string) => void): void;
109
+ expire(callback: () => void): StatefulPromise<void>;
110
+ progress(config: { count?: number, interval?: number } | ProgressCallback, callback?: ProgressCallback): StatefulPromise<T>;
111
+ stateChange(callback: (state: ReactNativeBlobUtilResponseInfo) => void): StatefulPromise<T>;
112
+ uploadProgress(config: { count?: number, interval?: number } | UploadProgressCallback, callback?: UploadProgressCallback): StatefulPromise<T>;
113
+ }
114
+
115
+ export type AddAndroidDownloads = {
116
+ description?: string,
117
+ mediaScannable?: boolean,
118
+ mime?: string,
119
+ notification?: boolean,
120
+ path?: string,
121
+ title?: string,
122
+ useDownloadManager?: boolean,
123
+ storeLocal: boolean
124
+ };
125
+ export type AndroidDownloadOption = {
126
+ description?: string,
127
+ mime?: string,
128
+ path: string,
129
+ showNotification?: boolean,
130
+ title?: string
131
+ };
132
+ export type AndroidFsStat = {
133
+ external_free: number,
134
+ external_total: number,
135
+ internal_free: number,
136
+ internal_total: number
137
+ };
138
+ export type Dirs = {
139
+ CacheDir: string,
140
+ DCIMDir: string,
141
+ DocumentDir: string,
142
+ DownloadDir: string,
143
+ LibraryDir: string,
144
+ MainBundleDir: string,
145
+ MovieDir: string,
146
+ MusicDir: string,
147
+ PictureDir: string,
148
+ SDCardApplicationDir: string,
149
+ SDCardDir: string
150
+ };
151
+ export type Encoding = "utf8" | "ascii" | "base64";
152
+ export type FormField = { data: string, filename?: string, name: string, type?: string };
153
+ export type HashAlgorithm = "md5" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512";
154
+ export type IosFsStat = { free: number, total: number };
155
+ export type Methods = "POST" | "GET" | "DELETE" | "PUT" | "PATCH" | "HEAD" | "post" | "get" | "delete" | "put" | "patch" | "head";
156
+ export type ProgressCallback = (received: number, total: number) => void;
157
+ export type ReactNativeBlobUtilConfig = {
158
+ Progress?: { count?: number, interval?: number },
159
+ UploadProgress?: { count?: number, interval?: number },
160
+ IOSBackgroundTask?: boolean,
161
+ addAndroidDownloads?: AddAndroidDownloads,
162
+ appendExt?: string,
163
+ fileCache?: boolean,
164
+ indicator?: boolean,
165
+ overwrite?: boolean,
166
+ path?: string,
167
+ session?: string,
168
+ timeout?: number,
169
+ trusty?: boolean,
170
+ wifiOnly?: boolean,
171
+ followRedirect?: boolean
172
+ };
173
+ export type ReactNativeBlobUtilResponseInfo = {
174
+ headers: { [fieldName: string]: string },
175
+ redirects: string[],
176
+ respType: "text" | "blob" | "" | "json",
177
+ rnfbEncode: "path" | Encoding,
178
+ state: string,
179
+ status: number,
180
+ taskId: string,
181
+ timeout: boolean
182
+ };
183
+ export type ReactNativeBlobUtilStat = {
184
+ filename: string,
185
+ lastModified: number,
186
+ path: string,
187
+ size: number,
188
+ type: "directory" | "file" | "asset"
189
+ };
190
+ export type UploadProgressCallback = (sent: number, total: number) => void;
191
+
192
+ declare export default ReactNativeBlobUtil;
package/package.json CHANGED
@@ -1,85 +1,83 @@
1
- {
2
- "name": "react-native-blob-util",
3
- "version": "0.24.10",
4
- "description": "A module provides upload, download, and files access API. Supports file stream read/write for process large files.",
5
- "main": "index",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1",
8
- "e2e:server": "node tests/e2e/server.js",
9
- "e2e:android": "node tests/e2e/run-all.js --platforms android",
10
- "e2e:ios": "node tests/e2e/run-all.js --platforms ios",
11
- "e2e:windows": "node tests/e2e/run-all.js --platforms windows",
12
- "e2e:runner": "node tests/e2e/appium/run.js",
13
- "e2e:all": "node tests/e2e/run-all.js"
14
- },
15
- "dependencies": {
16
- "base-64": "1.0.0",
17
- "glob": "13.0.6"
18
- },
19
- "keywords": [
20
- "react-native",
21
- "fetch",
22
- "blob",
23
- "fs",
24
- "upload",
25
- "file",
26
- "download",
27
- "filestream",
28
- "image header",
29
- "android",
30
- "ios",
31
- "file system"
32
- ],
33
- "repository": {
34
- "url": "https://github.com/RonRadtke/react-native-blob-util"
35
- },
36
- "author": {
37
- "name": "RonRadtke",
38
- "username": "RonRadtke"
39
- },
40
- "funding": {
41
- "type": "github",
42
- "url": "https://github.com/sponsors/ronradtke"
43
- },
44
- "license": "MIT",
45
- "contributors": [
46
- "Traviskn <>",
47
- "Ben <benhsieh@catchplay.com>",
48
- "wkh237 <xeiyan@gmail.com>"
49
- ],
50
- "devDependencies": {
51
- "@typescript-eslint/eslint-plugin": "^8.61.1",
52
- "@typescript-eslint/parser": "^8.61.1",
53
- "appium-uiautomator2-driver": "^7.6.2",
54
- "eslint": "^8.57.1",
55
- "eslint-plugin-ft-flow": "^3.0.11",
56
- "eslint-plugin-import": "^2.32.0",
57
- "eslint-plugin-react": "^7.37.5",
58
- "eslint-plugin-react-native": "^5.0.0",
59
- "react": "19.2.3",
60
- "react-native": "0.84.1",
61
- "react-native-windows": "0.84.0",
62
- "webdriverio": "^9.29.0"
63
- },
64
- "peerDependencies": {
65
- "react": "*",
66
- "react-native": "*"
67
- },
68
- "codegenConfig": {
69
- "name": "ReactNativeBlobUtilSpec",
70
- "type": "modules",
71
- "jsSrcsDir": "codegenSpecs",
72
- "windows": {
73
- "namespace": "ReactNativeBlobUtilCodegen",
74
- "outputDirectory": "windows/ReactNativeBlobUtil/codegen",
75
- "separateDataTypes": true
76
- }
77
- },
78
- "react-native-windows": {
79
- "init-windows": {
80
- "name": "ReactNativeBlobUtil",
81
- "namespace": "ReactNativeBlobUtil",
82
- "template": "cpp-lib"
83
- }
84
- }
85
- }
1
+ {
2
+ "name": "react-native-blob-util",
3
+ "version": "0.24.11",
4
+ "description": "A module provides upload, download, and files access API. Supports file stream read/write for process large files.",
5
+ "main": "index",
6
+ "scripts": {
7
+ "test": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON --test \"tests/unit/*.test.js\"",
8
+ "e2e:server": "node tests/e2e/server.js",
9
+ "e2e:android": "node tests/e2e/run-all.js --platforms android",
10
+ "e2e:ios": "node tests/e2e/run-all.js --platforms ios",
11
+ "e2e:windows": "node tests/e2e/run-all.js --platforms windows",
12
+ "e2e:runner": "node tests/e2e/appium/run.js",
13
+ "e2e:all": "node tests/e2e/run-all.js"
14
+ },
15
+ "dependencies": {
16
+ "base-64": "1.0.0"
17
+ },
18
+ "keywords": [
19
+ "react-native",
20
+ "fetch",
21
+ "blob",
22
+ "fs",
23
+ "upload",
24
+ "file",
25
+ "download",
26
+ "filestream",
27
+ "image header",
28
+ "android",
29
+ "ios",
30
+ "file system"
31
+ ],
32
+ "repository": {
33
+ "url": "https://github.com/RonRadtke/react-native-blob-util"
34
+ },
35
+ "author": {
36
+ "name": "RonRadtke",
37
+ "username": "RonRadtke"
38
+ },
39
+ "funding": {
40
+ "type": "github",
41
+ "url": "https://github.com/sponsors/ronradtke"
42
+ },
43
+ "license": "MIT",
44
+ "contributors": [
45
+ "Traviskn <>",
46
+ "Ben <benhsieh@catchplay.com>",
47
+ "wkh237 <xeiyan@gmail.com>"
48
+ ],
49
+ "devDependencies": {
50
+ "@typescript-eslint/eslint-plugin": "^8.61.1",
51
+ "@typescript-eslint/parser": "^8.61.1",
52
+ "eslint": "^8.57.1",
53
+ "eslint-plugin-ft-flow": "^3.0.11",
54
+ "eslint-plugin-import": "^2.32.0",
55
+ "eslint-plugin-react": "^7.37.5",
56
+ "eslint-plugin-react-native": "^5.0.0",
57
+ "react": "19.2.3",
58
+ "react-native": "0.84.1",
59
+ "react-native-windows": "0.84.0",
60
+ "webdriverio": "^9.29.0"
61
+ },
62
+ "peerDependencies": {
63
+ "react": "*",
64
+ "react-native": "*"
65
+ },
66
+ "codegenConfig": {
67
+ "name": "ReactNativeBlobUtilSpec",
68
+ "type": "modules",
69
+ "jsSrcsDir": "codegenSpecs",
70
+ "windows": {
71
+ "namespace": "ReactNativeBlobUtilCodegen",
72
+ "outputDirectory": "windows/ReactNativeBlobUtil/codegen",
73
+ "separateDataTypes": true
74
+ }
75
+ },
76
+ "react-native-windows": {
77
+ "init-windows": {
78
+ "name": "ReactNativeBlobUtil",
79
+ "namespace": "ReactNativeBlobUtil",
80
+ "template": "cpp-lib"
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Native reports progress byte counts inconsistently across platforms:
3
+ *
4
+ * Android `String.valueOf(long)` -> "900", "-1" when length is unknown
5
+ * iOS `stringWithFormat:@"%lld"` -> "900", "-1" when length is unknown
6
+ * Windows `int64_t` / `JSValue` -> 900, null when length is unknown
7
+ *
8
+ * The public progress/uploadProgress callbacks are documented as receiving
9
+ * numbers, so normalise here rather than pushing the inconsistency onto every
10
+ * consumer. `-1` is the "unknown length" sentinel Android and iOS already use
11
+ * for chunked responses; Windows' null folds into it.
12
+ */
13
+ function toByteCount(value) {
14
+ if (value === null || value === undefined || value === '') return -1;
15
+ const count = Number(value);
16
+ return Number.isNaN(count) ? -1 : count;
17
+ }
18
+
19
+ export {toByteCount};
20
+ export default toByteCount;