Skip to content

Commit d17ed94

Browse files
authored
Merge pull request #115 from samchon/features/esm
Adjust prettier
2 parents b620c76 + 3369f99 commit d17ed94

File tree

244 files changed

+20802
-21266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

244 files changed

+20802
-21266
lines changed

.prettierignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
{
2-
// Use IntelliSense to learn about possible Node.js debug attributes.
3-
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5-
"version": "0.2.0",
6-
"configurations": [
7-
{
8-
"type": "node",
9-
"request": "launch",
10-
"name": "TypeScript Test using TS-NODE",
11-
"runtimeArgs": [
12-
"-r",
13-
"ts-node/register"
14-
],
15-
"args": [
16-
"${workspaceRoot}/src/test/index.ts"
17-
]
18-
},
19-
{
20-
"type": "node",
21-
"request": "launch",
22-
"name": "JavaScript Test using SourceMap",
23-
"program": "${workspaceRoot}/test/index.js",
24-
"cwd": "${workspaceRoot}",
25-
26-
// TypeScript
27-
"sourceMaps": true,
28-
"outFiles": ["${workspaceRot}/**.js"]
29-
}
30-
]
2+
// Use IntelliSense to learn about possible Node.js debug attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "TypeScript Test using TS-NODE",
11+
"runtimeArgs": [
12+
"-r",
13+
"ts-node/register"
14+
],
15+
"args": [
16+
"${workspaceRoot}/src/test/index.ts"
17+
]
18+
},
19+
{
20+
"type": "node",
21+
"request": "launch",
22+
"name": "JavaScript Test using SourceMap",
23+
"program": "${workspaceRoot}/test/index.js",
24+
"cwd": "${workspaceRoot}",
25+
// TypeScript
26+
"sourceMaps": true,
27+
"outFiles": [
28+
"${workspaceRot}/**.js"
29+
]
30+
}
31+
]
3132
}

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"editor.tabSize": 2,
3+
"editor.formatOnSave": true,
4+
"[typescript][javascript][json]": {
5+
"editor.defaultFormatter": "esbenp.prettier-vscode",
6+
"editor.codeActionsOnSave": {
7+
"source.fixAll.eslint": "explicit"
8+
},
9+
}
10+
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@
2121
"benchmark": "node benchmark",
2222
"build": "rimraf lib && tsc && rollup -c",
2323
"dev": "rimraf lib && tsc --watch",
24-
"prettier": "prettier --write ./src",
24+
"prettier": "prettier --write ./src/**/*.ts",
2525
"test": "node lib/test"
2626
},
2727
"devDependencies": {
2828
"@rollup/plugin-terser": "^0.4.4",
2929
"@rollup/plugin-typescript": "^11.1.6",
30+
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
3031
"@types/cli": "^0.11.19",
3132
"@types/node": "^14.6.3",
3233
"cli": "^1.0.1",
33-
"prettier": "^2.7.1",
34+
"prettier": "^2.8.8",
3435
"rimraf": "^3.0.2",
3536
"rollup": "^4.13.1",
3637
"source-map-support": "^0.5.21",

prettier.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
parser: "typescript",
3+
printWidth: 80,
4+
semi: true,
5+
tabWidth: 2,
6+
trailingComma: "all",
7+
plugins: [require.resolve("@trivago/prettier-plugin-sort-imports")],
8+
importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"],
9+
importOrderSeparation: true,
10+
importOrderSortSpecifiers: true,
11+
importOrderParserPlugins: ["decorators-legacy", "typescript"],
12+
};

rollup.config.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
const typescript = require('@rollup/plugin-typescript');
2-
const terser = require('@rollup/plugin-terser');
1+
const typescript = require("@rollup/plugin-typescript");
2+
const terser = require("@rollup/plugin-terser");
33

