@node-novel/normalize 1.0.33 → 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/dist/index.cjs ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') {
5
+ module.exports = require('./index.cjs.development.cjs')
6
+ } else {
7
+ module.exports = require('./index.cjs.production.min.cjs')
8
+ }
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
3
+ var strUtilTrim = require('@lazy-cjk/str-util-trim');
4
+ var zh2num = require('@lazy-cjk/zh2num');
5
+ var fullhalf = require('@lazy-cjk/fullhalf');
6
+ var normalizeNum = require('normalize-num');
7
+ var novelFilename = require('@lazy-cjk/novel-filename');
8
+ var zhSlugify = require('@lazy-cjk/zh-slugify');
9
+
10
+ function normalize_strip(str, isDir) {
11
+ if (isDir) {
12
+ if (/^p?\d{4,}[\s_](.+)(_\(\d+\))$/.exec(str)) {
13
+ str = RegExp.$1;
14
+ } else if (/^p?\d{4,}[\s_](.+)(_\(\d+\))?$/.exec(str)) {
15
+ str = RegExp.$1;
16
+ }
17
+ } else {
18
+ if (/^\d+_(.+)\.\d+$/.exec(str)) {
19
+ str = RegExp.$1;
20
+ } else if (/^c?\d{4,}_(.+)$/.exec(str)) {
21
+ str = RegExp.$1;
22
+ }
23
+ }
24
+ str = strUtilTrim.trim(str, ' ');
25
+ return str;
26
+ }
27
+ function normalize_val(str, padNum = 5, options = {}) {
28
+ padNum = padNum || options.padNum;
29
+ str = novelFilename.filename(str);
30
+ if (/^(?:序|プロローグ|Prologue)/i.test(str)) {
31
+ str = '0_' + str;
32
+ }
33
+ str = str.replace(/^(web)版(\d+)/i, '$1$2');
34
+ str = fullhalf.toHalfWidth(str).toLowerCase();
35
+ str = strUtilTrim.trim(str, ' ');
36
+ str = zh2num.zh2num(str).toString();
37
+ str = zh2num.zh2num(str, {
38
+ truncateOne: 2,
39
+ flags: 'ug'
40
+ }).toString();
41
+ str = normalizeNum.str2num(str, {
42
+ all: true,
43
+ roman: options.checkRoman
44
+ });
45
+ str = str.replace(/\d+/g, function ($0) {
46
+ return $0.padStart(padNum, '0');
47
+ });
48
+ str = str.replace(/^第+/, '').replace(/[―—-──\-―—─==―——─ー─]/g, '_').replace(/[\s ]/g, '_').replace(/[\(\)〔[【《(「『』」》)】〕]〔[〕]]/g, '_').replace(/[·‧・···•・·᛫•․‧∙⋅⸱⸳・ꞏ·‧・···•˙●‧﹒]/g, '_').replace(/[::︰﹕:︓∶:]/ug, '_').replace(/[・:,]/g, '_').replace(/_+$/g, '').replace(/_+/g, '_');
49
+ str = zhSlugify.slugify(str, true);
50
+ return str;
51
+ }
52
+ // @ts-ignore
53
+ {
54
+ Object.defineProperty(normalize_val, "__esModule", {
55
+ value: true
56
+ });
57
+ Object.defineProperty(normalize_val, 'normalize_val', {
58
+ value: normalize_val
59
+ });
60
+ Object.defineProperty(normalize_val, 'default', {
61
+ value: normalize_val
62
+ });
63
+ Object.defineProperty(normalize_val, 'normalize_strip', {
64
+ value: normalize_strip
65
+ });
66
+ }
67
+
68
+ // @ts-ignore
69
+ module.exports = normalize_val;
70
+ //# sourceMappingURL=index.cjs.development.cjs.map
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var e = require("@lazy-cjk/str-util-trim"), r = require("@lazy-cjk/zh2num"), l = require("@lazy-cjk/fullhalf"), a = require("normalize-num"), i = require("@lazy-cjk/novel-filename"), n = require("@lazy-cjk/zh-slugify");
4
+
5
+ function normalize_val(t, u = 5, c = {}) {
6
+ return u = u || c.padNum, t = i.filename(t), /^(?:序|プロローグ|Prologue)/i.test(t) && (t = "0_" + t),
7
+ t = t.replace(/^(web)版(\d+)/i, "$1$2"), t = l.toHalfWidth(t).toLowerCase(), t = e.trim(t, " "),
8
+ t = r.zh2num(t).toString(), t = r.zh2num(t, {
9
+ truncateOne: 2,
10
+ flags: "ug"
11
+ }).toString(), t = (t = (t = a.str2num(t, {
12
+ all: !0,
13
+ roman: c.checkRoman
14
+ })).replace(/\d+/g, (function(e) {
15
+ return e.padStart(u, "0");
16
+ }))).replace(/^第+/, "").replace(/[―—-──\-―—─==―——─ー─]/g, "_").replace(/[\s ]/g, "_").replace(/[\(\)〔[【《(「『』」》)】〕]〔[〕]]/g, "_").replace(/[·‧・···•・·᛫•․‧∙⋅⸱⸳・ꞏ·‧・···•˙●‧﹒]/g, "_").replace(/[::︰﹕:︓∶:]/gu, "_").replace(/[・:,]/g, "_").replace(/_+$/g, "").replace(/_+/g, "_"),
17
+ n.slugify(t, !0);
18
+ }
19
+
20
+ Object.defineProperty(normalize_val, "__esModule", {
21
+ value: !0
22
+ }), Object.defineProperty(normalize_val, "normalize_val", {
23
+ value: normalize_val
24
+ }), Object.defineProperty(normalize_val, "default", {
25
+ value: normalize_val
26
+ }), Object.defineProperty(normalize_val, "normalize_strip", {
27
+ value: function normalize_strip(r, l) {
28
+ return l ? (/^p?\d{4,}[\s_](.+)(_\(\d+\))$/.exec(r) || /^p?\d{4,}[\s_](.+)(_\(\d+\))?$/.exec(r)) && (r = RegExp.$1) : (/^\d+_(.+)\.\d+$/.exec(r) || /^c?\d{4,}_(.+)$/.exec(r)) && (r = RegExp.$1),
29
+ e.trim(r, " ");
30
+ }
31
+ }), module.exports = normalize_val;
32
+ //# sourceMappingURL=index.cjs.production.min.cjs.map
@@ -2,10 +2,14 @@
2
2
  * Created by user on 2018/2/14/014.
