@node-novel/normalize 1.0.32 → 1.0.33
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/CHANGELOG.md +10 -0
- package/index.js +10 -8
- package/index.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.33](https://github.com/bluelovers/ws-node-novel/compare/@node-novel/normalize@1.0.32...@node-novel/normalize@1.0.33) (2024-02-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### 📦 Code Refactoring
|
|
11
|
+
|
|
12
|
+
* update import ([489012e](https://github.com/bluelovers/ws-node-novel/commit/489012e46d35eae5d7c26d18dc6ad306ec869773))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
6
16
|
## [1.0.32](https://github.com/bluelovers/ws-node-novel/compare/@node-novel/normalize@1.0.31...@node-novel/normalize@1.0.32) (2024-01-29)
|
|
7
17
|
|
|
8
18
|
|
package/index.js
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.normalize_val = exports.normalize_strip = void 0;
|
|
7
7
|
const tslib_1 = require("tslib");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const str_util_trim_1 = require("@lazy-cjk/str-util-trim");
|
|
9
|
+
const zh2num_1 = require("@lazy-cjk/zh2num");
|
|
10
|
+
const fullhalf_1 = require("@lazy-cjk/fullhalf");
|
|
11
|
+
const normalize_num_1 = require("normalize-num");
|
|
10
12
|
const novel_filename_1 = tslib_1.__importDefault(require("@lazy-cjk/novel-filename"));
|
|
11
13
|
const zh_slugify_1 = require("@lazy-cjk/zh-slugify");
|
|
12
14
|
function normalize_strip(str, isDir) {
|
|
@@ -26,7 +28,7 @@ function normalize_strip(str, isDir) {
|
|
|
26
28
|
str = RegExp.$1;
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
|
-
str =
|
|
31
|
+
str = (0, str_util_trim_1.trim)(str, ' ');
|
|
30
32
|
return str;
|
|
31
33
|
}
|
|
32
34
|
exports.normalize_strip = normalize_strip;
|
|
@@ -39,16 +41,16 @@ function normalize_val(str, padNum = 5, options = {}) {
|
|
|
39
41
|
}
|
|
40
42
|
str = str.replace(/^(web)版(\d+)/i, '$1$2');
|
|
41
43
|
//str = str.replace(/^[cp](\d{4,}_)/, '$1');
|
|
42
|
-
str =
|
|
44
|
+
str = (0, fullhalf_1.toHalfWidth)(str)
|
|
43
45
|
.toLowerCase();
|
|
44
|
-
str =
|
|
45
|
-
str =
|
|
46
|
-
str =
|
|
46
|
+
str = (0, str_util_trim_1.trim)(str, ' ');
|
|
47
|
+
str = (0, zh2num_1.zh2num)(str).toString();
|
|
48
|
+
str = (0, zh2num_1.zh2num)(str, {
|
|
47
49
|
truncateOne: 2,
|
|
48
50
|
flags: 'ug',
|
|
49
51
|
}).toString();
|
|
50
52
|
//console.log(str);
|
|
51
|
-
str = (0, normalize_num_1.
|
|
53
|
+
str = (0, normalize_num_1.str2num)(str, {
|
|
52
54
|
all: true,
|
|
53
55
|
roman: options.checkRoman,
|
|
54
56
|
});
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAGH,2DAA8D;AAC9D,6CAAkD;AAClD,iDAAwH;AAExH,iDAAwC;AAExC,sFAAqD;AACrD,qDAA+C;AAQ/C,SAAgB,eAAe,CAAC,GAAW,EAAE,KAAe;IAE3D,IAAI,KAAK,EACT,CAAC;QACA,IAAI,+BAA+B,C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,eAAM,EAAC,GAAG,EAAE;QACjB,WAAW,EAAE,CAAC;QACd,KAAK,EAAE,IAAI;KACX,CAAC,CAAC,QAAQ,EAAE,CAAC;IAEd,mBAAmB;IAEnB,GAAG,GAAG,IAAA,uBAAO,EAAC,GAAG,EAAE;QAClB,GAAG,EAAE,IAAI;QACT,KAAK,EAAE,OAAO,CAAC,UAAU;KACzB,CAAC,CAAC;IAEH;;;;;;;;;;;;;;MAcE;IAEF,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE;QAErC,OAAO,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,GAAG,GAAG,GAAG;SACP,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;QACnB,8BAA8B;QAC9B,2BAA2B;QAC3B,sBAAsB;SACrB,OAAO,CAAC,uBAAuB,EAAE,GAAG,CAAC;SACrC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,2BAA2B,EAAE,GAAG,CAAC;SACzC,OAAO,CAAC,mCAAmC,EAAE,GAAG,CAAC;SACjD,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC;SAC5B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAEpB;IAED;;;;MAIE;IAEF;;;;;;;;;;MAUE;IAEF,GAAG,GAAG,IAAA,oBAAO,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAEzB,OAAO,GAAG,CAAC;AACZ,CAAC;AA9FD,sCA8FC;AAED,kBAAe,OAAmC,CAAC","sourcesContent":["/**\n * Created by user on 2018/2/14/014.\n */\n\nimport StrUtil from 'str-util';\nimport { trim as strUtilTrim } from '@lazy-cjk/str-util-trim';\nimport { zh2num, num2zh } from '@lazy-cjk/zh2num';\nimport { toFullNumber, toHalfNumber, toFullEnglish, toHalfEnglish, toFullWidth, toHalfWidth } from '@lazy-cjk/fullhalf';\n\nimport { str2num } from 'normalize-num';\n\nimport novelFilename from '@lazy-cjk/novel-filename';\nimport { slugify } from '@lazy-cjk/zh-slugify';\n\nexport interface IOptions\n{\n\tpadNum?: number,\n\tcheckRoman?: boolean,\n}\n\nexport function normalize_strip(str: string, isDir?: boolean)\n{\n\tif (isDir)\n\t{\n\t\tif (/^p?\\d{4,}[\\s_](.+)(_\\(\\d+\\))$/.exec(str))\n\t\t{\n\t\t\tstr = RegExp.$1;\n\t\t}\n\t\telse if (/^p?\\d{4,}[\\s_](.+)(_\\(\\d+\\))?$/.exec(str))\n\t\t{\n\t\t\tstr = RegExp.$1;\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (/^\\d+_(.+)\\.\\d+$/.exec(str))\n\t\t{\n\t\t\tstr = RegExp.$1;\n\t\t}\n\t\telse if (/^c?\\d{4,}_(.+)$/.exec(str))\n\t\t{\n\t\t\tstr = RegExp.$1;\n\t\t}\n\t}\n\n\tstr = strUtilTrim(str, ' ');\n\n\treturn str;\n}\n\nexport function normalize_val(str: string, padNum: number = 5, options: IOptions = {}): string\n{\n\tpadNum = padNum || options.padNum;\n\n\t//console.log(111, str);\n\n\tstr = novelFilename.filename(str);\n\n\tif (/^(?:序|プロローグ|Prologue)/i.test(str))\n\t{\n\t\tstr = '0_' + str;\n\t}\n\n\tstr = str.replace(/^(web)版(\\d+)/i, '$1$2');\n\n\t//str = str.replace(/^[cp](\\d{4,}_)/, '$1');\n\n\tstr = toHalfWidth(str)\n\t\t.toLowerCase()\n\t;\n\tstr = strUtilTrim(str, ' ');\n\n\tstr = zh2num(str).toString();\n\n\tstr = zh2num(str, {\n\t\ttruncateOne: 2,\n\t\tflags: 'ug',\n\t}).toString();\n\n\t//console.log(str);\n\n\tstr = str2num(str, {\n\t\tall: true,\n\t\troman: options.checkRoman,\n\t});\n\n\t/*\n\tif (options.checkRoman)\n\t{\n\t\tlet m = isRoman(str);\n\n\t\tif (m)\n\t\t{\n\t\t\tlet n = deromanize(normalizeRoman(m[1]));\n\t\t\tstr = n.toString() + str.slice(m[1].length);\n\t\t\t//console.log(m[1], n, str);\n\t\t}\n\t}\n\n\tstr = circle2num(str);\n\t*/\n\n\tstr = str.replace(/\\d+/g, function ($0)\n\t{\n\t\treturn $0.padStart(padNum, '0');\n\t});\n\n\tstr = str\n\t\t.replace(/^第+/, '')\n\t\t//.replace(/(\\d)[章話]/g, '$1_')\n\t\t//.replace(/第(\\d)/g, '_$1')\n\t\t//.replace(/\\./g, '_')\n\t\t.replace(/[―—-──\\-―—─==―——─ー─]/g, '_')\n\t\t.replace(/[\\s ]/g, '_')\n\t\t.replace(/[\\(\\)〔[【《(「『』」》)】〕]〔[〕]]/g, '_')\n\t\t.replace(/[·‧・···•・·᛫•․‧∙⋅⸱⸳・ꞏ·‧・···•˙●‧﹒]/g, '_')\n\t\t.replace(/[::︰﹕:︓∶:]/ug, '_')\n\t\t.replace(/[・:,]/g, '_')\n\t\t.replace(/_+$/g, '')\n\t\t.replace(/_+/g, '_')\n\n\t;\n\n\t/*\n\tstr = zh2jp(cn2tw(str) as string, {\n\t\tsafe: false,\n\t});\n\t*/\n\n\t/*\n\tstr = zhTable.auto(cn2tw(str, {\n\t\tsafe: false,\n\t\t// @ts-ignore\n\t\tgreedyTable: true,\n\t}), {\n\t\tsafe: false,\n\t\t// @ts-ignore\n\t\tgreedyTable: true,\n\t})[0];\n\t*/\n\n\tstr = slugify(str, true);\n\n\treturn str;\n}\n\nexport default exports as typeof import('./index');\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-novel/normalize",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
4
4
|
"description": "normalize file name for sort",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@node-novel",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"sort-package-json": "npx yarn-tool sort"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@lazy-cjk/novel-filename": "^1.0.
|
|
46
|
-
"@lazy-cjk/zh-slugify": "^1.0.
|
|
45
|
+
"@lazy-cjk/novel-filename": "^1.0.51",
|
|
46
|
+
"@lazy-cjk/zh-slugify": "^1.0.87",
|
|
47
47
|
"normalize-num": "^1.0.16",
|
|
48
|
-
"str-util": "^3.0.
|
|
48
|
+
"str-util": "^3.0.2",
|
|
49
49
|
"tslib": "^2"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "b2b758eb863a93ab885d36a71589d1da4bb2635b"
|
|
55
55
|
}
|