44
module.exports = {
5-
input: './src/index.ts',
6-
output: {
7-
dir: 'lib',
8-
format: 'esm',
9-
entryFileNames: '[name].mjs',
10-
sourcemap: true,
11-
},
12-
plugins: [
13-
typescript({
14-
tsconfig: "tsconfig.json",
15-
module: "ES2020",
16-
target: "ES2020",
17-
}),
18-
terser({
19-
format: {
20-
comments: 'some',
21-
beautify: true,
22-
ecma: '2020',
23-
},
24-
compress: false,
25-
mangle: false,
26-
module: true,
27-
}),
28-
]
29-
};
5+
input: "./src/index.ts",
6+
output: {
7+
dir: "lib",
8+
format: "esm",
9+
entryFileNames: "[name].mjs",
10+
sourcemap: true,
11+
},
12+
plugins: [
13+
typescript({
14+
tsconfig: "tsconfig.json",
15+
module: "ES2020",
16+
target: "ES2020",
17+
}),
18+
terser({
19+
format: {
20+
comments: "some",
21+
beautify: true,
22+
ecma: "2020",
23+
},
24+
compress: false,
25+
mangle: false,
26+
module: true,
27+
}),
28+
],
29+
};

src/algorithm/binary_search.ts

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
//================================================================
2+
23
/**
34
* @packageDocumentation
45
* @module std
56
*/
67
//================================================================
7-
import { IForwardIterator } from "../iterator/IForwardIterator";
88
import { IPointer } from "../functional/IPointer";
9-
import { Pair } from "../utility/Pair";
10-
11-
import { Comparator } from "../internal/functional/Comparator";
12-
import { distance, advance } from "../iterator/global";
139
import { less } from "../functional/comparators";
10+
import { Comparator } from "../internal/functional/Comparator";
11+
import { IForwardIterator } from "../iterator/IForwardIterator";
12+
import { advance, distance } from "../iterator/global";
13+
import { Pair } from "../utility/Pair";
1414

1515
/* =========================================================
1616
BINARY SEARCH
@@ -26,27 +26,27 @@ import { less } from "../functional/comparators";
2626
* @return Iterator to the first element equal or after the val.
2727
*/
2828
export function lower_bound<
29-
ForwardIterator extends Readonly<
30-
IForwardIterator<IPointer.ValueType<ForwardIterator>, ForwardIterator>
31-
>,
29+
ForwardIterator extends Readonly<
30+
IForwardIterator<IPointer.ValueType<ForwardIterator>, ForwardIterator>
31+
>,
3232
>(
33-
first: ForwardIterator,
34-
last: ForwardIterator,
35-
val: IPointer.ValueType<ForwardIterator>,
36-
comp: Comparator<IPointer.ValueType<ForwardIterator>> = less,
33+
first: ForwardIterator,
34+
last: ForwardIterator,
35+
val: IPointer.ValueType<ForwardIterator>,
36+
comp: Comparator<IPointer.ValueType<ForwardIterator>> = less,
3737
): ForwardIterator {
38-
let count: number = distance(first, last);
38+
let count: number = distance(first, last);
3939

40-
while (count > 0) {
41-
const step: number = Math.floor(count / 2);
42-
const it: ForwardIterator = advance(first, step);
40+
while (count > 0) {
41+
const step: number = Math.floor(count / 2);
42+
const it: ForwardIterator = advance(first, step);
4343

44-
if (comp(it.value, val)) {
45-
first = it.next();
46-
count -= step + 1;
47-
} else count = step;
48-
}
49-
return first;
44+
if (comp(it.value, val)) {
45+
first = it.next();
46+
count -= step + 1;
47+
} else count = step;
48+
}
49+
return first;
5050
}
5151