3
3
  */
4
4
  export interface IOptions {
5
- padNum?: number;
6
- checkRoman?: boolean;
5
+ padNum?: number;
6
+ checkRoman?: boolean;
7
7
  }
8
8
  export declare function normalize_strip(str: string, isDir?: boolean): string;
9
9
  export declare function normalize_val(str: string, padNum?: number, options?: IOptions): string;
10
- declare const _default: typeof import("./index");
11
- export default _default;
10
+
11
+ export {
12
+ normalize_val as default,
13
+ };
14
+
15
+ export {};
@@ -0,0 +1,34 @@
1
+ import { trim as e } from "@lazy-cjk/str-util-trim";
2
+
3
+ import { zh2num as r } from "@lazy-cjk/zh2num";
4
+
5
+ import { toHalfWidth as a } from "@lazy-cjk/fullhalf";
6
+
7
+ import { str2num as l } from "normalize-num";
8
+
9
+ import { filename as o } from "@lazy-cjk/novel-filename";
10
+
11
+ import { slugify as t } from "@lazy-cjk/zh-slugify";
12
+
13
+ function normalize_strip(r, a) {
14
+ return a ? (/^p?\d{4,}[\s_](.+)(_\(\d+\))$/.exec(r) || /^p?\d{4,}[\s_](.+)(_\(\d+\))?$/.exec(r)) && (r = RegExp.$1) : (/^\d+_(.+)\.\d+$/.exec(r) || /^c?\d{4,}_(.+)$/.exec(r)) && (r = RegExp.$1),
15
+ e(r, " ");
16
+ }
17
+
18
+ function normalize_val(c, p = 5, i = {}) {
19
+ return p = p || i.padNum, c = o(c), /^(?:序|プロローグ|Prologue)/i.test(c) && (c = "0_" + c),
20
+ c = c.replace(/^(web)版(\d+)/i, "$1$2"), c = a(c).toLowerCase(), c = e(c, " "), c = r(c).toString(),
21
+ c = r(c, {
22
+ truncateOne: 2,
23
+ flags: "ug"
24
+ }).toString(), c = (c = (c = l(c, {
25
+ all: !0,
26
+ roman: i.checkRoman
27
+ })).replace(/\d+/g, (function(e) {
28
+ return e.padStart(p, "0");
29
+ }))).replace(/^第+/, "").replace(/[―—-──\-―—─==―——─ー─]/g, "_").replace(/[\s ]/g, "_").replace(/[\(\)〔[【《(「『』」》)】〕]〔[〕]]/g, "_").replace(/[·‧・···•・·᛫•․‧∙⋅⸱⸳・ꞏ·‧・···•˙●‧﹒]/g, "_").replace(/[::︰﹕:︓∶:]/gu, "_").replace(/[・:,]/g, "_").replace(/_+$/g, "").replace(/_+/g, "_"),
30
+ t(c, !0);
31
+ }
32
+
33
+ export { normalize_val as default, normalize_strip, normalize_val };
34
+ //# sourceMappingURL=index.esm.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-novel/normalize",
3
- "version": "1.0.33",
3
+ "version": "2.0.0",
4
4
  "description": "normalize file name for sort",
