@guanghechen/filepart 1.0.4 → 2.0.0
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/README.md +71 -0
- package/lib/cjs/index.cjs +3 -7
- package/lib/esm/index.mjs +3 -2
- package/lib/types/index.d.ts +21 -3
- package/package.json +12 -6
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<header>
|
|
2
|
+
<h1 align="center">
|
|
3
|
+
<a href="https://github.com/guanghechen/sora/tree/@guanghechen/filepart@2.0.0/packages/filepart#readme">@guanghechen/filepart</a>
|
|
4
|
+
</h1>
|
|
5
|
+
<div align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@guanghechen/filepart">
|
|
7
|
+
<img
|
|
8
|
+
alt="Npm Version"
|
|
9
|
+
src="https://img.shields.io/npm/v/@guanghechen/filepart.svg"
|
|
10
|
+
/>
|
|
11
|
+
</a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/@guanghechen/filepart">
|
|
13
|
+
<img
|
|
14
|
+
alt="Npm Download"
|
|
15
|
+
src="https://img.shields.io/npm/dm/@guanghechen/filepart.svg"
|
|
16
|
+
/>
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://www.npmjs.com/package/@guanghechen/filepart">
|
|
19
|
+
<img
|
|
20
|
+
alt="Npm License"
|
|
21
|
+
src="https://img.shields.io/npm/l/@guanghechen/filepart.svg"
|
|
22
|
+
/>
|
|
23
|
+
</a>
|
|
24
|
+
<a href="#install">
|
|
25
|
+
<img
|
|
26
|
+
alt="Module Formats: cjs, esm"
|
|
27
|
+
src="https://img.shields.io/badge/module_formats-cjs%2C%20esm-green.svg"
|
|
28
|
+
/>
|
|
29
|
+
</a>
|
|
30
|
+
<a href="https://github.com/nodejs/node">
|
|
31
|
+
<img
|
|
32
|
+
alt="Node.js Version"
|
|
33
|
+
src="https://img.shields.io/node/v/@guanghechen/filepart"
|
|
34
|
+
/>
|
|
35
|
+
</a>
|
|
36
|
+
<a href="https://github.com/facebook/jest">
|
|
37
|
+
<img
|
|
38
|
+
alt="Tested with Jest"
|
|
39
|
+
src="https://img.shields.io/badge/tested_with-jest-9c465e.svg"
|
|
40
|
+
/>
|
|
41
|
+
</a>
|
|
42
|
+
<a href="https://github.com/prettier/prettier">
|
|
43
|
+
<img
|
|
44
|
+
alt="Code Style: prettier"
|
|
45
|
+
src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"
|
|
46
|
+
/>
|
|
47
|
+
</a>
|
|
48
|
+
</div>
|
|
49
|
+
</header>
|
|
50
|
+
<br/>
|
|
51
|
+
|
|
52
|
+
File helper utilities for splitting files and merging streams.
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
- npm
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install --save @guanghechen/filepart
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- yarn
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
yarn add @guanghechen/filepart
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
|
|
70
|
+
[homepage]:
|
|
71
|
+
https://github.com/guanghechen/sora/tree/@guanghechen/filepart@2.0.0/packages/filepart#readme
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var invariant = require('@guanghechen/invariant');
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const DEFAULT_FILEPART_CODE_PREFIX = '.ghc-part';
|
|
5
6
|
|
|
6
7
|
function* calcFilePartItemsBySize(fileSize, partSize) {
|
|
7
8
|
if (fileSize <= 0) {
|
|
@@ -74,13 +75,8 @@ function* calcFilePartNamesByCount(partTotal, partCodePrefix) {
|
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
|
|
78
|
+
exports.DEFAULT_FILEPART_CODE_PREFIX = DEFAULT_FILEPART_CODE_PREFIX;
|
|
77
79
|
exports.calcFilePartItemsByCount = calcFilePartItemsByCount;
|
|
78
80
|
exports.calcFilePartItemsBySize = calcFilePartItemsBySize;
|
|
79
81
|
exports.calcFilePartNames = calcFilePartNames;
|
|
80
82
|
exports.calcFilePartNamesByCount = calcFilePartNamesByCount;
|
|
81
|
-
Object.keys(filepart_types).forEach(function (k) {
|
|
82
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
83
|
-
enumerable: true,
|
|
84
|
-
get: function () { return filepart_types[k]; }
|
|
85
|
-
});
|
|
86
|
-
});
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { invariant } from '@guanghechen/invariant';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
const DEFAULT_FILEPART_CODE_PREFIX = '.ghc-part';
|
|
3
4
|
|
|
4
5
|
function* calcFilePartItemsBySize(fileSize, partSize) {
|
|
5
6
|
if (fileSize <= 0) {
|
|
@@ -72,4 +73,4 @@ function* calcFilePartNamesByCount(partTotal, partCodePrefix) {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
export { calcFilePartItemsByCount, calcFilePartItemsBySize, calcFilePartNames, calcFilePartNamesByCount };
|
|
76
|
+
export { DEFAULT_FILEPART_CODE_PREFIX, calcFilePartItemsByCount, calcFilePartItemsBySize, calcFilePartNames, calcFilePartNamesByCount };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const DEFAULT_FILEPART_CODE_PREFIX = ".ghc-part";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An part item of file.
|
|
5
|
+
*/
|
|
6
|
+
interface IFilePartItem {
|
|
7
|
+
/**
|
|
8
|
+
* Sequence no of a part.
|
|
9
|
+
*/
|
|
10
|
+
sid: number;
|
|
11
|
+
/**
|
|
12
|
+
* Start position of a part in sourcefile.
|
|
13
|
+
*/
|
|
14
|
+
start: number;
|
|
15
|
+
/**
|
|
16
|
+
* End position of a part in sourcefile.
|
|
17
|
+
*/
|
|
18
|
+
end: number;
|
|
19
|
+
}
|
|
3
20
|
|
|
4
21
|
/**
|
|
5
22
|
* Generate file part items by part size.
|
|
@@ -27,4 +44,5 @@ declare function calcFilePartItemsByCount(fileSize: number, partTotal: number):
|
|
|
27
44
|
declare function calcFilePartNames(parts: ReadonlyArray<Pick<IFilePartItem, 'sid'>>, partCodePrefix: string): IterableIterator<string>;
|
|
28
45
|
declare function calcFilePartNamesByCount(partTotal: number, partCodePrefix: string): IterableIterator<string>;
|
|
29
46
|
|
|
30
|
-
export { calcFilePartItemsByCount, calcFilePartItemsBySize, calcFilePartNames, calcFilePartNamesByCount };
|
|
47
|
+
export { DEFAULT_FILEPART_CODE_PREFIX, calcFilePartItemsByCount, calcFilePartItemsBySize, calcFilePartNames, calcFilePartNamesByCount };
|
|
48
|
+
export type { IFilePartItem };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guanghechen/filepart",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "File helper",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "guanghechen",
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/guanghechen/sora/tree/@guanghechen/filepart@1.0.
|
|
11
|
+
"url": "https://github.com/guanghechen/sora/tree/@guanghechen/filepart@1.0.4",
|
|
12
12
|
"directory": "packages/filepart"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/filepart@1.0.
|
|
14
|
+
"homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/filepart@1.0.4/packages/filepart#readme",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"file helper",
|
|
17
17
|
"split file",
|
|
@@ -31,6 +31,13 @@
|
|
|
31
31
|
"module": "./lib/esm/index.mjs",
|
|
32
32
|
"types": "./lib/types/index.d.ts",
|
|
33
33
|
"license": "MIT",
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "rollup -c ../../rollup.config.mjs",
|
|
36
|
+
"clean": "rimraf lib",
|
|
37
|
+
"test": "vitest run --config ../../vitest.config.ts",
|
|
38
|
+
"test:coverage": "vitest run --config ../../vitest.config.ts --coverage",
|
|
39
|
+
"test:update": "vitest run --config ../../vitest.config.ts -u"
|
|
40
|
+
},
|
|
34
41
|
"files": [
|
|
35
42
|
"lib/",
|
|
36
43
|
"!lib/**/*.map",
|
|
@@ -40,8 +47,7 @@
|
|
|
40
47
|
"README.md"
|
|
41
48
|
],
|
|
42
49
|
"dependencies": {
|
|
43
|
-
"@guanghechen/
|
|
44
|
-
"@guanghechen/invariant": "^6.0.5"
|
|
50
|
+
"@guanghechen/invariant": "^7.0.0"
|
|
45
51
|
},
|
|
46
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "12990a720b31d50d217e2e17a6191256dc94eda6"
|
|
47
53
|
}
|