5252
/**
@@ -60,27 +60,27 @@ export function lower_bound<
6060
* @return Iterator to the first element after the key.
6161
*/
6262
export function upper_bound<
63-
ForwardIterator extends Readonly<
64-
IForwardIterator<IPointer.ValueType<ForwardIterator>, ForwardIterator>
65-
>,
63+
ForwardIterator extends Readonly<
64+
IForwardIterator<IPointer.ValueType<ForwardIterator>, ForwardIterator>
65+
>,
6666
>(
67-
first: ForwardIterator,
68-
last: ForwardIterator,
69-
val: IPointer.ValueType<ForwardIterator>,
70-
comp: Comparator<IPointer.ValueType<ForwardIterator>> = less,
67+
first: ForwardIterator,
68+
last: ForwardIterator,
69+
val: IPointer.ValueType<ForwardIterator>,
70+
comp: Comparator<IPointer.ValueType<ForwardIterator>> = less,
7171
): ForwardIterator {
72-
let count: number = distance(first, last);
72+
let count: number = distance(first, last);
7373

74-
while (count > 0) {
75-
const step: number = Math.floor(count / 2);
76-
const it: ForwardIterator = advance(first, step);
74+
while (count > 0) {
75+
const step: number = Math.floor(count / 2);
76+
const it: ForwardIterator = advance(first, step);
7777

78-
if (!comp(val, it.value)) {
79-
first = it.next();
80-
count -= step + 1;
81-
} else count = step;
82-
}
83-
return first;
78+
if (!comp(val, it.value)) {
79+
first = it.next();
80+
count -= step + 1;
81+
} else count = step;
82+
}
83+
return first;
8484
}
8585

8686
/**
@@ -94,19 +94,19 @@ export function upper_bound<
9494
* @return Pair of {@link lower_bound} and {@link upper_bound}.
9595
*/
9696
export function equal_range<
97-
ForwardIterator extends Readonly<
98-
IForwardIterator<IPointer.ValueType<ForwardIterator>, ForwardIterator>
99-
>,
97+
ForwardIterator extends Readonly<
98+
IForwardIterator<IPointer.ValueType<ForwardIterator>, ForwardIterator>
99+
>,
100100
>(
101-
first: ForwardIterator,
102-
last: ForwardIterator,
103-
val: IPointer.ValueType<ForwardIterator>,
104-
comp: Comparator<IPointer.ValueType<ForwardIterator>> = less,
101+
first: ForwardIterator,
102+
last: ForwardIterator,
103+
val: IPointer.ValueType<ForwardIterator>,
104+
comp: Comparator<IPointer.ValueType<ForwardIterator>> = less,
105105
): Pair<ForwardIterator, ForwardIterator> {
106-
first = lower_bound(first, last, val, comp);
107-
const second: ForwardIterator = upper_bound(first, last, val, comp);
106+
first = lower_bound(first, last, val, comp);
107+
const second: ForwardIterator = upper_bound(first, last, val, comp);
108108

109-
return new Pair(first, second);
109+
return new Pair(first, second);
110110
}
111111

112112
/**
@@ -120,16 +120,16 @@ export function equal_range<
120120
* @return Whether the value exists or not.
121121
*/
122122
export function binary_search<
123-
ForwardIterator extends Readonly<
124-
IForwardIterator<IPointer.ValueType<ForwardIterator>, ForwardIterator>
125-
>,
123+
ForwardIterator extends Readonly<
124+
IForwardIterator<IPointer.ValueType<ForwardIterator>, ForwardIterator>
125+
>,
126126
>(
127-
first: ForwardIterator,
128-
last: ForwardIterator,
129-
val: IPointer.ValueType<ForwardIterator>,
130-
comp: Comparator<IPointer.ValueType<ForwardIterator>> = less,
127+
first: ForwardIterator,
128+
last: ForwardIterator,
129+
val: IPointer.ValueType<ForwardIterator>,
130+
comp: Comparator<IPointer.ValueType<ForwardIterator>> = less,
131131
): boolean {
132-
first = lower_bound(first, last, val, comp);
132+
first = lower_bound(first, last, val, comp);
133133

134-
return !first.equals(last) && !comp(val, first.value);
134+
return !first.equals(last) && !comp(val, first.value);
135135
}

0 commit comments

Comments
 (0)