5
5
  "keywords": [
6
6
  "@node-novel",
@@ -9,7 +9,9 @@
9
9
  "node-novel",
10
10
  "normalize",
11
11
  "sort",
12
- "strip"
12
+ "strip",
13
+ "create-by-yarn-tool",
14
+ "create-by-tsdx"
13
15
  ],
14
16
  "homepage": "https://github.com/bluelovers/ws-node-novel/tree/master/packages/node-novel-normalize#readme",
15
17
  "bugs": {
@@ -22,34 +24,70 @@
22
24
  },
23
25
  "license": "ISC",
24
26
  "author": "bluelovers",
25
- "main": "index.js",
27
+ "sideEffects": false,
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "require": "./dist/index.cjs",
32
+ "import": "./dist/index.esm.mjs"
33
+ },
34
+ "./package.json": "./package.json",
35
+ "./src/*": "./src/*"
36
+ },
37
+ "main": "dist/index.cjs",
38
+ "unpkg": "dist/index.umd.production.min.cjs",
39
+ "module": "dist/index.esm.mjs",
40
+ "types": "dist/index.d.ts",
41
+ "typings": "dist/index.d.ts",
26
42
  "directories": {
27
43
  "test": "test"
28
44
  },
29
45
  "scripts": {
30
46
  "coverage": "yarn run test -- --coverage",
47
+ "pretest": "echo pretest",
31
48
  "test": "jest",
32
49
  "test:jest": "jest --passWithNoTests",
50
+ "test:jest:coverage": "yarn run test:jest -- --coverage",
33
51
  "test:jest:snapshot": "yarn run test:jest -- -u",
34
52
  "test:snapshot": "yarn run test -- -u",
35
53
  "test:tsd": "ynpx tsd",
54
+ "posttest": "yarn run build",
55
+ "build": "yarn run build:tsdx && yarn run build:dts:bundle",
56
+ "build:dts:bundle": "ynpx @bluelovers/dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner --inline-declare-global & echo build:dts:bundle",
57
+ "build:dts:copy": "copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts",
58
+ "build:dts:tsc": "yarn run build:dts:copy && yarn run build:dts:tsc:emit && yarn run build:dts:copy",
59
+ "build:dts:tsc:emit": "tsc --emitDeclarationOnly --declaration --noEmit false",
60
+ "build:tsdx": "ynpx @bluelovers/tsdx build --target node",
61
+ "ci:install": "echo ci:install",
62
+ "ci:build": "echo ci:build",
36
63
  "npm:publish": "npm publish",
37
64
  "npm:publish:lerna": "npx lerna publish --yes --cd-version patch",
38
65
  "preversion": "yarn run test",
66
+ "version": "echo version",
67
+ "postversion": "echo postversion",
68
+ "prepublish": "echo prepublish",
39
69
  "prepublish:lockfile": "npx sync-lockfile .",
70
+ "prepare": "echo prepare",
71
+ "prepublishOnly": "echo prepublishOnly",
72
+ "prepack": "echo prepack",
73
+ "pack": "echo pack",
74
+ "postpack": "echo postpack",
75
+ "publish": "echo publish",
76
+ "postpublish": "echo postpublish",
40
77
  "postpublish_": "git commit -m \"chore(release): publish\" .",
78
+ "postpublishOnly": "echo postpublishOnly",
41
79
  "ncu": "npx yarn-tool ncu -u",
42
- "sort-package-json": "npx yarn-tool sort"
80
+ "sort-package-json": "npx yarn-tool sort",
81
+ "tsc:showConfig": "ynpx get-current-tsconfig -p"
43
82
  },
44
83
  "dependencies": {
45
- "@lazy-cjk/novel-filename": "^1.0.51",
46
- "@lazy-cjk/zh-slugify": "^1.0.87",
84
+ "@lazy-cjk/novel-filename": "^1.0.53",
85
+ "@lazy-cjk/zh-slugify": "^1.0.89",
47
86
  "normalize-num": "^1.0.16",
48
- "str-util": "^3.0.2",
49
- "tslib": "^2"
87
+ "str-util": "^3.0.2"
50
88
  },
51
89
  "publishConfig": {
52
90
  "access": "public"
53
91
  },
54
- "gitHead": "b2b758eb863a93ab885d36a71589d1da4bb2635b"
92
+ "gitHead": "f655723796683dc127d290d13d4106f21279bdae"
55
93
  }
package/src/index.cts ADDED
@@ -0,0 +1,4 @@
1
+ import _ from './index';
2
+
3
+ // @ts-ignore
4
+ export = _
package/src/index.ts ADDED
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Created by user on 2018/2/14/014.
3
+ */
4
+
5
+ import { trim as strUtilTrim } from '@lazy-cjk/str-util-trim';
6
+ import { zh2num } from '@lazy-cjk/zh2num';
7
+ import { toHalfWidth } from '@lazy-cjk/fullhalf';
8
+ import { str2num } from 'normalize-num';
9
+ import { filename as novelFilename } from '@lazy-cjk/novel-filename';
10
+ import { slugify } from '@lazy-cjk/zh-slugify';
11
+
12
+ export interface IOptions
13
+ {
14
+ padNum?: number,
15
+ checkRoman?: boolean,
16
+ }
17
+
18
+ export function normalize_strip(str: string, isDir?: boolean)
19
+ {
20
+ if (isDir)
21
+ {
22
+ if (/^p?\d{4,}[\s_](.+)(_\(\d+\))$/.exec(str))
23
+ {
24
+ str = RegExp.$1;
25
+ }
26
+ else if (/^p?\d{4,}[\s_](.+)(_\(\d+\))?$/.exec(str))
27
+ {
28
+ str = RegExp.$1;
29
+ }
30
+ }
31
+ else
32
+ {
33
+ if (/^\d+_(.+)\.\d+$/.exec(str))
34
+ {
35
+ str = RegExp.$1;
36
+ }
37
+ else if (/^c?\d{4,}_(.+)$/.exec(str))
38
+ {
39
+ str = RegExp.$1;
40
+ }
41
+ }
42
+
43
+ str = strUtilTrim(str, ' ');
44
+
45
+ return str;
46
+ }
47
+
48
+ export function normalize_val(str: string, padNum: number = 5, options: IOptions = {}): string
49
+ {
50
+ padNum = padNum || options.padNum;
51
+
52
+ //console.log(111, str);
53
+
54
+ str = novelFilename(str);
55
+
56
+ if (/^(?:序|プロローグ|Prologue)/i.test(str))
57
+ {
58
+ str = '0_' + str;
59
+ }
60
+
61
+ str = str.replace(/^(web)版(\d+)/i, '$1$2');
62
+
63
+ //str = str.replace(/^[cp](\d{4,}_)/, '$1');
64
+
65
+ str = toHalfWidth(str)
66
+ .toLowerCase()
67
+ ;
68
+ str = strUtilTrim(str, ' ');
69
+
70
+ str = zh2num(str).toString();
71
+
72
+ str = zh2num(str, {
73
+ truncateOne: 2,
74
+ flags: 'ug',
75
+ }).toString();
76
+
77
+ //console.log(str);
78
+
79
+ str = str2num(str, {
80
+ all: true,
81
+ roman: options.checkRoman,
82
+ });
83
+
84
+ /*
85
+ if (options.checkRoman)
86
+ {
87
+ let m = isRoman(str);
88
+
89
+ if (m)
90
+ {
91
+ let n = deromanize(normalizeRoman(m[1]));
92
+ str = n.toString() + str.slice(m[1].length);
93
+ //console.log(m[1], n, str);
94
+ }
95
+ }
96
+
97
+ str = circle2num(str);
98
+ */
99
+
100
+ str = str.replace(/\d+/g, function ($0)
101
+ {
102
+ return $0.padStart(padNum, '0');
103
+ });
104
+
105
+ str = str
106
+ .replace(/^第+/, '')
107
+ //.replace(/(\d)[章話]/g, '$1_')
108
+ //.replace(/第(\d)/g, '_$1')
109
+ //.replace(/\./g, '_')
110
+ .replace(/[―—-──\-―—─==―——─ー─]/g, '_')
111
+ .replace(/[\s ]/g, '_')
112
+ .replace(/[\(\)〔[【《(「『』」》)】〕]〔[〕]]/g, '_')
113
+ .replace(/[·‧・···•・·᛫•․‧∙⋅⸱⸳・ꞏ·‧・···•˙●‧﹒]/g, '_')
114
+ .replace(/[::︰﹕:︓∶:]/ug, '_')
115
+ .replace(/[・:,]/g, '_')
116
+ .replace(/_+$/g, '')
117
+ .replace(/_+/g, '_')
118
+
119
+ ;
120
+
121
+ /*
122
+ str = zh2jp(cn2tw(str) as string, {
123
+ safe: false,
124
+ });
125
+ */
126
+
127
+ /*
128
+ str = zhTable.auto(cn2tw(str, {
129
+ safe: false,
130
+ // @ts-ignore
131
+ greedyTable: true,
132
+ }), {
133
+ safe: false,
134
+ // @ts-ignore
135
+ greedyTable: true,
136
+ })[0];
137
+ */
138
+
139
+ str = slugify(str, true);
140
+
141
+ return str;
142
+ }
143
+
144
+ // @ts-ignore
145
+ if (process.env.TSDX_FORMAT !== 'esm')
146
+ {
147
+ Object.defineProperty(normalize_val, "__esModule", { value: true });
148
+
149
+ Object.defineProperty(normalize_val, 'normalize_val', { value: normalize_val });
150
+ Object.defineProperty(normalize_val, 'default', { value: normalize_val });
151
+
152
+ Object.defineProperty(normalize_val, 'normalize_strip', { value: normalize_strip });
153
+
154
+ }
155
+
156
+ export default normalize_val;
package/index.js DELETED
@@ -1,109 +0,0 @@
1
- "use strict";
2
- /**
3
- * Created by user on 2018/2/14/014.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.normalize_val = exports.normalize_strip = void 0;
7
- const tslib_1 = require("tslib");
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");
12
- const novel_filename_1 = tslib_1.__importDefault(require("@lazy-cjk/novel-filename"));
13
- const zh_slugify_1 = require("@lazy-cjk/zh-slugify");
14
- function normalize_strip(str, isDir) {
15
- if (isDir) {
16
- if (/^p?\d{4,}[\s_](.+)(_\(\d+\))$/.exec(str)) {
17
- str = RegExp.$1;
18
- }
19
- else if (/^p?\d{4,}[\s_](.+)(_\(\d+\))?$/.exec(str)) {
20
- str = RegExp.$1;
21
- }
22
- }
23
- else {
24
- if (/^\d+_(.+)\.\d+$/.exec(str)) {
25
- str = RegExp.$1;
26
- }
27
- else if (/^c?\d{4,}_(.+)$/.exec(str)) {
28
- str = RegExp.$1;
29
- }
30
- }
31
- str = (0, str_util_trim_1.trim)(str, ' ');
32
- return str;
33
- }
34
- exports.normalize_strip = normalize_strip;
35
- function normalize_val(str, padNum = 5, options = {}) {
36
- padNum = padNum || options.padNum;
37
- //console.log(111, str);
38
- str = novel_filename_1.default.filename(str);
39
- if (/^(?:序|プロローグ|Prologue)/i.test(str)) {
40
- str = '0_' + str;
41
- }
42
- str = str.replace(/^(web)版(\d+)/i, '$1$2');
43
- //str = str.replace(/^[cp](\d{4,}_)/, '$1');
44
- str = (0, fullhalf_1.toHalfWidth)(str)
45
- .toLowerCase();
46
- str = (0, str_util_trim_1.trim)(str, ' ');
47
- str = (0, zh2num_1.zh2num)(str).toString();
48
- str = (0, zh2num_1.zh2num)(str, {
49
- truncateOne: 2,
50
- flags: 'ug',
51
- }).toString();
52
- //console.log(str);
53
- str = (0, normalize_num_1.str2num)(str, {
54
- all: true,
55
- roman: options.checkRoman,
56
- });
57
- /*
58
- if (options.checkRoman)
59
- {
60
- let m = isRoman(str);
61
-
62
- if (m)
63
- {
64
- let n = deromanize(normalizeRoman(m[1]));
65
- str = n.toString() + str.slice(m[1].length);
66
- //console.log(m[1], n, str);
67
- }
68
- }
69
-
70
- str = circle2num(str);
71
- */
72
- str = str.replace(/\d+/g, function ($0) {
73
- return $0.padStart(padNum, '0');
74
- });
75
- str = str
76
- .replace(/^第+/, '')
77
- //.replace(/(\d)[章話]/g, '$1_')
78
- //.replace(/第(\d)/g, '_$1')
79
- //.replace(/\./g, '_')
80
- .replace(/[―—-──\-―—─==―——─ー─]/g, '_')
81
- .replace(/[\s ]/g, '_')
82
- .replace(/[\(\)〔[【《(「『』」》)】〕]〔[〕]]/g, '_')
83
- .replace(/[·‧・···•・·᛫•․‧∙⋅⸱⸳・ꞏ·‧・···•˙●‧﹒]/g, '_')
84
- .replace(/[::︰﹕:︓∶:]/ug, '_')
85
- .replace(/[・:,]/g, '_')
86
- .replace(/_+$/g, '')
87
- .replace(/_+/g, '_');
88
- /*
89
- str = zh2jp(cn2tw(str) as string, {
90
- safe: false,
91
- });
92
- */
93
- /*
94
- str = zhTable.auto(cn2tw(str, {
95
- safe: false,
96
- // @ts-ignore
97
- greedyTable: true,
98
- }), {
99
- safe: false,
100
- // @ts-ignore
101
- greedyTable: true,
102
- })[0];
103
- */
104
- str = (0, zh_slugify_1.slugify)(str, true);
105
- return str;
106
- }
107
- exports.normalize_val = normalize_val;
108
- exports.default = exports;
109
- //# sourceMappingURL=index.js.map
package/index.js.map DELETED
@@ -1 +0,0 @@
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,CA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im } 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"]}